CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
ex05b_solving_linear_systems_ldlt.cpp
#include <iostream>
#include <cla3p/dense.hpp>
#include <cla3p/linsol.hpp>
#include <cla3p/algebra.hpp>
int main()
{
/*
* Create a random symmetric matrix.
*/
/*
* Create random right hand sides.
*/
/*
* Decompose A into LDL' product.
*/
ldltSolver.decompose(A);
{
/*
* Single column (vector) rhs.
* Overwrite X with the solution (A^{-1} * b).
*/
ldltSolver.solve(x);
std::cout << "Dense Vector rhs::Absolute Error: "
<< (b - A * x).evaluate().normOne() << std::endl;
}
{
/*
* Multiple column (matrix) rhs.
* Overwrite X with the solution (A^{-1} * B).
*/
ldltSolver.solve(X);
std::cout << "Dense Matrix rhs::Absolute Error: "
<< (B - A * X).evaluate().normOne() << std::endl;
}
return 0;
}
void solve(T_Matrix &rhs) const
Performs in-place matrix solution.
void decompose(const T_Matrix &mat)
Performs matrix decomposition.
The indefinite Cholesky (LDL') linear solver for dense matrices.
Definition lapack_ldlt.hpp:39
The property class.
Definition property.hpp:42
static Property SymmetricLower()
Factory method for lower-triangular symmetric property.
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))
static XxVector< real_t > random(int_t n, T_RScalar lo=T_RScalar(0), T_RScalar hi=T_RScalar(1))
XxMatrix< real_t > RdMatrix
Double precision real matrix.
Definition dense.hpp:55
XxVector< real_t > RdVector
Double precision real vector.
Definition dense.hpp:31