Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The article seems to point out different ways to represent matrix data structures and the performance gains of a single array representation, although it doesn't really explain why you get the performance gains.</p> <p>For example, to represent a NxNxN matrix:</p> <p>In object form:</p> <pre><code>Cell { int x,y,z; } Matrix { int size = 10; Cell[] cells = new Cell[size]; } </code></pre> <p>In three-arrays form:</p> <pre><code>Matrix { int size = 10; int[][][] data = new int[size][size][size]; } </code></pre> <p>In a single array:</p> <pre><code>Matrx { int size = 10; int[] data = new int[size*size*size]; } </code></pre> <p>To your question, there is a performance gain by representing a NxN matrix as a single array of N*N length, you gain performance because of caching (assuming you cannot fit the entire matrix in one chunk); a single array representation guarantees the entire matrix will be in a contiguous chunk of memory. When data is moved from memory into cache (or disk into memory), it is moved in chunks, you sometimes grabs more data than you need. The extra data you grab contains the area surrounding the data you need.</p> <p>Say, you are processing the matrix row by row. When getting new data, the OS can grab N+10 items per chunk. In the NxN case, the extra data (+10) <em>may</em> be unrelated data. In the case of a N*N length array, the extra data (+10) is most likely from the matrix.</p> <p>This article from SGI seems to give a bit more detail, specifically the Principles of Good Cache Use: <a href="http://techpubs.sgi.com/library/dynaweb_docs/0640/SGI_Developer/books/OrOn2_PfTune/sgi_html/ch06.html" rel="nofollow">http://techpubs.sgi.com/library/dynaweb_docs/0640/SGI_Developer/books/OrOn2_PfTune/sgi_html/ch06.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload