akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
scalar_traits.hpp
Go to the documentation of this file.
1/*
2 * Copyright © 2025-2026 Akreon LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#pragma once
7
8#include <complex>
9#include <type_traits>
10
11namespace linalg {
12
19template <typename T>
20using remove_cvref_t = std::remove_cvref_t<T>;
21
36template <typename T>
38
40template <std::floating_point T>
41struct scalar_traits<T> {
43 using scalar_type = T;
45 using real_type = T;
46
48 static constexpr bool is_real = true;
50 static constexpr bool is_complex = false;
51};
52
54template <std::floating_point T>
55struct scalar_traits<std::complex<T>> {
57 using scalar_type = std::complex<T>;
59 using real_type = T;
60
62 static constexpr bool is_real = false;
64 static constexpr bool is_complex = true;
65};
66
68template <typename T>
70
72template <typename T>
74
81template <typename T>
83
85template <typename T>
86inline constexpr bool is_real_v = scalar_traits_t<T>::is_real;
87
89template <typename T>
91
92} // namespace linalg
std::remove_cvref_t< T > remove_cvref_t
Remove top-level const, volatile, and reference qualification.
typename scalar_traits_t< T >::real_type real_type_t
Associated real component type registered for T.
constexpr bool is_real_v
Whether normalized T is registered as a real scalar.
constexpr bool is_complex_v
Whether normalized T is registered as a complex scalar.
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
constexpr bool 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.
typename scalar_traits_t< T >::scalar_type scalar_type_t
Normalized scalar representation registered for T.
T scalar_type
Normalized scalar representation.
T real_type
Associated real component type.
T real_type
Floating-point component type underlying the complex scalar.
std::complex< T > scalar_type
Normalized complex scalar representation.
Customization point for scalar metadata.