 |
Show this file without HTML
// -*- c++ -*-
//
// $COPYRIGHT$
//
//===========================================================================
#include
#include "mtl/mtl2lapack.h"
#include "mtl/dense1D.h"
#include "mtl/utils.h"
using namespace std;
/*
Sample Output
2x2
[
[0,1],
[-6,5]
]
eigenvalues
[(2,0),(3,0),]
eigenvectors
4x2
[
[0.447214,0.316228],
[0.894427,0.948683],
[0,0],
[0,0]
]
*/
int
main()
{
using namespace mtl2lapack;
const int N = 2;
//begin
double da [] = { 0, -6, 1, 5 };
lapack_matrix::type A(da, N,N), vl((double*)0,N,N);
lapack_matrix::type vr(2*N,N);
mtl::dense1D< std::complex > wr(N);
int info;
//end
mtl::print_all_matrix(A);
// Compute the eigenvalues and right eigenvectors of A.
//begin
info = geev(GEEV_CALC_RIGHT, A, wr, vl, vr);
//end
if (info > 0) {
cout << "QR failed to converge, INFO = " << info << endl;
return 0;
}
// Print the eigenvalues and eigenvectors.
cout << "eigenvalues" << endl;
mtl::print_vector(wr);
cout << "eigenvectors" << endl;
mtl::print_all_matrix(vr);
return 0;
}
|