comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.not.jrcarter@acm.not.spam.org>
Subject: Re: How to pass two dimensional arrays to C
Date: Sat, 29 Jul 2006 22:12:07 GMT
Date: 2006-07-29T22:12:07+00:00	[thread overview]
Message-ID: <X2Ryg.107393$1i1.10567@attbi_s72> (raw)
In-Reply-To: <m24px0sx58.fsf@grendel.local>

Simon Wright wrote:
> 
> I would have thought that, provided you choose the right orientation,
> the rows would be as expected by C (ie contiguous values).
> 
> In
> 
>    type M is array (Integer range <>, Integer range <>) of Float;
>    --               Column            Row
> 
> the Row elements would be contiguous? (I can see there _might_ be
> compiler differences, and ISTR that GNAT has a way of specifying
> Fortran conventions).

The 1st dimension is considered to index the rows and the 2nd, the 
columns (from the mathematical notation for 2D matrices). In Ada, all 
the components of the 1st row are stored in sequence, followed by all 
the components of the next row, and so on. "An implementation should 
normally represent multidimensional arrays in row-major order, 
consistent with the notation used for multidimensional array aggregates 
(see 4.3.3). However, if a pragma Convention(Fortran, ...) applies to a 
multidimensional array type, then column-major order should be used 
instead (see B.5, ``Interfacing with Fortran'')." (ARM 3.6.2). (Note 
that convention FORTRAN is defined by the language, not GNAT specific.)

In other words, the 2nd, or column, index varies most quickly with 
increasing address.

So to my mind, and using the notation I've described here, the row 
elements are contiguous. So I don't know whether we agree or disagree.

-- 
Jeff Carter
"Whatever it is, I'm against it."
Horse Feathers
46



  reply	other threads:[~2006-07-29 22:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-28 11:06 How to pass two dimensional arrays to C Jerry
2006-07-28 12:27 ` Jeffrey Creem
2006-07-28 12:27 ` Dmitry A. Kazakov
2006-07-28 16:53 ` Adam Beneschan
2006-07-28 20:15 ` Jeffrey R. Carter
2006-07-28 20:46 ` Jerry
2006-07-28 21:14   ` Jeffrey Creem
2006-07-28 22:54   ` Björn Persson
2006-07-29  1:14     ` Jeffrey R. Carter
2006-07-29  7:11       ` Simon Wright
2006-07-29 22:12         ` Jeffrey R. Carter [this message]
2006-07-30 11:18           ` Simon Wright
2006-07-30 11:20           ` Simon Wright
2006-07-29  4:19   ` REH
2006-07-29  4:28     ` REH
2006-07-29  4:30       ` REH
2006-08-14  6:59     ` Dave Thompson
2006-07-29  5:47 ` REH
2006-08-02  8:20 ` Jerry
2006-08-02  9:03   ` Dmitry A. Kazakov
2006-08-02 10:22     ` Jerry
2006-08-02 18:25   ` Björn Persson
2006-08-05  1:03 ` Jerry
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox