10namespace uni20::linalg::detail
13template <
class Matrix>
bool solve_matrix_is_finite(Matrix
const& matrix)
15 using scalar_type =
typename Matrix::value_type;
16 for (
typename Matrix::index_type
row = 0;
row < matrix.extent(0); ++
row)
17 for (
typename Matrix::index_type col = 0; col < matrix.extent(1); ++col)
22template <uni20::Real Real>
void require_solve_options(SolveOptions<Real>
const& options)
25 "solve requires a finite nonnegative relative pivot tolerance");
30template <
class Matrix,
class Rhs,
class Real>
31bool prepare_linear_solve(Matrix
const& coefficients, Rhs
const& rhs, Real& scale, SolveInfo& info)
34 if (!solve_matrix_is_finite(coefficients) || !solve_matrix_is_finite(rhs))
40 using scalar_type =
typename Matrix::value_type;
41 for (
typename Matrix::index_type
row = 0;
row < coefficients.extent(0); ++
row)
42 for (
typename Matrix::index_type col = 0; col < coefficients.extent(1); ++col)
56bool check_solve_pivot(Real magnitude, Real scale, SolveOptions<Real>
const& options, std::size_t column,
61 else if (magnitude == Real{})
63 else if (options.relative_pivot_tolerance > Real{} && magnitude / scale <= options.relative_pivot_tolerance)
65 return info.succeeded();
constexpr bool isfinite(I const &x) noexcept
Returns whether an integer scalar is finite.
Definition math.hpp:121
Scalar math helper utilities.
void info(checked_format_string< Args... > format, Args &&... args)
Emit an informational display message.
Definition display.hpp:393
DiagnosticMagnitude< R > magnitude(R const &value)
Definition gmres_diagnostics.hpp:98
@ nonfinite_input
An input coefficient or RHS component was nonfinite; both workspaces are preserved.
@ singular
An exactly zero elimination pivot was found.
@ nonfinite_result
A factor, solution, reduction, or required magnitude became nonfinite.
@ small_pivot
A nonzero pivot failed the requested relative threshold.
constexpr auto abs(basic_half_int< T > value) -> basic_half_int< T >
Return the absolute value of a half-integer.
Definition half_int.hpp:431
#define ERROR_IF(cond,...)
Definition trace.hpp:389