Registered Member
|
I found a strange behavior of SparseMatrix's method coeffRef(i,j).
When an sparse matrix m is initialized with some non zeros, anytime I used m.coeffRef(i,j) but not assign any value to it, it will add an entry of m(i,j) with 0 if it is not previously assigned. For example, if m(0,0) is not initialized and if I use if (m.coeffRef(0,0) > 1) in a statement, the result will be that m(0,0) is initialized as 0 after the call, which should not be added. This is strange. |
Registered Member
|
I got the answer. Simply replace coeffRef with coeff method to avoid unintended insertion.
|
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]