11#ifndef TLAPACK_UTILS_HH
12#define TLAPACK_UTILS_HH
25#ifdef TLAPACK_USE_LAPACKPP
32using std::enable_if_t;
53constexpr T square(
const T& x)
70template <
typename T, enable_if_t<is_real<T>,
int> = 0>
85template <
typename T, enable_if_t<is_real<T>,
int> = 0>
99template <
typename T, enable_if_t<is_real<T>,
int> = 0>
100constexpr T
conj(
const T&
x)
noexcept
108template <
typename T, enable_if_t<is_real<T>,
int> = 0>
111 return (T(0) <
val) - (
val < T(0));
116template <
typename T, enable_if_t<is_complex<T>,
int> = 0>
124template <
typename T, enable_if_t<is_complex<T>,
int> = 0>
143 template <
class T,
typename =
int>
150 int>> : std::true_type {};
152 template <
class T,
typename =
int>
162 constexpr bool is_matrix =
175 template <
class matrix_t>
177 enable_if_t<internal::is_matrix<matrix_t> &&
178 !internal::is_vector<matrix_t>,
180 using type = std::decay_t<
decltype(
181 ((
const matrix_t)std::declval<matrix_t>())(0, 0))>;
184 template <
class vector_t>
186 enable_if_t<internal::is_vector<vector_t>,
int>> {
187 using type = std::decay_t<
decltype(
188 ((
const vector_t)std::declval<vector_t>())[0])>;
191 template <
class matrix_t>
193 enable_if_t<internal::is_matrix<matrix_t> &&
194 !internal::is_vector<matrix_t>,
196 using type = std::decay_t<decltype(nrows(std::declval<matrix_t>()))>;
199 template <
class vector_t>
201 enable_if_t<internal::is_vector<vector_t>,
int>> {
202 using type = std::decay_t<decltype(size(std::declval<vector_t>()))>;
215 template <
class C1,
class C2,
class...
Cs>
223 template <
class C1,
class C2>
231 template <
class C1,
class T1,
class C2,
class T2>
237 template <
class...
Types>
245 enable_if_t<internal::is_matrix<C> && !internal::is_vector<C>,
int>> {
246 static constexpr bool value =
255 static constexpr bool value =
266 template <
class C,
class T>
269 enable_if_t<internal::is_matrix<C> || internal::is_vector<C>,
int>> {
270 static constexpr bool value =
275 template <
class C,
class T>
278 enable_if_t<!internal::is_matrix<C> && !internal::is_vector<C>,
int>> {
280 std::is_constructible<T, C>::value;
283 template <
class C1,
class T1,
class C2,
class T2,
class...
Ps>
285 static constexpr bool value =
288 internal::has_compatible_layout<
C1,
C2,
Ps...>;
293template <
class...
Ts>
297template <
class T1,
class...
Ts>
301template <
class T1,
class...
Ts>
305#ifdef TLAPACK_USE_LAPACKPP
308 struct allow_optblas_trait<
float,
int> : std::true_type {};
310 struct allow_optblas_trait<
double,
int> : std::true_type {};
312 struct allow_optblas_trait<std::complex<float>,
int> : std::true_type {};
314 struct allow_optblas_trait<std::complex<double>,
int> : std::true_type {};
316 struct allow_optblas_trait<
StrongZero,
int> : std::true_type {};
enable_if_t<(!allow_optblas< T1, Ts... >), int > disable_if_allow_optblas_t
Disable if the list of types allows optimized BLAS library.
Definition utils.hpp:303
constexpr bool isnan(const T &x) noexcept
Extends std::isnan() to complex numbers.
Definition utils.hpp:125
enable_if_t<(allow_optblas< T1, Ts... >), int > enable_if_allow_optblas_t
Enable if the list of types allows optimized BLAS library.
Definition utils.hpp:298
constexpr real_type< T > real(const T &x) noexcept
Extends std::real() to real datatypes.
Definition utils.hpp:71
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
constexpr bool allow_optblas
True if the list of types allows optimized BLAS library.
Definition utils.hpp:294
constexpr bool has_compatible_layout
True if C1, C2, Cs... have all compatible layouts. False otherwise.
Definition utils.hpp:216
constexpr real_type< T > abs1(const T &x)
1-norm absolute value, |Re(x)| + |Im(x)|
Definition utils.hpp:133
constexpr real_type< T > imag(const T &x) noexcept
Extends std::imag() to real datatypes.
Definition utils.hpp:86
constexpr bool isinf(const T &x) noexcept
Extends std::isinf() to complex numbers.
Definition utils.hpp:117
constexpr int sgn(const T &val)
Type-safe sgn function.
Definition utils.hpp:109
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113
Strong zero type.
Definition StrongZero.hpp:43
Trait to determine if the list Types allows optimization.
Definition utils.hpp:238
Entry type trait.
Definition arrayTraits.hpp:40
Size type trait.
Definition arrayTraits.hpp:61