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

Sharing data between double pointer and MatrixXd

Tags: None
(comma "," separated)
marvisiyer
Registered Member
Posts
21
Karma
0
I have a double pointer double* a which holds a N by N matrix row-wise. I want to share this to a MatrixXd variable but without copying the contents of double* a. How should I go about doing this? From here (http://stackoverflow.com/questions/1200 ... gen-matrix), I see that the other way around is possible using the the method data().

Thanks
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
You have to create a Map object like this:
Code: Select all
Map<Matrix<double,Dynamic,Dynamic,RowMajor> >  mat(ptr, N, N);


You can use mat just like a MatrixXd except that its type is not a MatrixXd and not even a Matrix<double,Dynamic,Dynamic,RowMajor>.


Bookmarks



Who is online

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