MiniTensor Version of the Day
Loading...
Searching...
No Matches
Type Traits and Scalar Utilities

Sacado-aware type promotion machinery, index types, and scalar-level helpers such as machine_epsilon and not_a_number. More...

Classes

class  minitensor::Vector< T, N >
 The classes. More...
 
class  minitensor::Tensor< T, N >
 
class  minitensor::Tensor3< T, N >
 
class  minitensor::Tensor4< T, N >
 
class  minitensor::Matrix< T, M, N >
 
struct  minitensor::is_vector< T >
 Vector. More...
 
struct  minitensor::is_vector< Vector< T, N > >
 is_vector specialization: T is a Vector. More...
 
struct  minitensor::apply_vector< T, N >
 
struct  minitensor::is_tensor< T >
 2nd-order tensor More...
 
struct  minitensor::is_tensor< Tensor< T, N > >
 is_tensor specialization: T is a Tensor. More...
 
struct  minitensor::apply_tensor< T, N >
 
struct  minitensor::is_tensor3< T >
 3rd-order tensor More...
 
struct  minitensor::is_tensor3< Tensor3< T, N > >
 is_tensor3 specialization: T is a Tensor3. More...
 
struct  minitensor::apply_tensor3< T, N >
 
struct  minitensor::is_tensor4< T >
 4th-order tensor More...
 
struct  minitensor::is_tensor4< Tensor4< T, N > >
 is_tensor4 specialization: T is a Tensor4. More...
 
struct  minitensor::apply_tensor4< T, N >
 
struct  minitensor::is_matrix< T >
 Matrix. More...
 
struct  minitensor::is_matrix< Matrix< T, M, N > >
 is_matrix specialization: T is a Matrix. More...
 
struct  minitensor::apply_matrix< T, M, N >
 
struct  minitensor::order_1234< T >
 Tensors from 1st to 4th order and matrix. More...
 
struct  minitensor::order_1234< Vector< T, N > >
 order_1234 specialization for Vector. More...
 
struct  minitensor::order_1234< Tensor< T, N > >
 order_1234 specialization for Tensor. More...
 
struct  minitensor::order_1234< Tensor3< T, N > >
 order_1234 specialization for Tensor3. More...
 
struct  minitensor::order_1234< Tensor4< T, N > >
 order_1234 specialization for Tensor4. More...
 
struct  minitensor::order_1234< Matrix< T, M, N > >
 order_1234 specialization for Matrix. More...
 
struct  minitensor::dimension_string< N >
 
struct  minitensor::dimension_string< DYNAMIC >
 dimension_string specialization for DYNAMIC. More...
 
struct  minitensor::dimension_string< 1 >
 dimension_string specialization for dimension 1. More...
 
struct  minitensor::dimension_string< 2 >
 dimension_string specialization for dimension 2. More...
 
struct  minitensor::dimension_string< 3 >
 dimension_string specialization for dimension 3. More...
 
struct  minitensor::dimension_string< 4 >
 dimension_string specialization for dimension 4. More...
 

Typedefs

using minitensor::Index = uint32_t
 Indexing type.
 
using minitensor::LongIndex = uint64_t
 High count type.
 
using minitensor::Real = double
 Floating point type.
 
using minitensor::Complex = std::complex< Real >
 Complex type.
 

Functions

template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::abs (T const &a)
 
template<typename T >
KOKKOS_INLINE_FUNCTION void minitensor::swap (T &a, T &b)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::max (T const &a, T const &b)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::min (T const &a, T const &b)
 
template<typename T >
KOKKOS_INLINE_FUNCTION int minitensor::sgn (T const &s)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::copysign (T const &a, T const &b)
 
template<typename T >
KOKKOS_INLINE_FUNCTION Sacado::ScalarType< T >::type minitensor::not_a_number ()
 
template<typename T >
KOKKOS_INLINE_FUNCTION Sacado::ScalarType< T >::type minitensor::machine_epsilon ()
 
template<typename T >
KOKKOS_INLINE_FUNCTION Index minitensor::num_digits ()
 
template<>
KOKKOS_INLINE_FUNCTION Index minitensor::num_digits< Index > ()
 
template<>
KOKKOS_INLINE_FUNCTION Index minitensor::num_digits< LongIndex > ()
 
template<typename T >
KOKKOS_INLINE_FUNCTION Sacado::ScalarType< T >::type minitensor::tau ()
 
template<typename T >
Sacado::ScalarType< T >::type minitensor::random ()
 
template<typename T >
Sacado::ScalarType< T >::type minitensor::random_uniform ()
 
template<typename T >
Sacado::ScalarType< T >::type minitensor::random_normal ()
 
template<typename T >
KOKKOS_INLINE_FUNCTION void minitensor::fill_AD (typename enable_if< is_same< T, typename ScalarType< T >::type >::value, T >::type &x, typename ScalarType< T >::type const c)
 
template<typename T >
KOKKOS_INLINE_FUNCTION void minitensor::fill_AD (typename enable_if<!is_same< T, typename ScalarType< T >::type >::value, T >::type &x, typename ScalarType< T >::type const c)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::integer_power (T const &X, Index const exponent)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::integer_root (T const &x, Index const root)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::kronecker_delta (Index const i, Index const j)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::kronecker_delta (Index const i, Index const j, Index const k)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::kronecker_delta (Index const i, Index const j, Index const k, Index const l)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::levi_civita (Index const i, Index const j)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::levi_civita (Index const i, Index const j, Index const k)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::levi_civita (Index const i, Index const j, Index const k, Index const l)
 

Variables

constexpr Index minitensor::INDEX_SIZE {32}
 
constexpr Index minitensor::LONG_INDEX_SIZE {64}
 
constexpr Index minitensor::DYNAMIC {0}
 Indicator for dynamic storage.
 
template<Index N, Index D>
constexpr bool minitensor::dimension_reachable {N == DYNAMIC || N >= D}
 

Detailed Description

Sacado-aware type promotion machinery, index types, and scalar-level helpers such as machine_epsilon and not_a_number.

Typedef Documentation

◆ Index

using minitensor::Index = typedef uint32_t

Indexing type.

Definition at line 50 of file MiniTensor_Traits.h.

◆ LongIndex

using minitensor::LongIndex = typedef uint64_t

High count type.

Definition at line 59 of file MiniTensor_Traits.h.

◆ Real

using minitensor::Real = typedef double

Floating point type.

Definition at line 68 of file MiniTensor_Traits.h.

◆ Complex

using minitensor::Complex = typedef std::complex<Real>

Complex type.

Definition at line 71 of file MiniTensor_Traits.h.

Function Documentation

◆ abs()

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::abs ( T const &  a)

Absolute value, usable on host and device.

Definition at line 244 of file MiniTensor_Scalar.h.

◆ swap()

template<typename T >
KOKKOS_INLINE_FUNCTION void minitensor::swap ( T &  a,
T &  b 
)

Swap two values, usable on host and device.

Definition at line 258 of file MiniTensor_Scalar.h.

◆ max()

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::max ( T const &  a,
T const &  b 
)

Maximum of two values, usable on host and device.

Definition at line 277 of file MiniTensor_Scalar.h.

◆ min()

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::min ( T const &  a,
T const &  b 
)

Minimum of two values, usable on host and device.

Definition at line 291 of file MiniTensor_Scalar.h.

◆ sgn()

template<typename T >
KOKKOS_INLINE_FUNCTION int minitensor::sgn ( T const &  s)

Sign function

Definition at line 302 of file MiniTensor_Scalar.h.

◆ copysign()

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::copysign ( T const &  a,
T const &  b 
)

Copysign function

Definition at line 313 of file MiniTensor_Scalar.h.

◆ not_a_number()

template<typename T >
KOKKOS_INLINE_FUNCTION Sacado::ScalarType< T >::type minitensor::not_a_number ( )

NaN function. Necessary to choose the proper underlying NaN for non-floating-point types. Assumption: non-floating-point types have a typedef that determines the underlying floating-point type.

Definition at line 327 of file MiniTensor_Scalar.h.

◆ machine_epsilon()

template<typename T >
KOKKOS_INLINE_FUNCTION Sacado::ScalarType< T >::type minitensor::machine_epsilon ( )

Machine epsilon function. Necessary to choose the proper underlying machine epsilon for non-floating-point types. Assumption: non-floating-point types have a typedef that determines the underlying floating-point type.

Definition at line 342 of file MiniTensor_Scalar.h.

◆ num_digits()

template<typename T >
KOKKOS_INLINE_FUNCTION Index minitensor::num_digits ( )

Number of digits for integer types.

Definition at line 354 of file MiniTensor_Scalar.h.

◆ num_digits< Index >()

Number of binary digits in Index.

Definition at line 361 of file MiniTensor_Scalar.h.

◆ num_digits< LongIndex >()

Number of binary digits in LongIndex.

Definition at line 369 of file MiniTensor_Scalar.h.

◆ tau()

template<typename T >
KOKKOS_INLINE_FUNCTION Sacado::ScalarType< T >::type minitensor::tau ( )

The circle constant

Definition at line 381 of file MiniTensor_Scalar.h.

◆ random()

template<typename T >
Sacado::ScalarType< T >::type minitensor::random ( )

Random number generation. Uniform distribution U(-1,1).

Definition at line 392 of file MiniTensor_Scalar.h.

◆ random_uniform()

template<typename T >
Sacado::ScalarType< T >::type minitensor::random_uniform ( )

Random number generation. Uniform distribution U(0,1).

Definition at line 401 of file MiniTensor_Scalar.h.

◆ random_normal()

template<typename T >
Sacado::ScalarType< T >::type minitensor::random_normal ( )

Random number generation. Normal distribution N(0,1).

Definition at line 409 of file MiniTensor_Scalar.h.

◆ fill_AD() [1/2]

template<typename T >
KOKKOS_INLINE_FUNCTION void minitensor::fill_AD ( typename enable_if< is_same< T, typename ScalarType< T >::type >::value, T >::type &  x,
typename ScalarType< T >::type const  c 
)

Fill a non-AD scalar with a constant.

Definition at line 429 of file MiniTensor_Scalar.h.

◆ fill_AD() [2/2]

template<typename T >
KOKKOS_INLINE_FUNCTION void minitensor::fill_AD ( typename enable_if<!is_same< T, typename ScalarType< T >::type >::value, T >::type &  x,
typename ScalarType< T >::type const  c 
)

Fill an AD scalar with a constant, handling its derivative components.

Definition at line 443 of file MiniTensor_Scalar.h.

◆ integer_power()

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::integer_power ( T const &  X,
Index const  exponent 
)

Compute a non-negative integer power by binary manipulation.

Definition at line 468 of file MiniTensor_Scalar.h.

◆ integer_root()

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::integer_root ( T const &  x,
Index const  root 
)

Compute a non-negative integer root by bisection.

Definition at line 548 of file MiniTensor_Scalar.h.

◆ kronecker_delta() [1/3]

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::kronecker_delta ( Index const  i,
Index const  j 
)

Utility for Kronecker delta in 2D

Definition at line 580 of file MiniTensor_Scalar.h.

◆ kronecker_delta() [2/3]

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::kronecker_delta ( Index const  i,
Index const  j,
Index const  k 
)

Utility for Kronecker delta in 3D

Definition at line 596 of file MiniTensor_Scalar.h.

◆ kronecker_delta() [3/3]

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::kronecker_delta ( Index const  i,
Index const  j,
Index const  k,
Index const  l 
)

Utility for Kronecker delta in 4D

Definition at line 613 of file MiniTensor_Scalar.h.

◆ levi_civita() [1/3]

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::levi_civita ( Index const  i,
Index const  j 
)

Utility for Levi-Civita/permutation/alternating symbol in 2D

Definition at line 631 of file MiniTensor_Scalar.h.

◆ levi_civita() [2/3]

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::levi_civita ( Index const  i,
Index const  j,
Index const  k 
)

Utility for Levi-Civita/permutation/alternating symbol in 3D

Definition at line 649 of file MiniTensor_Scalar.h.

◆ levi_civita() [3/3]

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::levi_civita ( Index const  i,
Index const  j,
Index const  k,
Index const  l 
)

Utility for Levi-Civita/permutation/alternating symbol in 4D

Definition at line 672 of file MiniTensor_Scalar.h.

Variable Documentation

◆ INDEX_SIZE

constexpr Index minitensor::INDEX_SIZE {32}
constexpr

Number of bits in Index.

Definition at line 56 of file MiniTensor_Traits.h.

◆ LONG_INDEX_SIZE

constexpr Index minitensor::LONG_INDEX_SIZE {64}
constexpr

Number of bits in LongIndex.

Definition at line 65 of file MiniTensor_Traits.h.

◆ DYNAMIC

constexpr Index minitensor::DYNAMIC {0}
constexpr

Indicator for dynamic storage.

Definition at line 82 of file MiniTensor_Traits.h.

◆ dimension_reachable

template<Index N, Index D>
constexpr bool minitensor::dimension_reachable {N == DYNAMIC || N >= D}
inlineconstexpr

Whether a container whose static dimension is N can ever have the run-time dimension D. Dynamically sized containers can have any dimension, statically sized ones are bounded by N. Use it with if constexpr to discard the branches of a dimension dispatch that a statically sized argument can never take, and that would otherwise look to the compiler like accesses past the end of its storage.

Definition at line 94 of file MiniTensor_Traits.h.