10#if !defined(MiniTensor_Tensor4_h)
11#define MiniTensor_Tensor4_h
25template<
typename T, Index N>
31template<
typename T, Index N = DYNAMIC>
148 Index const l)
const;
187template<
typename S,
typename T, Index N>
198template<
typename S,
typename T, Index N>
207template<
typename T, Index N>
216template<
typename T, Index N>
225template<
typename T, Index N>
236template<
typename S,
typename T, Index N>
247template<
typename S,
typename T, Index N>
258template<
typename S,
typename T, Index N>
269template<
typename S,
typename T, Index N>
277template<
typename T, Index N>
286template<
typename T, Index N>
299template<
typename T, Index N>
308template<
typename T, Index N>
321template<
typename T, Index N>
330template<
typename T, Index N>
343template<
typename T, Index N>
351template<
typename T, Index N>
361template<
typename T, Index N>
369template<
typename T, Index N>
379template<
typename T, Index N>
387template<
typename T, Index N>
397template<
typename T, Index N>
406template<
typename T, Index N>
417template<
typename S,
typename T, Index N>
428template<
typename S,
typename T, Index N>
439template<
typename S,
typename T, Index N>
450template<
typename S,
typename T, Index N>
461template<
typename S,
typename T, Index N>
472template<
typename S,
typename T, Index N>
483template<
typename S,
typename T, Index N>
494template<
typename S,
typename T, Index N>
505template<
typename S,
typename T, Index N>
516template<
typename S,
typename T, Index N>
527template<
typename S,
typename T, Index N>
538template<
typename S,
typename T, Index N>
549template<
typename S,
typename T, Index N>
560template<
typename S,
typename T, Index N>
571template<
typename S,
typename T, Index N>
582template<
typename S,
typename T, Index N>
593template<
typename S,
typename T, Index N>
604template<
typename S,
typename T, Index N>
617template<
typename S,
typename T, Index N>
633template<
typename S,
typename T, Index N>
644template<
typename T, Index N>
654template<
typename T, Index N>
666template<
typename T, Index N>
675template<
typename T, Index N>
686template<
typename T, Index N>
694template<
typename T, Index N>
705template<
typename T, Index N>
713template<
typename T, Index N>
724template<
typename T, Index N>
740second_to_fourth_dimension(
Index const dimension_2nd)
745 switch (dimension_2nd) {
769 return dimension_4th;
774template<
typename T, Index N>
779 dimension_2nd = A.get_dimension();
782 dimension_4th = second_to_fourth_dimension(dimension_2nd);
790 number_components = dimension_2nd * dimension_2nd;
792 for (
Index i = 0; i < number_components; ++i) {
801template<
typename T, Index N>
811template<
typename T, Index N>
822template<
typename T, Index N>
834template<
typename S,
typename T, Index N>
850template<
typename S,
typename T, Index N>
852Tensor4<typename Promote<S, T>::type, N>
866template<
typename T, Index N>
882template<
typename T, Index N>
893template<
typename T, Index N>
904template<
typename S,
typename T, Index N>
906typename lazy_disable_if< order_1234<S>, apply_tensor4< Promote<S,T>, N>>::type
920template<
typename S,
typename T, Index N>
922typename lazy_disable_if< order_1234<S>, apply_tensor4< Promote<S,T>, N>>::type
936template<
typename S,
typename T, Index N>
938Tensor4<typename Promote<S, T>::type, N>
952template<
typename S,
typename T, Index N>
954Tensor4<typename Promote<S, T>::type, N>
972template<
typename T, Index N>
984 return self[((i * dimension + j) * dimension + k) * dimension + l];
994template<
typename T, Index N>
1006 return self[((i * dimension + j) * dimension + k) * dimension + l];
1012template<
typename T, Index N>
1025template<
typename T, Index N>
1031 dimension = A.get_dimension();
1033 for (
Index i = 0; i < dimension; ++i) {
1034 for (
Index j = 0; j < dimension; ++j) {
1035 for (
Index k = 0; k < dimension; ++k) {
1036 for (
Index l = 0; l < dimension; ++l) {
1037 if (i == k && j == l) {
1048template<
typename T, Index N>
1054 dimension = A.get_dimension();
1056 for (
Index i = 0; i < dimension; ++i) {
1057 for (
Index j = 0; j < dimension; ++j) {
1058 for (
Index k = 0; k < dimension; ++k) {
1059 for (
Index l = 0; l < dimension; ++l) {
1060 if (i == l && j == k) {
1071template<
typename T, Index N>
1077 dimension = A.get_dimension();
1079 for (
Index i = 0; i < dimension; ++i) {
1080 for (
Index j = 0; j < dimension; ++j) {
1081 for (
Index k = 0; k < dimension; ++k) {
1082 for (
Index l = 0; l < dimension; ++l) {
1083 if (i == j && k == l) {
1094template<
typename T, Index N>
1099 dimension = A.get_dimension();
1101 for (
Index i = 0; i < dimension; ++i) {
1102 for (
Index j = 0; j < dimension; ++j) {
1103 for (
Index k = 0; k < dimension; ++k) {
1104 for (
Index l = 0; l < dimension; ++l) {
1120template<
typename T, Index N>
1132const Tensor4<T, DYNAMIC>
1143template<
typename T, Index N>
1148 if (N !=
DYNAMIC) assert(dimension == N);
1159template<
typename T, Index N>
1171const Tensor4<T, DYNAMIC>
1182template<
typename T, Index N>
1187 if (N !=
DYNAMIC) assert(dimension == N);
1198template<
typename T, Index N>
1210const Tensor4<T, DYNAMIC>
1221template<
typename T, Index N>
1234template<
typename T, Index N>
1242 fill_levi_civita(A);
1252Tensor4<T, DYNAMIC>
const
1258 fill_levi_civita(A);
1266template<
typename T, Index N>
1271 if (N !=
DYNAMIC) assert(dimension == N);
1276 fill_levi_civita(A);
1284template<
typename T, Index N>
1297Tensor4<T, DYNAMIC>
const
1306template<
typename T, Index N>
1317template<
typename T, Index N>
1330Tensor4<T, DYNAMIC>
const
1340template<
typename T, Index N>
1352template<
typename T, Index N>
1363 for (
Index i = 0; i < dimension; ++i) {
1364 for (
Index j = 0; j < dimension; ++j) {
1365 for (
Index k = 0; k < dimension; ++k) {
1366 for (
Index l = 0; l < dimension; ++l) {
1367 B(i, j, k, l) = A(k, l, i, j);
1382template<
typename S,
typename T, Index N>
1384Tensor3<typename Promote<S, T>::type, N>
1395 for (
Index i = 0; i < dimension; ++i) {
1396 for (
Index j = 0; j < dimension; ++j) {
1397 for (
Index k = 0; k < dimension; ++k) {
1399 typename Promote<S, T>::type
1402 for (
Index p = 0; p < dimension; ++p) {
1403 s += A(i,j,k,p) * u(p);
1419template<
typename S,
typename T, Index N>
1421Tensor3<typename Promote<S, T>::type, N>
1432 for (
Index i = 0; i < dimension; ++i) {
1433 for (
Index j = 0; j < dimension; ++j) {
1434 for (
Index k = 0; k < dimension; ++k) {
1436 typename Promote<S, T>::type
1439 for (
Index p = 0; p < dimension; ++p) {
1440 s += u(p) * A(p,i,j,k);
1456template<
typename S,
typename T, Index N>
1458Tensor3<typename Promote<S, T>::type, N>
1469 for (
Index i = 0; i < dimension; ++i) {
1470 for (
Index j = 0; j < dimension; ++j) {
1471 for (
Index k = 0; k < dimension; ++k) {
1473 typename Promote<S, T>::type
1476 for (
Index p = 0; p < dimension; ++p) {
1477 s += A(i,j,p,k) * u(p);
1493template<
typename S,
typename T, Index N>
1495Tensor3<typename Promote<S, T>::type, N>
1506 for (
Index i = 0; i < dimension; ++i) {
1507 for (
Index j = 0; j < dimension; ++j) {
1508 for (
Index k = 0; k < dimension; ++k) {
1510 typename Promote<S, T>::type
1513 for (
Index p = 0; p < dimension; ++p) {
1514 s += u(p) * A(i,p,j,k);
1527template<
typename S,
typename T, Index N>
1529Tensor<typename Promote<S, T>::type, N>
1540 for (
Index i = 0; i < dimension; ++i) {
1541 for (
Index j = 0; j < dimension; ++j) {
1543 typename Promote<S, T>::type
1546 for (
Index p = 0; p < dimension; ++p) {
1547 for (
Index q = 0; q < dimension; ++q) {
1548 s += A(i,j,p,q) * B(p,q);
1561template<
typename S,
typename T, Index N>
1563Tensor<typename Promote<S, T>::type, N>
1574 for (
Index i = 0; i < dimension; ++i) {
1575 for (
Index j = 0; j < dimension; ++j) {
1577 typename Promote<S, T>::type
1580 for (
Index p = 0; p < dimension; ++p) {
1581 for (
Index q = 0; q < dimension; ++q) {
1582 s += B(p,q) * A(p,q,i,j);
1595template<
typename S,
typename T, Index N>
1597Tensor4<typename Promote<S, T>::type, N>
1608 for (
Index i = 0; i < dimension; ++i) {
1609 for (
Index j = 0; j < dimension; ++j) {
1610 for (
Index k = 0; k < dimension; ++k) {
1611 for (
Index l = 0; l < dimension; ++l) {
1613 typename Promote<S, T>::type
1616 for (
Index p = 0; p < dimension; ++p) {
1617 for (
Index q = 0; q < dimension; ++q) {
1618 s += A(i,j,p,q) * B(p,q,k,l);
1633template<
typename S,
typename T, Index N>
1635Tensor4<typename Promote<S, T>::type, N>
1646 for (
Index i = 0; i < dimension; ++i) {
1647 for (
Index j = 0; j < dimension; ++j) {
1648 for (
Index k = 0; k < dimension; ++k) {
1649 for (
Index l = 0; l < dimension; ++l) {
1650 C(i,j,k,l) = A(i,j) * B(k,l);
1662template<
typename S,
typename T, Index N>
1664Tensor4<typename Promote<S, T>::type, N>
1675 for (
Index i = 0; i < dimension; ++i) {
1676 for (
Index j = 0; j < dimension; ++j) {
1677 for (
Index k = 0; k < dimension; ++k) {
1678 for (
Index l = 0; l < dimension; ++l) {
1679 C(i,j,k,l) = A(i,k) * B(j,l);
1691template<
typename S,
typename T, Index N>
1693Tensor4<typename Promote<S, T>::type, N>
1704 for (
Index i = 0; i < dimension; ++i) {
1705 for (
Index j = 0; j < dimension; ++j) {
1706 for (
Index k = 0; k < dimension; ++k) {
1707 for (
Index l = 0; l < dimension; ++l) {
1708 C(i,j,k,l) = A(i,l) * B(k,j);
1720template<
typename S,
typename T, Index N>
1722Tensor4<typename Promote<S, T>::type, N>
1733 for (
Index i = 0; i < dimension; ++i) {
1734 for (
Index j = 0; j < dimension; ++j) {
1735 for (
Index k = 0; k < dimension; ++k) {
1736 for (
Index l = 0; l < dimension; ++l) {
1738 typename Promote<S, T>::type
1741 for (
Index p = 0; p < dimension; ++p) {
1742 s += A(i,j,k,p) * B(p,l);
1756template<
typename S,
typename T, Index N>
1758Tensor4<typename Promote<S, T>::type, N>
1769 for (
Index i = 0; i < dimension; ++i) {
1770 for (
Index j = 0; j < dimension; ++j) {
1771 for (
Index k = 0; k < dimension; ++k) {
1772 for (
Index l = 0; l < dimension; ++l) {
1774 typename Promote<S, T>::type
1777 for (
Index p = 0; p < dimension; ++p) {
1778 s += A(i,j,k,p) * B(l,p);
1796template<
typename S,
typename T, Index N>
1798Tensor4<typename Promote<S, T>::type, N>
1809 for (
Index i = 0; i < dimension; ++i) {
1810 for (
Index j = 0; j < dimension; ++j) {
1811 for (
Index k = 0; k < dimension; ++k) {
1812 for (
Index l = 0; l < dimension; ++l) {
1814 typename Promote<S, T>::type
1817 for (
Index p = 0; p < dimension; ++p) {
1818 s += A(i,p) * B(p,j,k,l);
1832template<
typename S,
typename T, Index N>
1834Tensor4<typename Promote<S, T>::type, N>
1845 for (
Index i = 0; i < dimension; ++i) {
1846 for (
Index j = 0; j < dimension; ++j) {
1847 for (
Index k = 0; k < dimension; ++k) {
1848 for (
Index l = 0; l < dimension; ++l) {
1850 typename Promote<S, T>::type
1853 for (
Index p = 0; p < dimension; ++p) {
1854 s += A(p,i) * B(p,j,k,l);
1868template<
typename S,
typename T, Index N>
1870Tensor4<typename Promote<S, T>::type, N>
1881 for (
Index i = 0; i < dimension; ++i) {
1882 for (
Index j = 0; j < dimension; ++j) {
1883 for (
Index k = 0; k < dimension; ++k) {
1884 for (
Index l = 0; l < dimension; ++l) {
1886 typename Promote<S, T>::type
1889 for (
Index p = 0; p < dimension; ++p) {
1890 s += A(i,j,p,l) * B(p,k);
1904template<
typename S,
typename T, Index N>
1906Tensor4<typename Promote<S, T>::type, N>
1917 for (
Index i = 0; i < dimension; ++i) {
1918 for (
Index j = 0; j < dimension; ++j) {
1919 for (
Index k = 0; k < dimension; ++k) {
1920 for (
Index l = 0; l < dimension; ++l) {
1922 typename Promote<S, T>::type
1925 for (
Index p = 0; p < dimension; ++p) {
1926 s += A(i,j,p,l) * B(k,p);
1940template<
typename S,
typename T, Index N>
1942Tensor4<typename Promote<S, T>::type, N>
1953 for (
Index i = 0; i < dimension; ++i) {
1954 for (
Index j = 0; j < dimension; ++j) {
1955 for (
Index k = 0; k < dimension; ++k) {
1956 for (
Index l = 0; l < dimension; ++l) {
1958 typename Promote<S, T>::type
1961 for (
Index p = 0; p < dimension; ++p) {
1962 s += A(j,p) * B(i,p,k,l);
1976template<
typename S,
typename T, Index N>
1978Tensor4<typename Promote<S, T>::type, N>
1989 for (
Index i = 0; i < dimension; ++i) {
1990 for (
Index j = 0; j < dimension; ++j) {
1991 for (
Index k = 0; k < dimension; ++k) {
1992 for (
Index l = 0; l < dimension; ++l) {
1994 typename Promote<S, T>::type
1997 for (
Index p = 0; p < dimension; ++p) {
1998 s += A(p,j) * B(i,p,k,l);
2017template<
typename S,
typename T, Index N>
2019Tensor4<typename Promote<S, T>::type, N>
2030 for (
Index i = 0; i < dimension; ++i) {
2031 for (
Index j = 0; j < dimension; ++j) {
2032 for (
Index k = 0; k < dimension; ++k) {
2033 for (
Index l = 0; l < dimension; ++l) {
2034 C(i,j,k,l) = 0.5 * (A(i,k) * B(j,l) + A(i,l) * B(j,k));
2046template<
typename S,
typename T, Index N>
2048Tensor4<typename Promote<S, T>::type, N>
2059 for (
Index i = 0; i < dimension; ++i) {
2060 for (
Index j = 0; j < dimension; ++j) {
2061 for (
Index k = 0; k < dimension; ++k) {
2062 for (
Index l = 0; l < dimension; ++l) {
2064 typename Promote<S, T>::type
2070 for (
Index p = 0; p < dimension; ++p) {
2071 for (
Index q = 0; q < dimension; ++q) {
2072 for (
Index m = 0; m < dimension; ++m) {
2073 for (
Index n = 0; n < dimension; ++n) {
2074 s += A(p,i) * A(q,j) * A(m,k) * A(n,l) * B(p,q,m,n);
2094template<
typename T, Index N>
2101 for (
Index i = 0; i < dimension; ++i) {
2102 for (
Index j = 0; j < dimension; ++j) {
2103 for (
Index k = 0; k < dimension; ++k) {
2104 for (
Index l = 0; l < dimension; ++l) {
2120template<
typename T, Index N>
2127 if (dimension == 0) {
2131 os << std::scientific << std::setprecision(17);
2133 for (
Index i = 0; i < dimension; ++i) {
2135 for (
Index j = 0; j < dimension; ++j) {
2137 for (
Index k = 0; k < dimension; ++k) {
2139 os << std::setw(24) << A(i,j,k,0);
2141 for (
Index l = 1; l < dimension; ++l) {
2143 os <<
"," << std::setw(24) << A(i,j,k,l);
#define KOKKOS_INLINE_FUNCTION
#define MT_ERROR_EXIT(...)
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > operator+(Matrix< S, M, N > const &A, Matrix< T, M, N > const &B)
KOKKOS_INLINE_FUNCTION Tensor4< typename Promote< S, T >::type, N > kronecker(Tensor< S, N > const &A, Tensor4< T, N > const &B)
KOKKOS_INLINE_FUNCTION void minus(TensorBase< T, ST > const &A, TensorBase< T, ST > &B)
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > operator-(Matrix< S, M, N > const &A, Matrix< T, M, N > const &B)
KOKKOS_INLINE_FUNCTION Tensor4< T, N > const levi_civita_4()
std::ostream & operator<<(std::ostream &os, Matrix< T, M, N > const &A)
KOKKOS_INLINE_FUNCTION void add(TensorBase< R, SR > const &A, TensorBase< S, SS > const &B, TensorBase< T, ST > &C)
KOKKOS_INLINE_FUNCTION constexpr Index bound_dimension(Index const dimension)
KOKKOS_INLINE_FUNCTION Tensor4< typename Promote< S, T >::type, N > tensor2(Tensor< S, N > const &A, Tensor< T, N > const &B)
KOKKOS_INLINE_FUNCTION Tensor4(Index const dimension, T const *data_ptr)
KOKKOS_INLINE_FUNCTION T const & operator()(Index const i, Index const j, Index const k, Index const l) const
std::istream & operator>>(std::istream &is, Matrix< T, M, N > &A)
virtual KOKKOS_INLINE_FUNCTION ~Tensor4()
tensor4_store< T, N > Store
KOKKOS_INLINE_FUNCTION Tensor4(T const *data_ptr)
KOKKOS_INLINE_FUNCTION Tensor4(Tensor4< T, N > const &A)
KOKKOS_INLINE_FUNCTION Tensor4(Tensor< T, dimension_square< N >::value > const &A)
KOKKOS_INLINE_FUNCTION Tensor4(Index const dimension, Filler const value)
KOKKOS_INLINE_FUNCTION Tensor4< typename Promote< S, T >::type, N > odot(Tensor< S, N > const &A, Tensor< T, N > const &B)
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > operator/(Matrix< T, M, N > const &A, S const &s)
KOKKOS_INLINE_FUNCTION Vector< typename Promote< S, T >::type, M > operator*(Matrix< T, M, N > const &A, Vector< S, N > const &u)
KOKKOS_INLINE_FUNCTION Promote< S, T >::type dotdot(Matrix< S, M, N > const &A, Matrix< T, M, N > const &B)
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION Tensor4< typename Promote< S, T >::type, N > tensor3(Tensor< S, N > const &A, Tensor< T, N > const &B)
KOKKOS_INLINE_FUNCTION bool equal(TensorBase< T, ST > const &A, TensorBase< T, ST > const &B)
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION Index get_dimension(Index const order) const
KOKKOS_INLINE_FUNCTION void set_dimension(Index const dimension)
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > dot_t(Matrix< S, M, P > const &A, Matrix< T, N, P > const &B)
KOKKOS_INLINE_FUNCTION TensorBase()
KOKKOS_INLINE_FUNCTION void scale(TensorBase< R, SR > const &A, S const &s, TensorBase< T, ST > &B)
KOKKOS_INLINE_FUNCTION bool operator!=(Matrix< T, M, N > const &A, Matrix< T, M, N > const &B)
KOKKOS_INLINE_FUNCTION Tensor4()
KOKKOS_INLINE_FUNCTION Tensor4< T, N > const permutation_4()
KOKKOS_INLINE_FUNCTION Tensor4< typename Promote< S, T >::type, N > dot2_t(Tensor4< T, N > const &A, Tensor< S, N > const &B)
static constexpr Index value
KOKKOS_INLINE_FUNCTION bool operator==(Matrix< T, M, N > const &A, Matrix< T, M, N > const &B)
KOKKOS_INLINE_FUNCTION Vector< typename Promote< S, T >::type, M > dot(Matrix< T, M, N > const &A, Vector< S, N > const &u)
Storage< T, dimension_power< N, 4 >::value > tensor4_store
static KOKKOS_INLINE_FUNCTION constexpr Index get_order()
KOKKOS_INLINE_FUNCTION Tensor4< T, N > const alternator_4()
KOKKOS_INLINE_FUNCTION void split(TensorBase< R, SR > const &A, S const &s, TensorBase< T, ST > &B)
static constexpr Index ORDER
static constexpr bool IS_DYNAMIC
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > t_dot(Matrix< S, P, M > const &A, Matrix< T, P, N > const &B)
KOKKOS_INLINE_FUNCTION Tensor< typename Promote< S, T >::type, N > tensor(Vector< S, N > const &u, Vector< T, N > const &v)
KOKKOS_INLINE_FUNCTION Tensor4< T, N > const identity_2()
KOKKOS_INLINE_FUNCTION Tensor4< T, N > const identity_3()
KOKKOS_INLINE_FUNCTION bool not_equal(TensorBase< T, ST > const &A, TensorBase< T, ST > const &B)
KOKKOS_INLINE_FUNCTION Tensor4(Filler const value)
KOKKOS_INLINE_FUNCTION Tensor4< T, N > const identity_1()
KOKKOS_INLINE_FUNCTION void set_dimension(Index const dimension, Index const order)
KOKKOS_INLINE_FUNCTION T & operator()(Index const i, Index const j, Index const k, Index const l)
KOKKOS_INLINE_FUNCTION Tensor4(Index const dimension)
KOKKOS_INLINE_FUNCTION Tensor4< typename Promote< S, T >::type, N > t_dot2(Tensor< S, N > const &A, Tensor4< T, N > const &B)
KOKKOS_INLINE_FUNCTION Matrix< T, M, N > transpose(Matrix< T, N, M > const &A)
KOKKOS_INLINE_FUNCTION void divide(TensorBase< R, SR > const &A, S const &s, TensorBase< T, ST > &B)
KOKKOS_INLINE_FUNCTION Tensor< typename Promote< S, T >::type, N > dot2(Tensor3< T, N > const &A, Vector< S > const &u)
KOKKOS_INLINE_FUNCTION void subtract(TensorBase< R, SR > const &A, TensorBase< S, SS > const &B, TensorBase< T, ST > &C)
KOKKOS_INLINE_FUNCTION Tensor< T, N > inverse(Tensor< T, N > const &A)
constexpr Index DYNAMIC
Indicator for dynamic storage.
uint32_t Index
Indexing type.
KOKKOS_INLINE_FUNCTION T levi_civita(Index const i, Index const j)