By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,321 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,321 IT Pros & Developers. It's quick & easy.

Arrays storage

P: n/a
Hello,

I'd like to improve several critical routines involving arrays (vectors and
matrices)...

How are arrays stored in memory?
Row major or column major?

(Like in C or like Fortran?)

Thank you in advance
Apr 18 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
alcabo <al****@discussions.microsoft.com> wrote:
I'd like to improve several critical routines involving arrays (vectors and
matrices)...

How are arrays stored in memory?
Row major or column major?

(Like in C or like Fortran?)


What kind of arrays are you talking about? True rectangular arrays, or
jagged arrays?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 18 '06 #2

P: n/a
Hello Jon,

Now I don't know what the jagged arrays are... What do you understand by
jagged arrays?

I think I'm talking about rectangular arrays having a compact storage.

For example,

int [] myArray = new int[10];

is stored in C as
XXXXXXXXXX

and

int [,] myArray = new int[3, 5];

is stored in C as
XXXXX
XXXXX
XXXXX

where X represents the amount of memory to store an integer value.

I'd be very graceful if you could link me to references about these issues

Alex
--
"Jon Skeet [C# MVP]" wrote:
alcabo <al****@discussions.microsoft.com> wrote:
I'd like to improve several critical routines involving arrays (vectors and
matrices)...

How are arrays stored in memory?
Row major or column major?

(Like in C or like Fortran?)


What kind of arrays are you talking about? True rectangular arrays, or
jagged arrays?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Apr 18 '06 #3

P: n/a
alcabo <al****@discussions.microsoft.com> wrote:
Now I don't know what the jagged arrays are... What do you understand by
jagged arrays?
Arrays of arrays.
I think I'm talking about rectangular arrays having a compact storage.

For example,

int [] myArray = new int[10];

is stored in C as
XXXXXXXXXX
That's just a single-dimensional array.
and

int [,] myArray = new int[3, 5];

is stored in C as
XXXXX
XXXXX
XXXXX
That's a rectangular array.
where X represents the amount of memory to store an integer value.

I'd be very graceful if you could link me to references about these
issues


The ECMA CLI specification gives the answer on this one:

<quote>
Array elements shall be laid out within the array object in row-major
order, i.e. the elements associated with the rightmost array dimension
shall be laid out contiguously from lowest to highest index. The actual
storage allocated for each array element may include platform-specific
padding.
</quote>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 18 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.