Solver for general full symmetric positive definite matrices.
It solves the system of linear equations A * X = B with a full symmetric positive definite matrix A. The matrix A is stored in a N x N block. The matrix B is stored in a N x NRHS block.
The example usage can be seen as follows.
#include <iomanip>
#include <iostream>
using namespace ezp;
public:
int_t n_rows, n_cols;
private:
std::vector<double> storage;
public:
mat(
const int_t rows,
const int cols)
: n_rows(rows)
, n_cols(cols) {}
auto init() { storage.resize(n_rows * n_cols); }
auto& operator()(const int_t i, const int_t j) { return storage[i + j * n_cols]; }
auto& operator[](const int_t i) { return storage[i]; }
auto begin() { return storage.begin(); }
auto end() { return storage.end(); }
};
int main() {
const auto& env = get_env<>();
constexpr auto N = 6, NRHS = 2;
if(0 == env.rank()) {
A.init();
B.init();
for(auto I = 0; I < N; ++I) {
B[I] = A(I, I) = I + 1;
B[I + N] = I + 4;
}
}
const auto info = par_dposv<int_t>().solve(A, B);
if(0 == env.rank() && 0 == info) {
std::cout << std::setprecision(10) << "Info: " << info << '\n';
std::cout << "Solution:\n";
for(const auto i : B) std::cout << i << '\n';
}
return info;
}
Definition: example.pposv.cpp:33
- Author
- tlc
- Date
- 07/03/2025
- Version
- 1.0.0