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. Use the call operator to set the parameters iparm for the solver.
The example usage can be seen as follows.
#include <iomanip>
#include <iostream>
int main() {
#ifdef EZP_MKL
const auto& comm_world{mpl::environment::comm_world()};
auto solver = ezp::pardiso<double, int_t>(ezp::matrix_type::real_and_nonsymmetric, ezp::message_level::no_output);
int N = 10, NRHS = 1;
std::vector<int_t> ia, ja;
std::vector<double> a, b;
const auto populate = [&] {
if(0 != comm_world.rank()) return;
ia.resize(N + 1);
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;
ia[N] = N + 1;
std::ranges::fill(b, 1.);
};
populate();
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 << "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;
#else
std::cerr << "MKL not enabled.\n";
return 0;
#endif
}
- Author
- tlc
- Date
- 23/03/2025
- Version
- 1.0.0