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

How to create a constant SparseMatrix object ?

Tags: None
(comma "," separated)
boborf
Registered Member
Posts
2
Karma
0
Hello,
This is a very simple question; I would like to create this kind of object:
Code: Select all
const SparseMatrix<double>
But filling up the SparseMatrix involves the setFromTriplets() method, which requires a non-constant object. It cannot be done inside a constructor (to my knowledge).

Is there any solution to bypass this and build + fill up a constant SparseMatrix? Any appropriate constructor or other method? Thank you very much for your help.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
const_cast<SparseMatrix<double>&>(mat).setFromTriplets() ;)

or create a non const tmp and "move" it to the const one.
boborf
Registered Member
Posts
2
Karma
0
Thank you :)


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]