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

How can I push back eigenvectors into vector<double> ?

Tags: None
(comma "," separated)
kimkevin
Registered Member
Posts
2
Karma
0
I'm starting to love Eigen, and quite new to this, but suppose I find eigenvectors of a matrix type MatrixXd

using SelfAdjointEigenSolver<MatrixXd> eigensolver ..... and I get eigenvectors via eigensolver.eigenvectors();

then how can I turn that into standard c++ matrix form? i.e. how can I push back each eigenvector into vector<double> ?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
You can map both data structures as a linear 1D array:

vector<double> vec(n*n);
VectorXd::Map(vec.data(), n*n) = VectorXd::Map(eigensolver.eigenvectors().data(), n*n);

or use memcpy...


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]