Advertisement

rows and columns

Started by April 18, 2000 10:45 PM
0 comments, last by Zumichu 24 years, 8 months ago
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! :: /_-_-_-_-_-_-_-/
[I did absolutely nothing, and it was everything that I thought it could be]
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 ];<br> </pre>  <br>will be friendlier to the cache than<br><pre><br>int temp = 0;<br>for (a = 0; a < 128; a++)<br>  for (b = 0; b < 128; b++)<br>    temp += array[ a ];<br>  </pre>  <br>Some languages lay it out differently. (I think FORTRAN does.)<br><br>Post editted due to major forum mangling.<br><br><br>Edited by - SiCrane on 4/18/00 10:53:50 PM    

This topic is closed to new replies.

Advertisement