Reputation: 1305
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 ?
Upvotes: 3
Views: 375
Reputation: 3157
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]
Upvotes: 1
Reputation: 20063
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.
Upvotes: 4