Suppose that I have a large sparse matrix with the following pattern:

- the number of nonzeros per column and their locations are fixed
- only matrix block A and B will change and the rest of the matrix stays static; (blocks A and B themselves are also sparse with fixed nonzero locations)
As instructed in the document, i've initialized the above matrix by
- reserving the exact number of nonzeros per column for the column major sparse matrix
- inserting column by column
- inserting from the smallest row index per column
In later part of the program, it's natural to reuse the matrix and only updates the A, B blocks inplace. Possible ways are:
- accessing existing entries by
coeffRef
, would introduce binary search so not preferred here. - iterating over the outer and inner dimensions as documented here
However, it seems a bit unnecessary to iterate over all nonzero entries since most part of the sparse matrix stays the same.
Is it possible to update A, B inplace without iterating over all nonzeros in the matrix?