This forum has been archived. All content is frozen. Please use KDE Discuss instead.

really slow coeffRef on 3.3.x

Tags: None
(comma "," separated)
Makoto
Registered Member
Posts
5
Karma
0

really slow coeffRef on 3.3.x

Sat Jul 29, 2017 10:15 pm
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: really slow coeffRef on 3.3.x

Sun Jul 30, 2017 7:48 am
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.
Makoto
Registered Member
Posts
5
Karma
0

Re: really slow coeffRef on 3.3.x

Sun Jul 30, 2017 11:39 pm
Thank you for your advice.
Once I put reserve, I got significant faster speed such as 3.2.10!


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]