CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
ex10a_geev_decomposition.cpp
#include <iostream>
#include <cla3p/dense.hpp>
#include <cla3p/eigsol.hpp>
int main()
{
/*
* Create a random 4x4 general (non-symmetric) matrix.
*/
std::cout << "A:\n" << A;
/*
* Set a simple geev object (right eigenvectors only, the default).
*/
/*
* Decompose A: compute eigenvalues and right eigenvectors.
*/
geev.decompose(A);
std::cout << "GEEV Decomposition of A (right eigenvectors only)\n";
std::cout << "-------------------------------------------------\n";
std::cout << "Eigenvalues:\n" << geev.eigenvalues() << "\n";
std::cout << "Right Eigenvectors:\n" << geev.rightEigenvectors() << "\n";
/*
* Set a geev object requesting both left and right eigenvectors,
* with buffer pre-allocation.
*/
geevLR.reserve(4);
geevLR.decompose(A);
std::cout << "GEEV Decomposition of A (left and right eigenvectors)\n";
std::cout << "-----------------------------------------------------\n";
std::cout << "Eigenvalues:\n" << geevLR.eigenvalues() << "\n";
std::cout << "Left Eigenvectors:\n" << geevLR.leftEigenvectors() << "\n";
std::cout << "Right Eigenvectors:\n" << geevLR.rightEigenvectors() << "\n";
/*
* Set a geev object computing eigenvalues only (no eigenvectors).
*/
cla3p::LapackGeev<cla3p::dns::RdMatrix> geevEigsOnly(false, false);
geevEigsOnly.decompose(A);
std::cout << "GEEV Decomposition of A (eigenvalues only)\n";
std::cout << "------------------------------------------\n";
std::cout << "Eigenvalues:\n" << geevEigsOnly.eigenvalues() << "\n";
return 0;
}
Eigenvalue decomposition solver using LAPACK GEEV routines.
Definition lapack_geev.hpp:64
const T_CVector & eigenvalues() const
Returns the computed eigenvalues.
const T_CMatrix & rightEigenvectors() const
Returns the computed right eigenvectors.
void reserve(int_t n)
Pre-allocates internal buffers for a matrix of dimension n.
void decompose(const T_Matrix &mat)
Performs the eigenvalue decomposition of mat.
const T_CMatrix & leftEigenvectors() const
Returns the computed left eigenvectors.
static XxMatrix< real_t > random(int_t nr, int_t nc, const Property &pr=Property::General(), T_RScalar lo=T_RScalar(0), T_RScalar hi=T_RScalar(1))
XxMatrix< real_t > RdMatrix
Double precision real matrix.
Definition dense.hpp:55