Registered Member
|
Hi, could someone help me understand why this does not compile and what the correct way would be to access elements in a symmetric sparse matrix. In my real code the matrix is created once and I would like to write to the matrix elements without having to explicitly check which index is greater.
Eigen::SparseMatrix<double> sm(3,3); sm.selfadjointView<Eigen::Lower>.coeffRef(1,2)+=1.0; Thanks, Staffan |
Moderator
|
The best is that you check the indices yourself:
if(i>=j) sm.coeffRef(i,j) += 1; Otherwise, in typical assembly code we would have an ambiguity when doing: sm.selfadjointView<Lower>().coeffRef(i,j) += 1; sm.selfadjointView<Lower>().coeffRef(j,i) += 3; -> shall we ignore the second call to coeffRef or add 3 to the symmetric coefficient i,j |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]