Skip to content

Latest commit

 

History

History
11 lines (6 loc) · 733 Bytes

File metadata and controls

11 lines (6 loc) · 733 Bytes

What is a sparse matrix? Explain an efficient way of storing a sparse matrix in memory

A matrix in which number of zero entries are much higher than the number of non zero entries is called sparse matrix.

One of the efficient ways of storing a sparse matrix in memory is the Compressed Sparse Row (CSR) format, also known as the Compressed Row Storage (CRS) format. In this format, the non-zero elements are stored in three separate arrays:

1.values: This array stores the non-zero values of the matrix in row-major order.

2.columns: This array stores the column indices of the non-zero values corresponding to the values array.

3.row_ptr: This array stores the starting index of each row in the values and columns arrays.