TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
traits.hpp File Reference
#include <complex>
#include <cstdint>
#include <ranges>
#include <type_traits>
#include <utility>

Detailed Description

Provides type traits for the nda library.

Definition in file traits.hpp.

Go to the source code of this file.

Classes

struct  nda::_linear_index_t
 A small wrapper around a single long integer to be used as a linear index. More...
 
struct  nda::is_instantiation_of< TMPLT, T >
 Check if type T is of type TMPLT<...>. More...
 
struct  nda::layout_info_t
 Stores information about the memory layout and the stride order of an array/view. More...
 

Typedefs

template<typename A >
using nda::get_value_t = std::decay_t<decltype(get_first_element(std::declval<A const>()))>
 Get the value type of an array/view or a scalar type.
 

Enumerations

enum class  nda::layout_prop_e : uint64_t
 Compile-time guarantees of the memory layout of an array/view. More...
 

Functions

template<typename A >
decltype(auto) nda::get_first_element (A const &a)
 Get the first element of an array/view or simply return the scalar if a scalar is given.
 
constexpr bool nda::has_contiguous (layout_prop_e lp)
 Checks if a layout property has the contiguous property.
 
constexpr bool nda::has_smallest_stride_is_one (layout_prop_e lp)
 Checks if a layout property has the smallest_stride_is_one property.
 
constexpr bool nda::has_strided_1d (layout_prop_e lp)
 Checks if a layout property has the strided_1d property.
 
constexpr bool nda::layout_property_compatible (layout_prop_e from, layout_prop_e to)
 Checks if two layout properties are compatible with each other.
 
constexpr layout_info_t nda::operator& (layout_info_t lhs, layout_info_t rhs)
 Bitwise AND operator for layout infos.
 
constexpr layout_prop_e nda::operator& (layout_prop_e lhs, layout_prop_e rhs)
 Bitwise AND operator for two layout properties.
 
constexpr layout_prop_e nda::operator| (layout_prop_e lhs, layout_prop_e rhs)
 Bitwise OR operator for two layout properties.
 

Variables

template<typename... Ts>
static constexpr bool nda::always_false = false
 Constexpr variable that is always false regardless of the types in Ts (used to trigger static_assert).
 
template<typename... Ts>
static constexpr bool nda::always_true = true
 Constexpr variable that is always true regardless of the types in Ts.
 
template<typename A >
constexpr char nda::get_algebra = 'N'
 Constexpr variable that specifies the algebra of a type.
 
template<typename A >
constexpr layout_info_t nda::get_layout_info = layout_info_t{}
 Constexpr variable that specifies the nda::layout_info_t of type A.
 
template<typename A >
constexpr int nda::get_rank
 Constexpr variable that specifies the rank of an nda::Array or of a contiguous 1-dimensional range.
 
template<typename A >
constexpr bool nda::has_contiguous_layout = (has_contiguous(get_layout_info<A>.prop))
 Constexpr variable that is true if type A has the contiguous nda::layout_prop_e guarantee.
 
template<typename A >
constexpr bool nda::has_layout_smallest_stride_is_one = (has_smallest_stride_is_one(get_layout_info<A>.prop))
 Constexpr variable that is true if type A has the smallest_stride_is_one nda::layout_prop_e guarantee.
 
template<typename A >
constexpr bool nda::has_layout_strided_1d = (has_strided_1d(get_layout_info<A>.prop))
 Constexpr variable that is true if type A has the strided_1d nda::layout_prop_e guarantee.
 
template<typename A0 , typename... As>
constexpr bool nda::have_same_rank_v = ((get_rank<A0> == get_rank<As>)and... and true)
 Constexpr variable that is true if all types in As have the same rank as A0.
 
template<typename A0 , typename... As>
constexpr bool nda::have_same_value_type_v = (std::is_same_v<get_value_t<A0>, get_value_t<As>> and ... and true)
 Constexpr variable that is true if all types in As have the same value type as A0.
 
template<typename T , typename... Ts>
static constexpr bool nda::is_any_of = (std::is_same_v<Ts, T> or ... or false)
 Constexpr variable that is true if type T is contained in the parameter pack Ts.
 
template<typename T >
constexpr bool nda::is_blas_lapack_v = is_double_or_complex_v<T>
 Alias for nda::is_double_or_complex_v.
 
template<typename T >
constexpr bool nda::is_complex_v = is_instantiation_of_v<std::complex, T>
 Constexpr variable that is true if type T is a std::complex type.
 
template<typename T >
constexpr bool nda::is_double_or_complex_v = is_complex_v<T> or std::is_same_v<double, std::remove_cvref_t<T>>
 Constexpr variable that is true if type T is a std::complex type or a double type.
 
template<template< typename... > class TMPLT, typename T >
constexpr bool nda::is_instantiation_of_v = is_instantiation_of<TMPLT, std::remove_cvref_t<T>>::value
 Constexpr variable that is true if type T is an instantiation of TMPLT (see nda::is_instantiation_of).
 
template<typename A >
constexpr bool nda::is_matrix_or_view_v = is_regular_or_view_v<A> and (get_algebra<A> == 'M') and (get_rank<A> == 2)
 Constexpr variable that is true if type A is a regular matrix or a view of a matrix.
 
template<typename A >
constexpr bool nda::is_regular_or_view_v = is_regular_v<A> or is_view_v<A>
 Constexpr variable that is true if type A is either a regular array or a view.
 
template<typename A >
constexpr bool nda::is_regular_v = false
 Constexpr variable that is true if type A is a regular array, i.e. an nda::basic_array.
 
template<typename S , typename A >
constexpr bool nda::is_scalar_for_v
 Constexpr variable used to check requirements when initializing an nda::basic_array or nda::basic_array_view of type A with some object/value of type S.
 
template<typename S >
constexpr bool nda::is_scalar_or_convertible_v = is_scalar_v<S> or std::is_constructible_v<std::complex<double>, S>
 Constexpr variable that is true if type S is a scalar type (see nda::is_scalar_v) or if a std::complex<double> can be constructed from it.
 
template<typename S >
constexpr bool nda::is_scalar_v = std::is_arithmetic_v<std::remove_cvref_t<S>> or is_complex_v<S>
 Constexpr variable that is true if type S is a scalar type, i.e. arithmetic or complex.
 
template<typename A >
constexpr bool nda::is_view_v = false
 Constexpr variable that is true if type A is a view, i.e. an nda::basic_array_view.