Compressed sparse row (CSR, CRS or Yale format) of Sparse matrix Top 12 Facts

  • 8 years ago
Facts : 1 Compressed sparse row (CSR, CRS or Yale format) The compressed sparse row (CSR) or compressed row storage (CRS) format represents a matrices M by three (one-dimensional) arrays, that respectively contain nonzero values, the extents of rows, and column indices
Facts : 2 The CSR format has been in use since at least the mid-1960s, with the first complete description appearing in 1967
Facts : 3 (Note that zero-based indices shall be used here.) The array A is of length NNZ and holds all the nonzero entries of M in left-to-right top-to-bottom ( row-major ) order
Facts : 4 The array IA is of length m + 1 and contains the index in A of the first element in each row, followed by the total number of nonzero elements NNZ
Facts : 5 Another way to understand this array is to define IA[0] as zero ,then the nth element IA[n] is the total count of nonzero element from row[0] to row[n-1]
Facts : 6 The third array, JA, contains the column index in M of each element of A and hence is of length NNZ as well
Facts : 7 In this case the CSR representation contains 13 entries, compared to 16 in the original matrix
Facts : 8 IA splits the array A into rows: (10, 20) (30, 40) (50, 60, 70) (80); JA aligns values in columns: (10, 20, ...) (0, 30, 0, 40, ...)(0, 0, 50, 60, 70, 0) (0, 0, 0, 0, 0, 80)
Facts : 9 Note that in this format, the first value of IA is always zero and the last is always NNZ, so they are in some sense redundant
Facts : 10 However, they can make accessing and traversing the array easier for the programmer
Facts : 11 The (old and new) Yale sparse matrix formats are instances of the CSR scheme
Facts : 12 The old Yale format works exactly as described above, with three arrays; the new format achieves a further compression by combining IA and JA into a single array