Eigensystem

Very important is the EIG class, computing the eigenvalues and eigenvectors of all the above defined different matrix classes. By calling the constructor

// eigensystem of Matrix a
EIG (const Matrix& a)
// eigensystem of ComplexMatrix a
EIG (const ComplexMatrix& a)

the eigensystem of the matrix will be computed and stored within the class. The two functions

// returns the eigenvalues as a ComplexColumnVector
ComplexColumnVector eigenvalues (void)
// returns the eigenvectors in the columns of a ComplexMatrix
ComplexMatrix eigenvectors (void)

return the eigenvalues as a ComplexColumnVector and the eigenvectors oin the columns of a ComplexMatrix.

Eigensystem Example (Code)

#include <iostream>
#include <octave/oct.h>

int main()
{
     // initialization of the matrix
     ComplexMatrix A = ComplexMatrix(2,2);
     A(0,0)=Complex(1,1);A(0,1)=Complex(1,2);
     A(1,0)=Complex(2,1);A(1,1)=Complex(2,2);

     // compute eigensystem of A
     EIG eig = EIG(A);

     // eigenvalues
     std::cout « "eigenvalues:" « std::endl;
     std::cout « eig.eigenvalues();

     // eigenvectors
     ComplexMatrix V = (eig.eigenvectors());
     std::cout « "eigenvectors:" « std::endl;
     std::cout « V;

     // transformation to eigensystem of A
     ComplexMatrix D = ComplexMatrix(2,2);
     D = V.inverse()*A*V;
     std::cout « "diagonal matrix" « std::endl;
     std::cout « D;

     return 0;
}

Eigensystem Example (Output)

eigenvalues:
(-0.158312,-0.158312)
(3.15831,3.15831)
eigenvectors:
 (0.806694,0) (0.560642,0.186881)
 (-0.560642,0.186881) (0.806694,0)
diagonal matrix
 (-0.158312,-0.158312) (-5.13478e-16,2.77556e-17)
 (-4.44089e-16,-3.33067e-16) (3.15831,3.15831)