35#ifdef SUANSPAN_64BIT_INT
36using la_it = std::int64_t;
46 shared_ptr<MetaMat<T>> mat_a, mat_b;
71 , bracket(std::move(B)) {}
88 template<std::invocable<fmat&> F>
int mixed_trs(mat& X, mat&& B, F&& trs) {
91 X = arma::zeros(size(B));
93 std::uint8_t counter{0};
95 const auto multiplier = norm(B);
97 suanpan_debug(
"Mixed precision algorithm multiplier: {:.5E}.\n", multiplier);
99 auto residual = conv_to<fmat>::from(B / multiplier);
101 if(0 != (INFO = trs(residual)))
break;
103 const mat incre = multiplier * conv_to<mat>::from(residual);
119 MetaMat(
const uword in_rows,
const uword in_cols,
const uword in_elem)
144 this->
at(K,
K) =
T(1);
149 [[nodiscard]]
virtual T max()
const = 0;
160 virtual T&
unsafe_at(
const uword I,
const uword J) {
return this->
at(I, J); }
166 virtual T&
at(uword, uword) = 0;
168 [[nodiscard]]
virtual const T*
memptr()
const = 0;
179 const auto& bracket =
M.bracket;
180 if(
nullptr != bracket.mat_a) this->
scale_accu(M.scalar, bracket.mat_a);
181 if(
nullptr != bracket.mat_b) this->
scale_accu(M.scalar, bracket.mat_b);
185 const auto& bracket =
M.bracket;
186 if(
nullptr != bracket.mat_a) this->
scale_accu(-M.scalar, bracket.mat_a);
187 if(
nullptr != bracket.mat_b) this->
scale_accu(-M.scalar, bracket.mat_b);
205 if(
SUANPAN_SUCCESS != this->
solve(X, std::forward<C>(B)))
throw std::runtime_error(
"fail to solve the system");
210 [[nodiscard]]
virtual int sign_det()
const {
throw std::runtime_error(
"not supported"); }
215 if(!
to_mat(*this).save(name, raw_ascii))
226 for(uword J = 0; J < in_mat.
n_cols; ++J)
227 for(uword I = 0; I < in_mat.
n_rows; ++I) out_mat(I, J) = in_mat(I, J);
234 Mat<data_t> out_mat(in_mat.
n_rows, in_mat.
n_cols, fill::zeros);
235 for(index_t I = 0; I < in_mat.
n_elem; ++I) out_mat(in_mat.
row(I), in_mat.
col(I)) += in_mat.
val(I);
240 Mat<data_t> out_mat(in_mat.
n_rows, in_mat.
n_cols, fill::zeros);
243 for(index_t I = 0; I < in_mat.
n_elem; ++I) {
244 if(I >= in_mat.
row_mem()[c_idx]) ++c_idx;
252 Mat<data_t> out_mat(in_mat.
n_rows, in_mat.
n_cols, fill::zeros);
255 for(index_t I = 0; I < in_mat.
n_elem; ++I) {
256 if(I >= in_mat.
col_mem()[c_idx]) ++c_idx;
266 const sp_i auto n_rows = index_t(in_mat->
n_rows);
267 const sp_i auto n_cols = index_t(in_mat->
n_cols);
268 const sp_i auto n_elem = index_t(in_mat->
n_elem);
271 for(index_t J = 0; J < n_cols; ++J)
272 for(index_t I = 0; I < n_rows; ++I) out_mat.
at(I, J) = in_mat->operator()(I, J);
Definition MetaMat.hpp:43
op_add(const shared_ptr< MetaMat< T > > &A, const shared_ptr< MetaMat< T > > &B)
Definition MetaMat.hpp:53
op_add(const shared_ptr< MetaMat< T > > &A)
Definition MetaMat.hpp:49
Definition MetaMat.hpp:58
op_scale(const T A, const shared_ptr< MetaMat< T > > &B)
Definition MetaMat.hpp:65
op_scale(const T A, op_add< T > &&B)
Definition MetaMat.hpp:69
Definition SolverSetting.hpp:28
data_t tolerance
Definition SolverSetting.hpp:30
std::uint8_t iterative_refinement
Definition SolverSetting.hpp:31
#define suanpan_debug(...)
Definition suanPan.h:374
constexpr auto SUANPAN_SUCCESS
Definition suanPan.h:180
#define suanpan_error(...)
Definition suanPan.h:376