Registered Member
|
hi,
In my case, coeffRef is really slow on Eigen 3.3.4. I also tried it on 3.3.3, but it is same. But when I tried to use 3.2.10, it is very first. Those speed difference is over 1000 times!! And of course I used same code. Eigen::SparseMatrix<double> mat(x_size, x_size); mat.setFromTriplets(trips.begin(), trips.end()); ...... for (int row = 0; row < mat.outerSize(); ++row) { mat.coeffRef(row, row) = 1; } I have around 200,000 x 200,000 matrix, but it takes 600sec on 3.3.4. on the 3.2.10 takes less than 1sec. So, what should I do it on 3.3.4??? I'm using visual studio 2013. |
Moderator
|
3 questions:
1 - are benchmarking in release mode? 2 - are you benchmarking the for loop only (i.e. without the setFromTriplets call)? 3 - do the diagonal coefficient already exist ? (are they included in trips?) If the answers are yes, yes, no then calling mat.reserve(VectorXi::Constant(x_size,1)) prior to insertion will speed up them. If you are absolutely sure they don't exist, calling insert instead of coeffRef will also be faster. |
Registered Member
|
Thank you for your advice.
Once I put reserve, I got significant faster speed such as 3.2.10! |
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]