473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Arrays storage

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
3 4004
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: csx | last post by:
Hi everyone! two quick questions relating to arrays. Q1, Is it possible to re-assign array elements? int array = {{2,4}, {4,5}}; array = {2,3}
5
by: Gent | last post by:
I have two questions which are very similar: Is it possible to return an object in C++. Below is part of my code for reference however I am more concerned about the concept. It seems like the...
12
by: Samee Zahur | last post by:
Back in the days of old C, only numeric literals could be used as dimensions for statically allocated arrays - the size had to be resolved to a constant at/before compile time. Now I'm beginning to...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
1
by: Nathan Gilbert | last post by:
I have a function that is returning a 2D array (declared using double pointers) and I want to be able to append a row of data to the beginning and end of this array without having to create a new...
32
by: santosh | last post by:
In following code char str = "asdf" ; str = 's' ; is possible. But char *str = "asdf" ; str = 's' ; is an run-time error. What i understand is *str = "asdf" is stored in Read-only-Memory....
6
by: Broeisi | last post by:
Hello, I wrote the tiny progam below just to understand arrays and strings better. I have 2 questions about arrays and strings in C. 1. Why is it that when you want to assign a string to an...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.