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 std::uint64_t in_elem)
144 this->
at(K,
K) = T(1);
150 for(
const auto index : list)
unify(index);
154 for(
const auto index : list)
nullify(index);
157 [[nodiscard]]
virtual T
max()
const = 0;
168 virtual T&
unsafe_at(
const uword I,
const uword J) {
return this->
at(I, J); }
174 virtual T&
at(uword, uword) = 0;
176 [[nodiscard]]
virtual const T*
memptr()
const = 0;
187 const auto& bracket =
M.bracket;
188 if(
nullptr != bracket.mat_a) this->
scale_accu(M.scalar, bracket.mat_a);
189 if(
nullptr != bracket.mat_b) this->
scale_accu(M.scalar, bracket.mat_b);
193 const auto& bracket =
M.bracket;
194 if(
nullptr != bracket.mat_a) this->
scale_accu(-M.scalar, bracket.mat_a);
195 if(
nullptr != bracket.mat_b) this->
scale_accu(-M.scalar, bracket.mat_b);
213 if(
SUANPAN_SUCCESS != this->
solve(X, std::forward<C>(B)))
throw std::runtime_error(
"fail to solve the system");
218 [[nodiscard]]
virtual int sign_det()
const {
throw std::runtime_error(
"not supported"); }
233 for(uword J{0}; J < in_mat.
n_cols; ++J)
234 for(uword I{0}; I < in_mat.
n_rows; ++I) out_mat(I, J) = in_mat(I, J);
241 Mat<data_t> out_mat(in_mat.
n_rows, in_mat.
n_cols, fill::zeros);
242 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);
247 Mat<data_t> out_mat(in_mat.
n_rows, in_mat.
n_cols, fill::zeros);
250 for(index_t I = 0; I < in_mat.
n_elem; ++I) {
251 if(I >= in_mat.
row_mem()[c_idx]) ++c_idx;
259 Mat<data_t> out_mat(in_mat.
n_rows, in_mat.
n_cols, fill::zeros);
262 for(index_t I = 0; I < in_mat.
n_elem; ++I) {
263 if(I >= in_mat.
col_mem()[c_idx]) ++c_idx;
273 const sp_i auto n_rows = index_t(in_mat->
n_rows);
274 const sp_i auto n_cols = index_t(in_mat->
n_cols);
275 const sp_i auto n_elem = index_t(in_mat->
n_elem);
278 for(index_t J = 0; J < n_cols; ++J)
279 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:347
constexpr auto SUANPAN_SUCCESS
Definition suanPan.h:166
#define suanpan_error(...)
Definition suanPan.h:349