tesseract++ 0.0.1
N-dimensional tensor library for embedded systems
Loading...
Searching...
No Matches
condition.h
Go to the documentation of this file.
1#ifndef FUSED_ALGORITHMS_CONDITION_H
2#define FUSED_ALGORITHMS_CONDITION_H
3
4#include "config.h"
6#include "matrix_traits.h"
9
42namespace matrix_algorithms
43{
44
46
56 template <typename T, my_size_t N>
58 {
59 static_assert(is_floating_point_v<T>,
60 "condition requires a floating-point scalar type");
61
62 T norm_A = norm1(A);
63
64 auto inv_result = inverse(A);
65
66 if (!inv_result.has_value())
67 {
68 return Unexpected{inv_result.error()};
69 }
70
71 T norm_Ainv = norm1(inv_result.value());
72
73 return norm_A * norm_Ainv;
74 }
75
76} // namespace matrix_algorithms
77
78#endif // FUSED_ALGORITHMS_CONDITION_H
A discriminated union holding either a success value or an error.
Definition expected.h:86
Definition fused_matrix.h:12
Global configuration for the tesseract tensor library.
A minimal, STL-free expected/result type for failable operations.
Matrix inverse with compile-time dispatch.
Runtime property descriptors and error codes for matrices.
Definition cholesky.h:52
Expected< FusedMatrix< T, N, N >, MatrixStatus > inverse(const FusedMatrix< T, N, N > &A)
Compute the inverse of a square matrix.
Definition inverse.h:65
T norm1(const FusedMatrix< T, N, N > &A)
Compute the 1-norm of a square matrix: max absolute column sum.
Definition norms.h:34
Expected< T, MatrixStatus > condition(const FusedMatrix< T, N, N > &A)
Compute the condition number of A in the 1-norm: cond₁(A) = ‖A‖₁ · ‖A⁻¹‖₁.
Definition condition.h:57
MatrixStatus
Error codes for matrix decomposition and solver algorithms.
Definition matrix_traits.h:33
Matrix and vector norms.
Tag type for constructing an Expected in the error state.
Definition expected.h:30
E error
The error value.
Definition expected.h:31