Closed shaundatta closed 4 years ago
The last entry is indeed A.rowptr[i+1]-1
however this corresponds to the diagonal entry. So it is used in the division two lines down. That's basically the main difference between a mat-vec and a triangular solve. You need to skip the diagonal entry and use it to divide.
The code for Lx=b (L sparse, b dense) loops for k=A.rowptr[i]:A.rowptr[i+1]-2. Perhaps I am mistaken, but I would expect this to be k=A.rowptr[i]:A.rowptr[i+1]-1, as it is in the code for matrix-vector multiplication on p. 332, where we select the indices of nzval corresponding to each row of the matrix.