CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
ex10b_syev_decomposition.cpp
#include <iostream>
#include <cla3p/dense.hpp>
#include <cla3p/eigsol.hpp>
#include <cla3p/algebra.hpp>
int main()
{
/*
* Create a random 4x4 symmetric positive-definite matrix: A = B' * B.
*/
std::cout << A.info("A") << "\n" << A;
/*
* Set a simple syev object (eigenvectors are computed by default).
*/
/*
* Decompose A: compute eigenvalues and eigenvectors.
*/
syev.decompose(A);
std::cout << "SYEV Decomposition of A (eigenvalues + eigenvectors)\n";
std::cout << "----------------------------------------------------\n";
std::cout << "Eigenvalues (real, ascending):\n" << syev.eigenvalues() << "\n";
std::cout << "Eigenvectors:\n" << syev.eigenvectors() << "\n";
/*
* Set a syev object with buffer pre-allocation and eigenvalues only.
*/
syevEigsOnly.reserve(4);
syevEigsOnly.decompose(A);
std::cout << "SYEV Decomposition of A (eigenvalues only)\n";
std::cout << "------------------------------------------\n";
std::cout << "Eigenvalues (real, ascending):\n" << syevEigsOnly.eigenvalues() << "\n";
return 0;
}
Eigenvalue decomposition solver using LAPACK SYEV/HEEV routines.
Definition lapack_syev.hpp:68
const T_Matrix & eigenvectors() const
Returns the computed 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_RVector & eigenvalues() const
Returns the computed eigenvalues.
static Property SymmetricLower()
Factory method for lower-triangular symmetric property.
std::string info(const std::string &header="") const
Get information about the matrix.
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