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

Creating a sparse matrix without allocating data vectors

Tags: None
(comma "," separated)
joelandersson
Registered Member
Posts
2
Karma
0
OS
Hello!

I am the author of a symbolic package called CasADi and I am considering to integrate it a bit tighter with Eigen.

In CasADi, there is a template based sparse matrix type where the entries are stored in the same row compressed format that you are using in Eigen.

This means that in addition two the dimension and an std::vector< > with the nonzeros, I have two std::vector<int> containing the columns of each nonzero and the nonzero offset for each row. Just standard row compressed format.

Is there some simple way to create an Eigen matrix out of this, without allocating new vectors for the sparsity and the data and copying the entries?

Best,
Joel
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
yes, you can use a MappedSparseMatrix<Scalar,_Flags,_Index> mat(Index rows, Index cols, Index nnz, Index* outerIndexPtr, Index* innerIndexPtr, Scalar* valuePtr)

in the future I'll probably move this feature into SparseMatrix<> itself.


Bookmarks



Who is online

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