In one of my class, I need to update a sparse matrix by adding new columns to a sparse matrix, but there is no conservative reside method for sparse matrices for the moment.
Implementing it would probably require at the same time
1) to grow the OuterIndexPtrs
2) to reserve space
so I would suggest to implement
conservativeResize(Index rows, Index cols, const SizesType &reserveSizes)
Some other methods could be built from this, like
conservativeResize(Index rows, Index cols, Index reserveSize) where the reserveSize is used when greater than the actual size
conservativeResize(Index rows, Index cols) where everything is kept as is (but OuterIndexPtrs)
To keep the API as simple as possible I would only implement the conservativeResize(Index rows, Index cols) variant. Reserving space can be done in a second time by calling reserve(reserveSize). Patch welcome.
Please find a patch implementing conservativeResize (along with corresponding tests).
Notice that the type of memory structures was changed from Index to Index * in order to use std::realloc.
Created attachment 269 [details]
Patch against head that implements conservativeResize for SparseMatrix
thanks for the patch, I'm too busy ATM, I'll look at it next week.
Hi, any news on this before the source tree diverges too much from the revision I was based on? Thanks.
Thanks again for this patch, it is very good. Applied:
date: 2012-07-19 00:07:06
summary: bug 449: add SparseMatrix::conservativeResize feature
btw, for the reserve stuff, we could add a reserve method to "SparseInnerVectorSet<SparseMatrix<_Scalar, _Options, _Index>, Size>" so that one can easily reserve space for a given set of rows or columns. The only trick is to factor the implementation with the implementation of SparseMatrix::reserve. To this end, one could implement a protected low level method of SparseMatrix. So I'm re-opening.
(hit the button too fast) The relation with conservativeResize is that when you add new columns or rows you probably only want to reserve space for the ones only which are obtained as follow, e.g.:
-- GitLab Migration Automatic Message --
This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/449.