Registered Member
|
I'm trying to figure out the 'best' (most efficient) way to permute a sparse matrix in Eigen given a permutation stored as a vector. For example, I currently have:
Is this the proper 'Eigen' way to permute a sparse matrix? Will PermutationMatrix respect the sparsity (that is, it won't evaluate to a dense matrix here, will it)? Thank you for your advices and tips. |
Moderator
|
You can avoid the copy using the asPermutation() method returning a permutation expression, and please do not use evalTo() which is rather an internal thing:
And yes, of course this will both exploit and preserve the sparsity. |
Registered Member
|
Many thanks, the code you have suggested works perfectly.
|
Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar