Solver for general sparse matrices.
It solves the system of linear equations A * X = B with a general sparse matrix A. The RHS matrix B is a dense matrix.
The matrix A should be stored in the Compressed Sparse Row (CSR) format with one-based indexing.
To set control parameters, use the overloaded function call operator, which allows access to the icntl array.
solver(3) = 0;
solver.icntl_printing_level(0);
Solver for general sparse matrices.
The example usage can be seen as follows.
#include <iomanip>
#include <iostream>
using namespace ezp;
int main() {
const auto& comm_world{mpl::environment::comm_world()};
int N = 10, NRHS = 1;
std::vector<int> ia, ja;
std::vector<double> a, b;
const auto populate = [&] {
if(0 != comm_world.rank()) return;
ia.resize(N);
ja.resize(N);
a.resize(N);
b.resize(N * NRHS);
for(auto i = 0; i < N; i++) ia[i] = ja[i] = a[i] = i + 1;
std::fill(b.begin(), b.end(), 1.);
};
populate();
solver.icntl_printing_level(0);
solver.icntl_determinant_computation(1);
auto info = solver.solve({N, N, ia.data(), ja.data(), a.data()}, {N, NRHS, b.data()});
const auto print = [&] {
if(0 != comm_world.rank()) return;
std::cout << std::fixed << std::setprecision(10) << "Info: " << info << '\n';
std::cout << "sign(det()): " << solver.sign_det() << '\n';
std::cout << "Solution:\n";
for(const double i : b) std::cout << i << '\n';
};
print();
N = 20;
populate();
info = solver.solve({N, N, ia.data(), ja.data(), a.data()}, {N, NRHS, b.data()});
print();
return info;
}
- Author
- tlc
- Date
- 23/03/2025
- Version
- 1.0.0