Registered Member
|
I thought coeffRef would insert a new element if it didn't already exist but I'm getting segfaults because the m_outerSize never grows. This construction is dynamic. I used to use DynamicSparseMatrix and resizeAndKeepData then the coeffRef but that's not available anymore. Can SparseMatrix objects not extend their outer dimensions themselves?
|
Moderator
|
Cannot you know the dimension of your matrix beforehand? Even though SparseMatrix would support growing, knowing the size in advance would be much faster. Note that setFromTripplet() might be the right solution for you unless you are in the specific case were you already have a matrix that you used for some computation and now you need to update/extend it?
|
Registered Member
|
Thanks for the reply. I know I can use the setFromTriplet function if I know the size before hand. What I need is a dynamic sparse matrix, like what Eigen used to have (I know it's in unsupported now - I don't want to use that). My question is can SparseMatrix grow itself? The docs seem to say that coeffRef will grow the matrix appropriately if the new element does not exist but when I try to use it, I get seg faults. For example if I just default construct a SparseMatrix and then try to coeffRef (i,j,v) it faults in reserveInnerVectors when it tries to index into m_outerIndex[m_outerSize-1] because the outerSize was never resized (to atleast i+1, from 0). It looks like SparseMatrix can only be extended in the inner direction.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]