Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
ops/lu_rcond.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace uni20::linalg
7{
12template <Real R> struct LuConditionResult
13{
16 std::optional<R> estimate = {};
17};
18
25template <KernelBackendSelector Backend, RealOrComplex S>
26[[nodiscard]] auto lu_rcond_with_info(Backend&& backend, LuFactorization<S> const& factor, MatrixNorm norm,
27 make_real_t<S> const& original_norm)
28{
31 auto a = mdspec_of(factor.packed());
33 detail::dispatch_at_precision<S>(std::forward<Backend>(backend), lu_rcond_op{norm}, factor.precision(), value, a,
34 original_norm, result.info);
35 if (result.info.succeeded()) result.estimate = std::move(value);
36 return result;
37}
38
40template <KernelBackendSelector Backend, RealOrComplex S>
41[[nodiscard]] auto lu_rcond_with_info(Backend&& backend, LuFactorization<S> const& factor,
43{
45 ERROR_IF(!factor.norms(), "LU norms were not retained; supply the original norm explicitly");
46 return lu_rcond_with_info(std::forward<Backend>(backend), factor, norm,
47 norm == MatrixNorm::One ? factor.norms()->one : factor.norms()->infinity);
48}
49
51template <RealOrComplex S>
52[[nodiscard]] auto lu_rcond_with_info(LuFactorization<S> const& factor, MatrixNorm norm,
53 make_real_t<S> const& original_norm)
54{
56}
57
59template <RealOrComplex S>
64
66template <class... Args>
67 requires requires(Args&&... args) { lu_rcond_with_info(std::forward<Args>(args)...); }
68[[nodiscard]] auto lu_rcond(Args&&... args)
69{
70 auto result = lu_rcond_with_info(std::forward<Args>(args)...);
71 detail::require_lu_success(result.info);
72 return std::move(*result.estimate);
73}
74} // namespace uni20::linalg
General-purpose owning tensor with immediate or deferred mdspan metadata.
Definition basic_tensor.hpp:109
Immutable owning packed factors satisfying P A = L U.
Definition ops/lu.hpp:34
std::optional< LuNorms< make_real_t< S > > > const & norms() const &noexcept
Original norms at factor precision, absent only when capture was disabled.
Definition ops/lu.hpp:46
Precision precision() const
Finite working precision used for these factors and subsequent solves.
Definition ops/lu.hpp:44
DenseMatrix< S > const & packed() const &noexcept
Read-only packed L/U matrix, valid while this object retains its storage.
Definition ops/lu.hpp:40
locale_t value
Definition data_table.cpp:49
typename make_real< T >::type make_real_t
Alias for the underlying real-valued type of T.
Definition scalar_traits.hpp:168
char norm_code(MatrixNorm norm)
Definition backends/lapack/lu_rcond.hpp:31
Definition linalg/async.hpp:28
auto lu_rcond_with_info(Backend &&backend, LuFactorization< S > const &factor, MatrixNorm norm, make_real_t< S > const &original_norm)
Estimate conditioning using an explicitly supplied original matrix norm.
Definition ops/lu_rcond.hpp:26
constexpr auto select_backend_for(Operation const &operation)
Resolve the immutable backend selector for Tensor operand types.
Definition backend_selector.hpp:201
MatrixNorm
Matrix norm selected by matrix_norm_op.
Definition operation_tags.hpp:119
@ One
Induced one-norm: largest column sum of entry magnitudes.
auto lu_rcond(Args &&... args)
Return the reciprocal condition estimate; numerical failure uses the terminal error policy.
Definition ops/lu_rcond.hpp:68
mpreal norm(mpcomplex const &z)
Definition mpcomplex.hpp:494
constexpr decltype(auto) mdspec_of(Tensor &tensor) noexcept(noexcept(tensor.mdspec()))
Return a tensor's immediate or descriptor-backed multidimensional metadata.
Definition tensor/concepts.hpp:50
Owning reusable host LU factors and solves through operation dispatch.
Reciprocal condition estimate, present only on numerical success.
Definition ops/lu_rcond.hpp:13
SolveInfo info
Definition ops/lu_rcond.hpp:14
std::optional< R > estimate
Definition ops/lu_rcond.hpp:16
MatrixNorm norm
Definition ops/lu_rcond.hpp:15
Diagnostics written by a completed numerical attempt, independent of dispatch.
Definition solve_info.hpp:41
Reciprocal condition estimate from successful packed LU and an original matrix norm.
Definition operation_tags.hpp:142
#define ERROR_IF(cond,...)
Definition trace.hpp:389