10#if !defined(MiniTensor_Traits_h)
11#define MiniTensor_Traits_h
16#include "MiniTensor_config.h"
19#if !defined( KOKKOS_INLINE_FUNCTION )
20#define KOKKOS_INLINE_FUNCTION inline
23#if defined(KOKKOS_ENABLE_CUDA)
24#define MT_ERROR_EXIT(...) \
25 Kokkos::abort(#__VA_ARGS__)
27#define MT_ERROR_EXIT(...) \
28 fprintf(stderr, "ERROR in: %s\n", __PRETTY_FUNCTION__); \
29 fprintf(stderr, __VA_ARGS__); \
30 fprintf(stderr, "\n"); \
34#if defined(KOKKOS_ENABLE_CUDA)
35#define MT_WARNING(...) \
36 Kokkos::abort(#__VA_ARGS__)
38#define MT_WARNING(...) \
39 fprintf(stderr, "WARNING in: %s\n", __PRETTY_FUNCTION__); \
40 fprintf(stderr, __VA_ARGS__); \
74template <
typename T, Index N>
class Vector;
75template <
typename T, Index N>
class Tensor;
76template <
typename T, Index N>
class Tensor3;
77template <
typename T, Index N>
class Tensor4;
78template <
typename T, Index M, Index N>
class Matrix;
92template<Index N, Index D>
98using Sacado::mpl::lazy_disable_if;
99using Sacado::mpl::disable_if_c;
109template <
typename T, Index N>
119template <
typename T, Index N>
133template <
typename T, Index N>
143template <
typename T, Index N>
157template <
typename T, Index N>
167template <
typename T, Index N>
181template <
typename T, Index N>
191template <
typename T, Index N>
205template <
typename T, Index M, Index N>
215template <
typename T, Index M, Index N>
229template <
typename T, Index N>
236template <
typename T, Index N>
243template <
typename T, Index N>
250template <
typename T, Index N>
257template<
typename T, Index M, Index N>
274 static string eval() {
return string(
"INVALID");}
281 static string eval() {
return string(
"DYNAMIC");}
288 static string eval() {
return string(
"1");}
295 static string eval() {
return string(
"2");}
302 static string eval() {
return string(
"3");}
309 static string eval() {
return string(
"4");}
330struct Promote<double, Index> {
337struct Promote<Index, double> {
344struct Promote<float, Index> {
351struct Promote<Index, float> {
358struct Promote<complex<double>, Index> {
365struct Promote<Index, complex<double>> {
372struct Promote<complex<float>, Index> {
379struct Promote<Index, complex<float>> {
385template <
typename T, Index N>
388 typedef typename ScalarType<T>::type
type;
392template <
typename T, Index N>
395 typedef typename ValueType<T>::type
type;
399template <
typename T, Index N>
402 static bool const value = IsADType<T>::value;
406template <
typename T, Index N>
409 static bool const value = IsScalarType<T>::value;
413template <
typename T, Index N>
424 v[i] = Value<T>::eval(x[i]);
432template <
typename T, Index N>
444 v[i] = ScalarValue<T>::eval(x[i]);
451template <
typename T, Index N>
457 return string(
"Vector<") + StringName<T>::eval() + string(
", ") +
463template <
typename T, Index N>
466 static bool eval(T
const & x, T
const & y) {
return x == y; }
470template <
typename T, Index N>
473 static bool const value =
true;
478struct IsStaticallySized<
Vector<T, DYNAMIC>>
481 static bool const value =
false;
485template <
typename T, Index N>
488 typedef typename ScalarType<T>::type
type;
492template <
typename T, Index N>
495 typedef typename ValueType<T>::type
type;
499template <
typename T, Index N>
502 static bool const value = IsADType<T>::value;
506template <
typename T, Index N>
509 static bool const value = IsScalarType<T>::value;
513template <
typename T, Index N>
524 v[i] = Value<T>::eval(x[i]);
532template <
typename T, Index N>
544 v[i] = ScalarValue<T>::eval(x[i]);
552template <
typename T, Index N>
558 return string(
"Tensor<") + StringName<T>::eval() + string(
", ") +
564template <
typename T, Index N>
567 static bool eval(T
const & x, T
const & y) {
return x == y; }
571template <
typename T, Index N>
574 static bool const value =
true;
579struct IsStaticallySized<
Tensor<T, DYNAMIC>>
582 static bool const value =
false;
586template <
typename T, Index N>
589 typedef typename ScalarType<T>::type
type;
593template <
typename T, Index N>
596 typedef typename ValueType<T>::type
type;
600template <
typename T, Index N>
603 static bool const value = IsADType<T>::value;
607template <
typename T, Index N>
610 static bool const value = IsScalarType<T>::value;
614template <
typename T, Index N>
625 v[i] = Value<T>::eval(x[i]);
633template <
typename T, Index N>
645 v[i] = ScalarValue<T>::eval(x[i]);
653template <
typename T, Index N>
659 return string(
"Tensor3<") + StringName<T>::eval() + string(
", ") +
665template <
typename T, Index N>
668 static bool eval(T
const & x, T
const & y) {
return x == y; }
672template <
typename T, Index N>
676 static bool const value =
true;
684 static bool const value =
false;
688template <
typename T, Index N>
691 typedef typename ScalarType<T>::type
type;
695template <
typename T, Index N>
698 typedef typename ValueType<T>::type
type;
702template <
typename T, Index N>
705 static bool const value = IsADType<T>::value;
709template <
typename T, Index N>
712 static bool const value = IsScalarType<T>::value;
716template <
typename T, Index N>
727 v[i] = Value<T>::eval(x[i]);
735template <
typename T, Index N>
747 v[i] = ScalarValue<T>::eval(x[i]);
755template <
typename T, Index N>
761 return string(
"Tensor4<") + StringName<T>::eval() + string(
", ") +
767template <
typename T, Index N>
770 static bool eval(T
const & x, T
const & y) {
return x == y; }
774template <
typename T, Index N>
778 static bool const value =
true;
786 static bool const value=
false;
790template <
typename T, Index M, Index N>
793 typedef typename ScalarType<T>::type
type;
797template <
typename T, Index M, Index N>
800 typedef typename ValueType<T>::type
type;
804template <
typename T, Index M, Index N>
807 static bool const value = IsADType<T>::value;
811template <
typename T, Index M, Index N>
814 static bool const value = IsScalarType<T>::value;
818template <
typename T, Index M, Index N>
821 typedef typename ValueType<Matrix<T, M, N>>::type
value_type;
829 v[i] = Value<T>::eval(x[i]);
837template <
typename T, Index M, Index N>
849 v[i] = ScalarValue<T>::eval(x[i]);
857template <
typename T, Index M, Index N>
863 return string(
"Matrix<") + StringName<T>::eval() + string(
", ") +
870template <
typename T, Index M, Index N>
873 static bool eval(T
const & x, T
const & y) {
return x == y; }
877template <
typename T, Index M, Index N>
878struct IsStaticallySized<
Matrix<T, M, N>> {
880 static bool const value =
true;
885template <
typename T, Index M>
886struct IsStaticallySized<
Matrix<T, M, DYNAMIC>>
889 static bool const value =
false;
894template <
typename T, Index N>
895struct IsStaticallySized<
Matrix<T, DYNAMIC, N>>
898 static bool const value =
false;
904struct IsStaticallySized<
Matrix<T, DYNAMIC, DYNAMIC>>
907 static bool const value =
false;
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION Index get_num_cols() const
KOKKOS_INLINE_FUNCTION Index get_num_rows() const
KOKKOS_INLINE_FUNCTION Index get_number_components() const
double Real
Floating point type.
uint32_t Index
Indexing type.
constexpr bool dimension_reachable
constexpr Index INDEX_SIZE
constexpr Index DYNAMIC
Indicator for dynamic storage.
constexpr Index LONG_INDEX_SIZE
std::complex< Real > Complex
Complex type.
uint64_t LongIndex
High count type.
static bool eval(T const &x, T const &y)
Compare two components for equality.
static bool eval(T const &x, T const &y)
Compare two components for equality.
static bool eval(T const &x, T const &y)
Compare two components for equality.
static bool eval(T const &x, T const &y)
Compare two components for equality.
static bool eval(T const &x, T const &y)
Compare two components for equality.
ScalarType< T >::type type
Underlying scalar type of the Matrix components.
ScalarType< T >::type type
Underlying scalar type of the Tensor3 components.
ScalarType< T >::type type
Underlying scalar type of the Tensor4 components.
ScalarType< T >::type type
Underlying scalar type of the Tensor components.
ScalarType< T >::type type
Underlying scalar type of the Vector components.
static const Matrix< scalar_type, M, N > eval(Matrix< T, M, N > const &x)
ScalarType< Matrix< T, M, N > >::type scalar_type
Scalar type of the Matrix components.
ScalarType< Tensor3< T, N > >::type scalar_type
Scalar type of the Tensor3 components.
static const Tensor3< scalar_type, N > eval(Tensor3< T, N > const &x)
ScalarType< Tensor4< T, N > >::type scalar_type
Scalar type of the Tensor4 components.
static const Tensor4< scalar_type, N > eval(Tensor4< T, N > const &x)
static const Tensor< scalar_type, N > eval(Tensor< T, N > const &x)
ScalarType< Tensor< T, N > >::type scalar_type
Scalar type of the Tensor components.
ScalarType< Vector< T, N > >::type scalar_type
Scalar type of the Vector components.
static const Vector< scalar_type, N > eval(Vector< T, N > const &x)
static string eval()
Return the name of the Matrix type as a string.
static string eval()
Return the name of the Tensor3 type as a string.
static string eval()
Return the name of the Tensor4 type as a string.
static string eval()
Return the name of the Tensor type as a string.
static string eval()
Return the name of the Vector type as a string.
ValueType< Matrix< T, M, N > >::type value_type
Value type of the Matrix components.
static const Matrix< value_type, M, N > eval(Matrix< T, M, N > const &x)
Extract a Matrix of the values of the components of x.
static const Tensor3< value_type, N > eval(Tensor3< T, N > const &x)
Extract a Tensor3 of the values of the components of x.
ValueType< Tensor3< T, N > >::type value_type
Value type of the Tensor3 components.
static const Tensor4< value_type, N > eval(Tensor4< T, N > const &x)
Extract a Tensor4 of the values of the components of x.
ValueType< Tensor4< T, N > >::type value_type
Value type of the Tensor4 components.
static const Tensor< value_type, N > eval(Tensor< T, N > const &x)
Extract a Tensor of the values of the components of x.
ValueType< Tensor< T, N > >::type value_type
Value type of the Tensor components.
static const Vector< value_type, N > eval(Vector< T, N > const &x)
Extract a Vector of the values of the components of x.
ValueType< Vector< T, N > >::type value_type
Value type of the Vector components.
ValueType< T >::type type
Value type of the Matrix components.
ValueType< T >::type type
Value type of the Tensor3 components.
ValueType< T >::type type
Value type of the Tensor4 components.
ValueType< T >::type type
Value type of the Tensor components.
ValueType< T >::type type
Value type of the Vector components.
Matrix< typename T::type, M, N > type
Matrix with element type T::type.
Tensor3< typename T::type, N > type
Tensor3 with element type T::type.
Tensor4< typename T::type, N > type
Tensor4 with element type T::type.
Tensor< typename T::type, N > type
Tensor with element type T::type.
Vector< typename T::type, N > type
Vector with element type T::type.
static string eval()
Return "1".
static string eval()
Return "2".
static string eval()
Return "3".
static string eval()
Return "4".
static string eval()
Return "DYNAMIC".
static string eval()
Return "INVALID" for dimensions without a specialization.
static bool const value
Whether T is a Matrix.
static bool const value
Whether T is a Tensor3.
static bool const value
Whether T is a Tensor4.
static bool const value
Whether T is a Tensor.
static bool const value
Whether T is a Vector.
Tensors from 1st to 4th order and matrix.
static bool const value
Whether T is a tensor of order 1 to 4 or a matrix.