How to Get Eigen Values and Eigen Vectors of a Matrix?

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
salehi
Posts: 49
Joined: Wed Aug 01, 2012 3:57 am
Location: University of Colorado - Boulder

How to Get Eigen Values and Eigen Vectors of a Matrix?

Post by salehi »

Hello everyone,

I am working on an element in whose formulation I need to determine the eigenvalues and the eigenvectors of a matrix... could anybody let me know how I may do eigen analysis in OpenSees? I tried using the following lines, but I could not set the size for theEigenSOE object:

static BandGenLinSolver *theSolver = new BandGenLinLapackSolver();
static LinearSOE *theArpackSOE = new BandGenLinSOE(*theSolver);
static EigenSOE *theEigenSOE = new ArpackSOE(*theArpackSOE, 0.0);

theEigenSOE->zeroA();
theEigenSOE->zeroM();

theEigenSOE->addA(K_ms, eleID); // "K_ms" is the matrix I need its eigenvalues
theEigenSOE->addM(I, eleID); // "I" is identity matrix

theEigenSOE->solve(9, true);
eigenValues(i) = theEigenSOE->getEigenvalue(i);
eigenVectors[i] = theEigenSOE->getEigenvector(i);

Also, I am wondering if any of the solvers other than Arpack can compute all the N eigenvalues of a N-by-N matrix, instead of the first N-1. I am looking forward to hearing from you and thanks in advance.
Mohammad Salehi
Graduate Research Assistant
PhD Student - Structural Engineering and Structural Mechanics
University of Colorado at Boulder
salehi
Posts: 49
Joined: Wed Aug 01, 2012 3:57 am
Location: University of Colorado - Boulder

Re: How to Get Eigen Values and Eigen Vectors of a Matrix?

Post by salehi »

I found out how to do this... for those who may concern, you need to modify the FullGenEigenSolver class or similar EigenSolver classes to get a Matrix object without calling analysis classes and needing Graph objects to set the size given to the EigenSolver; you also need to utilize a couple of functions of FullGenEigenSOE to add matrices to the class in the form of pointers, i.e. FullGenEigenSOE::addA() and addM()... By the way, note that while FullGenEigenSolver refers to a Fortran code which can compute all the N eigenvalues of a N-by-N matrix, Arpack solver can only compute the first N-1.
Mohammad Salehi
Graduate Research Assistant
PhD Student - Structural Engineering and Structural Mechanics
University of Colorado at Boulder
Post Reply