|
akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
|
#include <array>#include <cmath>#include <limits>#include <optional>#include "akreon/linalg/constants.hpp"#include "vector_concepts.hpp"Go to the source code of this file.
Namespaces | |
| namespace | linalg |
Macros | |
| #define | MAX_STEP_EVAL 256 |
| Maximum Newton/refinement iterations used by constexpr utilities. | |
| #define | LINALG_HAS_CXX26_CONSTEXPR_CMATH 0 |
Whether the active standard library supports P1383R2 <cmath>. | |
| #define | LINALG_HAS_CXX26_CONSTEXPR_COMPLEX_MATH 0 |
Whether the active standard library supports P1383R2 <complex>. | |
Functions | |
| template<typename T , std::size_t N> | |
| constexpr auto | linalg::array_to_tuple (const std::array< T, N > &x) |
| Copy a fixed-size array into a tuple of the same length. | |
| template<Field T> | |
| constexpr bool | linalg::is_real (const std::complex< T > &z, real_type_t< T > tol=1e-10) |
| Check whether a complex value's imaginary component is below a bound. | |
| template<Real T> | |
| constexpr std::optional< T > | linalg::constexpr_div (T num, T den) |
| Divide two real scalars with an explicit zero-denominator result. | |
| template<Real T> | |
| constexpr T | linalg::constexpr_div_safe (T num, T den, T fallback=T(0)) |
| Divide two real scalars, returning a fallback for a zero denominator. | |
| template<Real T> | |
| constexpr T | linalg::constexpr_pow (T x, std::size_t power) |
| Raise a real scalar to a nonnegative integral power. | |
| template<Real T> | |
| constexpr std::optional< T > | linalg::constexpr_sqrt (T x, T g=1e-10, T tol=1e-10) |
| Approximate a nonnegative square root with Newton iteration. | |
| template<Real T> | |
| constexpr T | linalg::constexpr_sqrt_safe (T x, T floor=T(0), T g=1e-10, T tol=1e-10) |
| Return a scalar square root with a sanitized fallback radicand. | |
| template<Real T> | |
| constexpr T | linalg::constexpr_abs (T x) |
| Compute real absolute value or complex magnitude. | |
| template<Complex T> | |
| constexpr auto | linalg::constexpr_abs (const T &x) |
| template<Real T> | |
| constexpr std::optional< T > | linalg::constexpr_nrt (T x, std::size_t root, T g=1e-10, T tol=1e-10) |
| Approximate a real nth root with Newton iteration. | |
| template<Real T> | |
| constexpr T | linalg::constexpr_nrt_safe (T x, std::size_t root, T floor=T(0), T g=1e-10, T tol=1e-10) |
| Return a scalar nth root with a sanitized fallback radicand. | |
| template<Real T> | |
| constexpr auto | linalg::constexpr_sin (T x, int terms=16) |
| Approximate sine with a truncated Taylor recurrence. | |
| template<Real T> | |
| constexpr auto | linalg::constexpr_cos (T x, int terms=16) |
| Approximate cosine with a truncated Taylor recurrence. | |
| template<Real T> | |
| constexpr std::optional< T > | linalg::constexpr_atanh (T x, int terms=16) |
| atanh (inverse hyperbolic tangent function) | |
| template<Real T> | |
| constexpr T | linalg::constexpr_atanh_safe (T x, T fallback=T(0), int terms=16) |
| constexpr-safe atanh with fallback | |
| template<Real T> | |
| constexpr auto | linalg::constexpr_expi (T theta, int terms=16) |
Approximate exp(i * theta) on the complex unit circle. | |
| template<Real T> | |
| constexpr auto | linalg::constexpr_exp (T x, int terms=16) |
| Approximate the real exponential with a truncated power series. | |
| template<Complex T> | |
| constexpr auto | linalg::constexpr_exp_lambda (const T &lambda, int terms=16) |
| Approximate the exponential of a complex scalar. | |
| template<Real T> | |
| constexpr std::optional< T > | linalg::constexpr_ln (T x_in, int terms=16) |
| natural log | |
| template<Real T> | |
| constexpr T | linalg::constexpr_ln_safe (T x, T floor=std::numeric_limits< T >::min(), int terms=16) |
| natural log with domain sanitization and fallback | |
| template<std::size_t Start, std::size_t End, typename Func > requires (End - Start >= 0) | |
| constexpr void | linalg::constexpr_for (Func &&f) |
| constexpr for loop which recursively unrolls a dynamic for loop into compile time recursive loop | |
| template<Complex T> | |
| constexpr bool | linalg::is_same (const T &a, const T &b, real_type_t< T > tol=1e-10) |
| Compare complex scalars by magnitude of their difference. | |
| template<VectorContainer Vec> requires (Real<vector_element_t<Vec>>) | |
| constexpr auto | linalg::argsort_desc (const Vec &x) |
| Return coordinate indices sorted by descending real value. | |
| #define LINALG_HAS_CXX26_CONSTEXPR_CMATH 0 |
Whether the active standard library supports P1383R2 <cmath>.
Definition at line 28 of file algebra_util.hpp.
| #define LINALG_HAS_CXX26_CONSTEXPR_COMPLEX_MATH 0 |
Whether the active standard library supports P1383R2 <complex>.
Definition at line 36 of file algebra_util.hpp.
| #define MAX_STEP_EVAL 256 |
Maximum Newton/refinement iterations used by constexpr utilities.
The cap keeps compile-time evaluation bounded on compilers with finite constexpr step budgets.
Definition at line 22 of file algebra_util.hpp.