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

Modify Eigenvalues

Tags: None
(comma "," separated)
seanl
Registered Member
Posts
6
Karma
0

Modify Eigenvalues

Tue Sep 24, 2013 7:29 pm
Hi Eigen Community,

After I've diagonalized a matrix using:

Code: Select all
Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> eigOut(A);


I want to multiply each eigenvalue by some value and overwrite the original value.

I tried looping through each eigenvalue and then assigning the value. For example:

Code: Select all
for (int i=0; i< eigOut.eigenvalues().rows(); i++){
     eigOut.eigenvalues().row(i)*=i;
}


However, that refused to compile. Can anybody tell me how I should be accessing the eigenvalue itself and then be able to overwrite the pre-existing value?

Thanks!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Modify Eigenvalues

Wed Oct 02, 2013 8:38 pm
.eigenvalues() returns a const reference, you need to copy them to your own vector before modifying them:
Code: Select all
VectorXd eigvals = eigOut.eigenvalues();
...
eigvals(i) *= i


Bookmarks



Who is online

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