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

Trying to assign an extern csr matrix to Eigen

Tags: None
(comma "," separated)
Freacky2002
Registered Member
Posts
1
Karma
0
OS
Hi all,

perhaps somebody can help with my litte porblem. I am trying to asing a csr matrix to Eigen sparseMatrix. I have 3 pointers of 1D array with row_ptr, col_index and values. I want to asign or copy to a SparseMatrix. I tried some things but nothing works. Would be great if somebody can help me.

Thanks!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
you can use the MappedSparseMatrix class for that, here is an example:

SparseMatrix<douvle,RowMajor> mat = MappedSparseMatrix<double,RowMajor>(rows, cols, nnz, row_ptr, col_index, values);

Note that you can avoid a copy and directly use the MappedSparseMatrix object into Eigen's expression, e.g.:

MappedSparseMatrix<double,RowMajor> mat(rows, cols, nnz, row_ptr, col_index, values);

v2 = mat * v1;


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora