Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About CRS Sparse Matrix storage

Hello i understand how CRS sparse Matrix works but i have a problem : what happens if a row is null (filled only with 0's) ? For example let the 5th row be null, what shall row_ptr(5) contain ?

like image 264
user2370139 Avatar asked Jul 08 '26 17:07

user2370139


2 Answers

The row pointer value will be duplicated, i.e. the row pointer will look like [1, 3, 3, 5]. This makes a lot of sense if you always think of the row pointer telling you how many non-zero entries there have been before the row with the index you're looking at.

By the way: even more interesting is what will happen if the last column(s) of a matrix will be empty. The CRS has no way to catch this scenario, which means that the number of columns is an additional information that cannot be encoded in the three arrays used in CRS.

like image 59
Ingo Bürk Avatar answered Jul 11 '26 11:07

Ingo Bürk


When a last row is zero we also double value. For example, last row number is 10, then a row index array contains [...., 11, 11]

like image 40
Ivan Kush Avatar answered Jul 11 '26 10:07

Ivan Kush



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!