Solver for general full matrices.
It solves the system of linear equations A * X = B with a full general 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;
int main() {
const auto& env = get_env<int_t>();
constexpr auto N = 6, NRHS = 2;
std::vector<double> A, B;
const auto IDX = par_dgesv<int_t>::indexer{N};
if(0 == env.rank()) {
A.resize(N * N, 0.);
B.resize(N * NRHS);
static constexpr auto M = 5.10156648;
for(auto I = 0; I < N; ++I) {
B[I] = A[IDX(I, I)] = I + 1;
B[I + N] = (I + 1) * M;
}
}
auto solver = par_dgesv<int_t>();
const auto info = solver.solve({N, N, A.data()}, {N, NRHS, B.data()});
const auto det = solver.det({N, N, A.data()});
if(0 == env.rank() && 0 == info) {
std::cout << std::setprecision(10) << "Info: " << info << '\n';
std::cout << "Determinant: " << det << '\n';
std::cout << "Solution:\n";
for(const double i : B) std::cout << i << '\n';
}
return info;
}
- Author
- tlc
- Date
- 07/03/2025
- Version
- 1.0.0