|
consteig
Compile-time eigenvalue and eigenvector computation for C++17
|
Constexpr mathematical functions with no standard library dependency. More...
Functions | |
| template<typename T > | |
| constexpr T | consteig::abs (const T x) |
| Absolute value of a real number. | |
| template<typename T > | |
| constexpr Complex< T > | consteig::csqrt (const T x) |
| Complex-valued square root of a real number. | |
| template<typename T > | |
| constexpr auto | consteig::exp (const T x) noexcept |
| Computes the exponential of a real number. | |
| template<typename T > | |
| constexpr T | consteig::pow (const T x, const unsigned int n) |
Raise x to an unsigned integer power via exponentiation by squaring. | |
| template<typename T > | |
| constexpr T | consteig::pow (const T x, const int n) |
Raise x to a signed integer power. | |
| template<typename T > | |
| constexpr T | consteig::sgn (const T x) |
| Signum function: returns +1, -1, or 0. | |
| template<typename T > | |
| constexpr T | consteig::sqrt (const T x) |
| Constexpr square root. | |
| template<typename T > | |
| constexpr auto | consteig::sin (const T x) noexcept |
| Computes the sine of x (in radians). | |
| template<typename T > | |
| constexpr auto | consteig::cos (const T x) noexcept |
| Computes the cosine of x (in radians). | |
| template<typename T > | |
| constexpr auto | consteig::tan (const T x) noexcept |
| Computes the tangent of x (in radians) as sin_series(r) / cos_series(r), where r = trig_reduce(x). | |
| template<typename T > | |
| constexpr bool | consteig::is_float (T const &) |
Returns true if T is a floating-point type (value overload). | |
| template<typename T > | |
| constexpr bool | consteig::is_float () |
Returns true if T is a floating-point type (type-only overload). | |
| template<typename T > | |
| constexpr T | consteig::epsilon () |
Machine epsilon for type T. | |
Constexpr mathematical functions with no standard library dependency.
Absolute value of a real number.
Returns |x|. Handles signed zero correctly (returns positive zero).
| T | Numeric type. |
| x | Input value. |
x. Complex-valued square root of a real number.
For non-negative x, returns {sqrt(x), 0}. For negative x, returns {0, sqrt(|x|)} (purely imaginary result). Use this instead of sqrt when the input may be negative.
| T | Numeric type. |
| x | Input value (may be negative). |
Raise x to an unsigned integer power via exponentiation by squaring.
| T | Numeric type. |
| x | Base value. |
| n | Non-negative exponent. |
x^n. Raise x to a signed integer power.
Negative exponents compute 1 / x^|n|.
| T | Numeric type. |
| x | Base value. |
| n | Integer exponent (may be negative). |
x^n. Signum function: returns +1, -1, or 0.
| T | Numeric type. |
| x | Input value. |
+1 if x > 0, -1 if x < 0, 0 if x == 0. Constexpr square root.
For floating-point types, uses Newton's method with range reduction. For integer types, returns the floor of the exact square root. Negative inputs produce a poison value (compile-time error in constexpr context); use csqrt if the input may be negative.
| T | Numeric type. |
| x | Non-negative input value. |
x. Computes the tangent of x (in radians) as sin_series(r) / cos_series(r), where r = trig_reduce(x).
NOTE: tan has singularities where cos_series(r) == 0 (x = pi/2 + k*pi for integer k). Near these points the result can be very large, +/-infinity, or NaN. This function does not clamp or guard against those cases.
Returns true if T is a floating-point type (value overload).
| T | Type to test. |
Returns true if T is a floating-point type (type-only overload).
Recognized floating-point types: float, double, long double. All other types (including integer types) return false.
| T | Type to test. |
|
constexpr |
Machine epsilon for type T.
Returns the smallest value eps such that 1 + eps != 1 in type T. Hardcoded for float and double to IEEE 754 values for O(1) constexpr performance. Falls back to iterative computation for long double and other types.
For non-floating-point types, returns T(0).
| T | Numeric type. |
T(0) for integer types.