Scalar helper utilities shared across Uni20 core algorithms.
More...
|
| template<typename Real > |
| using | uni20::complex = typename detail::complex_type< Real >::type |
| | Project-level complex scalar spelling.
|
| |
| template<typename T > |
| using | uni20::make_complex_t = typename make_complex< T >::type |
| | Alias for the complexified version of T.
|
| |
| template<typename T > |
| using | uni20::make_real_t = typename make_real< T >::type |
| | Alias for the underlying real-valued type of T.
|
| |
|
| template<typename T > |
| uni20::complex< T > | uni20::conj (detail::standard_complex< T > x) |
| | Returns the complex conjugate for complex-valued scalars.
|
| |
| template<Integer I> |
| constexpr I | uni20::conj (I const &x) |
| | Returns the conjugate of an integer scalar.
|
| |
| template<Real R> |
| constexpr R | uni20::conj (R const &x) |
| | Returns the conjugate of a real-valued scalar.
|
| |
| template<Complex T> |
| std::string | uni20::format_complex (T const &value, scalar_format_options const &options={}) |
| | Format a Uni20 complex scalar as real+imagi.
|
| |
| template<Real T> |
| std::string | uni20::format_real (T value, scalar_format_options const &options={}) |
| | Format a Uni20 real scalar.
|
| |
| template<RealOrComplex T> |
| std::string | uni20::format_scalar (T const &value, scalar_format_options const &options={}) |
| | Format any Uni20 real or complex scalar.
|
| |
| template<Scalar S> |
| constexpr auto | uni20::herm (S x) |
| | Computes the Hermitian adjoint of a scalar value.
|
| |
| template<typename T > |
| constexpr T & | uni20::imag (detail::standard_complex< T > &z) noexcept |
| | Provides mutable access to the imaginary component of a uni20::complex value.
|
| |
| template<Complex C> |
| constexpr bool | uni20::isfinite (C const &z) |
| | Returns whether both components of a complex scalar are finite.
|
| |
| template<Integer I> |
| constexpr bool | uni20::isfinite (I const &x) noexcept |
| | Returns whether an integer scalar is finite.
|
| |
| template<Real R> |
| constexpr bool | uni20::isfinite (R const &x) |
| | Returns whether a real scalar is neither NaN nor positive/negative infinity.
|
| |
| template<Real T> |
| T | uni20::parse_real (std::string_view text) |
| | Parse a Uni20 real scalar from text.
|
| |
| template<Real T> |
| std::istream & | uni20::read_real (std::istream &stream, T &value) |
| | Read a Uni20 real scalar from a stream token.
|
| |
| template<typename T > |
| constexpr T & | uni20::real (detail::standard_complex< T > &z) noexcept |
| | Provides mutable access to the real component of a uni20::complex value.
|
| |
Scalar helper utilities shared across Uni20 core algorithms.
◆ complex
template<typename Real >
| using uni20::complex = typedef typename detail::complex_type<Real>::type |
Project-level complex scalar spelling.
Native real types retain std::complex identity and ABI. With MPC enabled, mpreal selects the owning MPC scalar. Generic functions should deduce the complex value type directly rather than deducing through this alias.
- Template Parameters
-
| Real | Underlying real scalar type. |
◆ make_complex_t
Alias for the complexified version of T.
- Template Parameters
-
◆ make_real_t
Alias for the underlying real-valued type of T.
- Template Parameters
-
◆ real_format_notation
Selects how real scalar values are rendered as text.
| Enumerator |
|---|
| general | |
| fixed | |
| scientific | |
◆ conj() [1/3]
Returns the complex conjugate for complex-valued scalars.
This overload forwards to std::conj and therefore returns a uni20::complex<T> copy of the input value. It inherits the constexpr availability of std::conj (currently not constexpr).
- Template Parameters
-
| T | Component type of the complex scalar. |
- Parameters
-
| x | Complex value whose conjugate is requested. |
- Returns
- The complex conjugate of
x.
◆ conj() [2/3]
template<Integer I>
| constexpr I uni20::conj |
( |
I const & |
x | ) |
|
|
constexpr |
Returns the conjugate of an integer scalar.
Integer values are treated as reals for conjugation and therefore returned unchanged. The overload is constexpr, enabling compile-time evaluation for literal arguments.
- Template Parameters
-
- Parameters
-
| x | Integer scalar to return. |
- Returns
x, unchanged.
◆ conj() [3/3]
template<Real R>
| constexpr R uni20::conj |
( |
R const & |
x | ) |
|
|
constexpr |
Returns the conjugate of a real-valued scalar.
Real numbers are unchanged by conjugation, so the value is returned verbatim. The overload is constexpr, enabling compile-time evaluation for literal arguments.
- Template Parameters
-
- Parameters
-
- Returns
x, unchanged.
◆ format_complex()
Format a Uni20 complex scalar as real+imagi.
- Template Parameters
-
- Parameters
-
| value | Value to format. |
| options | Text formatting options. |
- Returns
- Formatted scalar text.
◆ format_real()
Format a Uni20 real scalar.
- Template Parameters
-
- Parameters
-
| value | Value to format. |
| options | Text formatting options. |
- Returns
- Formatted scalar text.
◆ format_scalar()
template<RealOrComplex T>
Format any Uni20 real or complex scalar.
- Template Parameters
-
| T | Real or complex scalar type. |
- Parameters
-
| value | Value to format. |
| options | Text formatting options. |
- Returns
- Formatted scalar text.
◆ herm()
template<Scalar S>
| constexpr auto uni20::herm |
( |
S |
x | ) |
|
|
constexpr |
Computes the Hermitian adjoint of a scalar value.
For scalar inputs the Hermitian adjoint is equivalent to the complex conjugate, so this helper simply forwards to conj. When the selected conj overload is constexpr, this helper is as well, preserving compile-time evaluation.
- Template Parameters
-
| S | Scalar type satisfying Scalar. |
- Parameters
-
| x | Scalar value whose Hermitian adjoint is requested. |
- Returns
- The result of calling
conj(x).
◆ imag()
template<typename T >
| constexpr T & uni20::imag |
( |
detail::standard_complex< T > & |
z | ) |
|
|
constexprnoexcept |
Provides mutable access to the imaginary component of a uni20::complex value.
This helper mirrors the std::imag overload for lvalues while remaining constexpr and noexcept for direct reference access.
- Template Parameters
-
| T | Component type of the complex scalar. |
- Parameters
-
| z | Complex number whose imaginary component will be exposed. |
- Returns
- Reference to the imaginary component of
z.
◆ isfinite() [1/3]
template<Complex C>
| constexpr bool uni20::isfinite |
( |
C const & |
z | ) |
|
|
constexpr |
Returns whether both components of a complex scalar are finite.
- Template Parameters
-
- Parameters
-
| z | Complex scalar to inspect. |
- Returns
true when both the real and imaginary components are finite.
◆ isfinite() [2/3]
template<Integer I>
| constexpr bool uni20::isfinite |
( |
I const & |
x | ) |
|
|
constexprnoexcept |
Returns whether an integer scalar is finite.
Integer Uni20 scalars have no NaN or infinity representation, so every value is finite.
- Template Parameters
-
- Parameters
-
| x | Integer scalar to inspect. |
- Returns
- Always
true.
◆ isfinite() [3/3]
template<Real R>
| constexpr bool uni20::isfinite |
( |
R const & |
x | ) |
|
|
constexpr |
Returns whether a real scalar is neither NaN nor positive/negative infinity.
This uses uni20::numeric_limits<T> so extension real scalar types can define their own infinity representation without depending on standard-library overload coverage for std::isfinite. Runtime-precision mpreal uses its native classification instead of type-only limits.
- Template Parameters
-
- Parameters
-
- Returns
true when x is finite.
◆ parse_real()
template<Real T>
| T uni20::parse_real |
( |
std::string_view |
text | ) |
|
Parse a Uni20 real scalar from text.
- Template Parameters
-
- Parameters
-
| text | Text containing one complete real literal. |
- Returns
- Parsed value.
- Exceptions
-
| std::invalid_argument | if the text is not a complete real literal. |
| std::out_of_range | if the literal overflows or underflows the target type. |
◆ read_real()
template<Real T>
| std::istream & uni20::read_real |
( |
std::istream & |
stream, |
|
|
T & |
value |
|
) |
| |
Read a Uni20 real scalar from a stream token.
This helper exists because extension real aliases such as uni20::float128 cannot portably receive ordinary overloaded stream extraction operators. For mpreal, parsing retains the destination's working precision; invalid input leaves its value unchanged.
- Template Parameters
-
- Parameters
-
| stream | Input stream. |
| value | Destination value. |
- Returns
- The input stream.
◆ real()
template<typename T >
| constexpr T & uni20::real |
( |
detail::standard_complex< T > & |
z | ) |
|
|
constexprnoexcept |
Provides mutable access to the real component of a uni20::complex value.
This helper mirrors the std::real overload for lvalues while remaining constexpr and noexcept for direct reference access.
- Template Parameters
-
| T | Component type of the complex scalar. |
- Parameters
-
| z | Complex number whose real component will be exposed. |
- Returns
- Reference to the real component of
z.
◆ has_numeric_limits_v
template<typename T >
| constexpr bool uni20::has_numeric_limits_v |
|
inlineconstexpr |
Initial value:=
requires { requires numeric_limits<std::remove_cvref_t<T>>::is_specialized; }
True when Uni20 has numeric limits for T.
Runtime-precision specializations require a value or precision for precision-dependent queries; this trait does not promise static limits.
- Template Parameters
-
◆ has_trivial_conj
template<typename T >
| constexpr bool uni20::has_trivial_conj = Real<T> || Integer<T> |
|
inlineconstexpr |
Indicates whether the Uni20 conjugation helper is a no-op for the provided scalar type.
Evaluates to true when the scalar is already real-valued or integral, allowing callers to skip complex conjugation work. The variable template is constexpr, so the result may be used in constant-expression contexts.
- Template Parameters
-
◆ is_complex_scalar_valued_v
Trait to detect whether T is scalar-valued with a complex scalar.
- Template Parameters
-
◆ is_complex_v
Convenience alias that exposes the value of is_complex_t.
- Template Parameters
-
◆ is_integer_scalar_valued_v
Trait to detect whether T is scalar-valued with an integer scalar.
- Template Parameters
-
◆ is_integer_v
Convenience alias that exposes the value of is_integer_t.
- Template Parameters
-
◆ is_real_or_complex_scalar_valued_v
Trait to detect whether T is scalar-valued with a real or complex scalar.
- Template Parameters
-
◆ is_real_or_complex_v
Trait to detect whether a type is a real or complex scalar.
- Template Parameters
-
◆ is_real_scalar_valued_v
Trait to detect whether T is scalar-valued with a real scalar.
- Template Parameters
-
◆ is_real_v
Convenience alias that exposes the value of is_real_t.
- Template Parameters
-
◆ is_scalar_v
Trait to detect whether a type is a numeric scalar (real, complex, or integer).
- Template Parameters
-
◆ is_scalar_valued_v
template<typename T >
| constexpr bool uni20::is_scalar_valued_v = !std::same_as<scalar_t<T>, void> |
|
inlineconstexpr |
Trait to detect whether T is scalar-valued.
A scalar-valued type is either a scalar itself or a type whose recursive value_type chain resolves to a Uni20 scalar. Use is_scalar_v<T> when constraining a type that must be the scalar value itself.
- Template Parameters
-