• Advertisement

Archived

This topic is now archived and is closed to further replies.

rows and columns

This topic is 6515 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was told that C++ was a "row major" language or row based...something like that...anyway, does it really matter if you put rows before columns if you stay consistent? /_-_-_-_-_-_-_-/ :: It's a Box! :: /_-_-_-_-_-_-_-/

Share this post


Link to post
Share on other sites
Advertisement
That refers how it's multi-dimensional arrays are layed out in memory. Entries in a single row are layed out in adjacent memory locations. For a two-dimensional array it will be kinder on the cache of you address adjacent items in a row rather than adjacent items in a column.
i.e.

int temp = 0;
for (a = 0; a < 128; a++)
for (b = 0; b < 128; b++)
temp += array[ a ][ b ];

will be friendlier to the cache than

int temp = 0;
for (a = 0; a < 128; a++)
for (b = 0; b < 128; b++)
temp += array[ b ][ a ];

Some languages lay it out differently. (I think FORTRAN does.)

Post editted due to major forum mangling.


Edited by - SiCrane on 4/18/00 10:53:50 PM

Share this post


Link to post
Share on other sites

  • Advertisement