[eigen] Eigen solver usage: simple questions
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: [eigen] Eigen solver usage: simple questions
• From: William Oquendo <woquendo@xxxxxxxxx>
• Date: Tue, 20 Jul 2010 16:06:48 -0500
• Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=MKaPaupTtl5//lD7tjKkoBxqoZ4F8UQYjdjzfKXv0ZbFyZAJLss1NEm3Ht/Zr4S+RS px7vkrKToWN2Nj6KTr3TdHqEOSXA8M4C/50d8mcQ/7GB9EgeWH3TLwnvr6v2oIpJGtxp xeI3RYubB8Zoh2tDTomTYhCb/fAm7qMsn+UcI=

Dear all,

First of all I apologize in advance if my questions are too simple, I read the docs but the info about eigen solvers is small. Second, I would like to thank you for the great work in Eigen!

I have been using eigen  (currently 2.0.15, compiler g++ 4.4.4, Slackware64 13.1) to solve eigenvalue problems. But now I am concerned with the way I am using the library. I have a 3x3 array (simulating the matrix) and I need to compute, by now, only the eigenvalues. When I execute the code (please see a reduced example copied at the end and also attached), the program dies with the following error assertion (in general my matrix is not self adjoint):

a.out: /usr/local/include/eigen2/Eigen/src/QR/SelfAdjointEigenSolver.h:296: Eigen::Matrix<typename Eigen::NumTraits<typename Eigen::ei_traits<T>::Scalar>::Real, Eigen::ei_traits::ColsAtCompileTime, 1, 2, Eigen::ei_traits::ColsAtCompileTime, 1> Eigen::MatrixBase<Derived>::eigenvalues() const [with Derived = Eigen::Map<Eigen::Matrix<double, 3, 3, 2, 3, 3>, 1>]: Assertion `Flags&SelfAdjointBit' failed.

But, if I compile with the flag -DNDEBUG, the programs ends successfully with the correct data (even with null matrices), as far as I have checked. How can I specify to Eigen that my matrix is not selfAdjoint? (if that is the problem ...

Let's assume now that I need both the eigen values and eigen vectors, and I am using the full eigen solver:
EigenSolver<Matrix3d> solver(Meigen);
Is it possible to sort the eigen values by norm and, of course, their corresponding eigen vectors by means of some internal eigen function? I can write a function to do that, but I would like to know if Eigen can do it already.

Best regards / Cordialmente,

--
William Oquendo
Phd Candidate
Simulation Of Physical Systems Group
National University of Colombia
Linux User # 321481
*********************
Este correo puede carecer de tildes o eñes ya que el teclado no contiene estos caracteres. Presento excusas por eso.

*********************

CODE

#include <iostream>
#include <eigen2/Eigen/Core>
#include <eigen2/Eigen/Array>
#include <eigen2/Eigen/QR>
using namespace Eigen;
using namespace std;

void ComputeEigenValues(double Matrix[], double & l0, double & l1, double & l2);

int main()
{
double M = { 1, 0, 0,
0, 1, 0,
0, 0, 1 };

double e0, e1, e2;

ComputeEigenValues(M, e0, e1, e2);

clog << "The eigen values are " << endl
<< e0 << endl
<< e1 << endl
<< e2 << endl
<< endl;

return 0;
}

void ComputeEigenValues(double Matrix[], double & l0, double & l1, double & l2)
{
l0 = l1 = l2 = 0;
Map<Matrix3d> Meigen(&Matrix);
Vector3d veval =  Meigen.eigenvalues();
l0 = veval..real();
l1 = veval.real();
l2 = veval.real();
}

```#include <iostream>
#include <eigen2/Eigen/Core>
#include <eigen2/Eigen/Array>
#include <eigen2/Eigen/QR>
using namespace Eigen;
using namespace std;

void ComputeEigenValues(double Matrix[], double & l0, double & l1, double & l2);

int main()
{
double M = { 1, 0, 0,
0, 1, 0,
0, 0, 1 };

double e0, e1, e2;

ComputeEigenValues(M, e0, e1, e2);

clog << "The eigen values are " << endl
<< e0 << endl
<< e1 << endl
<< e2 << endl
<< endl;

return 0;
}

void ComputeEigenValues(double Matrix[], double & l0, double & l1, double & l2)
{
l0 = l1 = l2 = 0;
Map<Matrix3d> Meigen(&Matrix);
Vector3d veval =  Meigen.eigenvalues();
l0 = veval.real();
l1 = veval.real();
l2 = veval.real();
}
```

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/