29#ifndef SPARSEMATLIS_HPP
30#define SPARSEMATLIS_HPP
32#include <lis/lislib.h>
37 LIS_SOLVER solver =
nullptr;
46 SparseMatLis(
const uword in_row,
const uword in_col,
const uword in_elem = 0)
48 lis_solver_create(&solver);
49 lis_solver_set_option(
"-i fgmres", solver);
54 lis_solver_create(&solver);
55 lis_solver_set_option(
"-i fgmres", solver);
64 unique_ptr<MetaMat<T>>
make_copy()
override {
return std::make_unique<SparseMatLis>(*
this); }
68 X.set_size(B.n_rows, B.n_cols);
78 lis_matrix_create(0, &
A);
79 lis_matrix_set_size(
A, n, 0);
81 lis_matrix_assemble(
A);
83 lis_vector_create(0, &b);
84 lis_vector_create(0, &x);
85 lis_vector_set_size(b, n, 0);
86 lis_vector_set_size(x, n, 0);
88 lis_solver_set_option(setting.lis_options.c_str(), solver);
90 for(uword I = 0; I < B.n_cols; ++I) {
92 lis_vector_set(b, (
double*)B.colptr(I));
93 lis_vector_set(x, (
double*)X.colptr(I));
96 lis_solve(
A, b, x, solver);
105 lis_matrix_destroy(
A);
106 lis_vector_destroy(b);
107 lis_vector_destroy(x);
A SparseMat class that holds matrices.
Definition: SparseMat.hpp:34
A SparseMatLis class that holds matrices.
Definition: SparseMatLis.hpp:36
SparseMatLis(const SparseMatLis &other)
Definition: SparseMatLis.hpp:52
SparseMatLis(SparseMatLis &&) noexcept=delete
unique_ptr< MetaMat< T > > make_copy() override
Definition: SparseMatLis.hpp:64
SparseMatLis(const uword in_row, const uword in_col, const uword in_elem=0)
Definition: SparseMatLis.hpp:46
Definition: suanPan.h:331
constexpr auto SUANPAN_SUCCESS
Definition: suanPan.h:172