<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
utils.hpp File Reference
#include <cmath>
#include <limits>
#include <type_traits>
#include <utility>
#include "tlapack/base/arrayTraits.hpp"
#include "tlapack/base/concepts.hpp"
#include "tlapack/base/exceptionHandling.hpp"
#include "tlapack/base/types.hpp"
#include "tlapack/base/workspace.hpp"
Include dependency graph for utils.hpp:

Go to the source code of this file.

Classes

struct  tlapack::traits::allow_optblas_trait< Types >
 Trait to determine if the list Types allows optimization. More...
 
struct  tlapack::traits::allow_optblas_trait< C, enable_if_t< internal::is_matrix< C > &&!internal::is_vector< C >, int > >
 
struct  tlapack::traits::allow_optblas_trait< C, enable_if_t< internal::is_vector< C >, int > >
 
struct  tlapack::traits::allow_optblas_trait< pair< C, T >, enable_if_t< internal::is_matrix< C >||internal::is_vector< C >, int > >
 
struct  tlapack::traits::allow_optblas_trait< pair< C, T >, enable_if_t<!internal::is_matrix< C > &&!internal::is_vector< C >, int > >
 
struct  tlapack::traits::allow_optblas_trait< pair< C1, T1 >, pair< C2, T2 >, Ps... >
 
struct  tlapack::traits::entry_type_trait< matrix_t, enable_if_t< internal::is_matrix< matrix_t > &&!internal::is_vector< matrix_t >, int > >
 
struct  tlapack::traits::entry_type_trait< vector_t, enable_if_t< internal::is_vector< vector_t >, int > >
 
struct  tlapack::traits::internal::has_operator_brackets_with_1_index< T, typename >
 
struct  tlapack::traits::internal::has_operator_brackets_with_1_index< T, enable_if_t<!is_same_v< decltype(std::declval< T >()[0]), void >, int > >
 
struct  tlapack::traits::internal::has_operator_parenthesis_with_2_indexes< T, typename >
 
struct  tlapack::traits::internal::has_operator_parenthesis_with_2_indexes< T, enable_if_t<!is_same_v< decltype(std::declval< T >()(0, 0)), void >, int > >
 
struct  tlapack::traits::size_type_trait< matrix_t, enable_if_t< internal::is_matrix< matrix_t > &&!internal::is_vector< matrix_t >, int > >
 
struct  tlapack::traits::size_type_trait< vector_t, enable_if_t< internal::is_vector< vector_t >, int > >
 

Typedefs

template<class T1 , class... Ts>
using tlapack::disable_if_allow_optblas_t = enable_if_t<(!allow_optblas< T1, Ts... >), int >
 Disable if the list of types allows optimized BLAS library.
 
template<class T1 , class... Ts>
using tlapack::enable_if_allow_optblas_t = enable_if_t<(allow_optblas< T1, Ts... >), int >
 Enable if the list of types allows optimized BLAS library.
 

Functions

template<typename T >
constexpr real_type< T > tlapack::abs1 (const T &x)
 1-norm absolute value, |Re(x)| + |Im(x)|
 
template<typename T , enable_if_t< is_real< T >, int > = 0>
constexprtlapack::conj (const T &x) noexcept
 Extends std::conj() to real datatypes.
 
template<typename T , enable_if_t< is_real< T >, int > = 0>
constexpr real_type< T > tlapack::imag (const T &x) noexcept
 Extends std::imag() to real datatypes.
 
template<typename T , enable_if_t< is_complex< T >, int > = 0>
constexpr bool tlapack::isinf (const T &x) noexcept
 Extends std::isinf() to complex numbers.
 
template<typename T , enable_if_t< is_complex< T >, int > = 0>
constexpr bool tlapack::isnan (const T &x) noexcept
 Extends std::isnan() to complex numbers.
 
template<typename T , enable_if_t< is_real< T >, int > = 0>
constexpr real_type< T > tlapack::real (const T &x) noexcept
 Extends std::real() to real datatypes.
 
template<typename T , enable_if_t< is_real< T >, int > = 0>
constexpr int tlapack::sgn (const T &val)
 Type-safe sgn function.
 
template<typename T >
constexprtlapack::square (const T &x)
 

Variables

template<class... Ts>
constexpr bool tlapack::allow_optblas = traits::allow_optblas_trait<Ts..., int>::value
 True if the list of types allows optimized BLAS library.
 
template<class C1 , class C2 , class... Cs>
constexpr bool tlapack::traits::internal::has_compatible_layout
 True if C1, C2, Cs... have all compatible layouts. False otherwise.
 
template<class C1 , class C2 >
constexpr bool tlapack::traits::internal::has_compatible_layout< C1, C2 >
 
template<class C1 , class T1 , class C2 , class T2 >
constexpr bool tlapack::traits::internal::has_compatible_layout< pair< C1, T1 >, pair< C2, T2 > >
 
template<class T >
constexpr bool tlapack::traits::internal::is_matrix
 
template<class T >
constexpr bool tlapack::traits::internal::is_vector = has_operator_brackets_with_1_index<T>::value
 

Detailed Description

Author
Weslley S Pereira, University of Colorado Denver, USA

Function Documentation

◆ conj()

template<typename T , enable_if_t< is_real< T >, int > = 0>
constexpr T tlapack::conj ( const T &  x)
constexprnoexcept

Extends std::conj() to real datatypes.

Parameters
[in]xReal number
Returns
x
Note
std::conj() is already defined for real numbers in C++. However, the return type is complex<real_t> instead of real_t.

◆ imag()

template<typename T , enable_if_t< is_real< T >, int > = 0>
constexpr real_type< T > tlapack::imag ( const T &  x)
constexprnoexcept

Extends std::imag() to real datatypes.

Parameters
[in]xReal number
Returns
0
Note
std::imag() is already defined for real numbers in C++. However, we want a more general definition that works for any real type, not only for the built-in types.

◆ real()

template<typename T , enable_if_t< is_real< T >, int > = 0>
constexpr real_type< T > tlapack::real ( const T &  x)
constexprnoexcept

Extends std::real() to real datatypes.

Parameters
[in]xReal number
Returns
x
Note
std::real() is already defined for real numbers in C++. However, we want a more general definition that works for any real type, not only for the built-in types.

◆ sgn()

template<typename T , enable_if_t< is_real< T >, int > = 0>
constexpr int tlapack::sgn ( const T &  val)
constexpr

Type-safe sgn function.

See also
Source: https://stackoverflow.com/a/4609795/5253097

Variable Documentation

◆ has_compatible_layout

template<class C1 , class C2 , class... Cs>
constexpr bool tlapack::traits::internal::has_compatible_layout
constexpr
Initial value:
=
(has_compatible_layout<C1, C2> &&
has_compatible_layout<C1, Cs...> &&
constexpr bool has_compatible_layout
True if C1, C2, Cs... have all compatible layouts. False otherwise.
Definition utils.hpp:216

True if C1, C2, Cs... have all compatible layouts. False otherwise.

◆ has_compatible_layout< C1, C2 >

template<class C1 , class C2 >
constexpr bool tlapack::traits::internal::has_compatible_layout< C1, C2 >
constexpr
Initial value:
=
(!is_matrix<C1> && !is_vector<C1>) ||
(!is_matrix<C2> && !is_vector<C2>) ||
(layout<C1> == Layout::Strided) ||
(layout<C2> == Layout::Strided) || (layout<C1> == layout<C2>)

◆ has_compatible_layout< pair< C1, T1 >, pair< C2, T2 > >

template<class C1 , class T1 , class C2 , class T2 >
constexpr bool tlapack::traits::internal::has_compatible_layout< pair< C1, T1 >, pair< C2, T2 > >
constexpr
Initial value:
=
has_compatible_layout<C1, C2>

◆ is_matrix

template<class T >
constexpr bool tlapack::traits::internal::is_matrix
constexpr
Initial value:
=
has_operator_parenthesis_with_2_indexes<T>::value