MiniTensor Version of the Day
Loading...
Searching...
No Matches
MiniTensor_Tensor4.h
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MiniTensor Package
4//
5// Copyright 2016 NTESS and the MiniTensor contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#if !defined(MiniTensor_Tensor4_h)
11#define MiniTensor_Tensor4_h
12
13#include <iomanip>
14
15#include "MiniTensor_Tensor3.h"
16
17namespace minitensor {
18
21
25template<typename T, Index N>
27
31template<typename T, Index N = DYNAMIC>
32class Tensor4 : public TensorBase<T, tensor4_store<T, N>>
33{
34public:
35
39 static constexpr
40 Index
41 ORDER = 4;
42
46 static constexpr
47 bool
49
54
59 static constexpr
60 Index
62 {
63 return ORDER;
64 }
65
69 explicit
72
77 explicit
79 Tensor4(Index const dimension);
80
85 explicit
87 Tensor4(Filler const value);
88
94 explicit
96 Tensor4(Index const dimension, Filler const value);
97
102 explicit
104 Tensor4(T const * data_ptr);
105
111 explicit
113 Tensor4(Index const dimension, T const * data_ptr);
114
121
127
131 virtual
134
143 T const &
145 Index const i,
146 Index const j,
147 Index const k,
148 Index const l) const;
149
158 T &
160 Index const i,
161 Index const j,
162 Index const k,
163 Index const l);
164
169 Index
171
176 void
177 set_dimension(Index const dimension);
178
179};
180
187template<typename S, typename T, Index N>
190operator+(Tensor4<S, N> const & A, Tensor4<T, N> const & B);
191
198template<typename S, typename T, Index N>
201operator-(Tensor4<S, N> const & A, Tensor4<T, N> const & B);
202
207template<typename T, Index N>
210operator-(Tensor4<T, N> const & A);
211
216template<typename T, Index N>
218bool
219operator==(Tensor4<T, N> const & A, Tensor4<T, N> const & B);
220
225template<typename T, Index N>
227bool
228operator!=(Tensor4<T, N> const & A, Tensor4<T, N> const & B);
229
236template<typename S, typename T, Index N>
238typename lazy_disable_if< order_1234<S>, apply_tensor4< Promote<S,T>, N>>::type
239operator*(S const & s, Tensor4<T, N> const & A);
240
247template<typename S, typename T, Index N>
249typename lazy_disable_if< order_1234<S>, apply_tensor4< Promote<S,T>, N>>::type
250operator*(Tensor4<T, N> const & A, S const & s);
251
258template<typename S, typename T, Index N>
261operator/(Tensor4<T, N> const & A, S const & s);
262
269template<typename S, typename T, Index N>
272operator/(S const & s, Tensor4<T, N> const & A);
273
277template<typename T, Index N>
280transpose(Tensor4<T, N> const & A);
281
286template<typename T, Index N>
288Tensor4<T, N> const
289identity_1();
290
294template<typename T>
297identity_1(Index const dimension);
298
299template<typename T, Index N>
301Tensor4<T, N> const
302identity_1(Index const dimension);
303
308template<typename T, Index N>
310Tensor4<T, N> const
311identity_2();
312
316template<typename T>
319identity_2(Index const dimension);
320
321template<typename T, Index N>
323Tensor4<T, N> const
324identity_2(Index const dimension);
325
330template<typename T, Index N>
332Tensor4<T, N> const
333identity_3();
334
338template<typename T>
341identity_3(Index const dimension);
342
343template<typename T, Index N>
345Tensor4<T, N> const
346identity_3(Index const dimension);
347
351template<typename T, Index N>
353Tensor4<T, N> const
355
356template<typename T>
359levi_civita_4(Index const dimension);
360
361template<typename T, Index N>
363Tensor4<T, N> const
364levi_civita_4(Index const dimension);
365
369template<typename T, Index N>
371Tensor4<T, N> const
373
374template<typename T>
377permutation_4(Index const dimension);
378
379template<typename T, Index N>
381Tensor4<T, N> const
382permutation_4(Index const dimension);
383
387template<typename T, Index N>
389Tensor4<T, N> const
391
392template<typename T>
395alternator_4(Index const dimension);
396
397template<typename T, Index N>
399Tensor4<T, N> const
400alternator_4(Index const dimension);
401
406template<typename T, Index N>
409inverse(Tensor4<T, N> const & A);
410
417template<typename S, typename T, Index N>
420dot(Tensor4<T, N> const & A, Vector<S, N> const & u);
421
428template<typename S, typename T, Index N>
431dot(Vector<S, N> const & u, Tensor4<T, N> const & A);
432
439template<typename S, typename T, Index N>
442dot2(Tensor4<T, N> const & A, Vector<S, N> const & u);
443
450template<typename S, typename T, Index N>
453dot2(Vector<S, N> const & u, Tensor4<T, N> const & A);
454
461template<typename S, typename T, Index N>
464dotdot(Tensor4<T, N> const & A, Tensor<S, N> const & B);
465
472template<typename S, typename T, Index N>
475dotdot(Tensor<S, N> const & B, Tensor4<T, N> const & A);
476
483template<typename S, typename T, Index N>
486dotdot(Tensor4<S, N> const & A, Tensor4<T, N> const & B);
487
494template<typename S, typename T, Index N>
497tensor(Tensor<S, N> const & A, Tensor<T, N> const & B);
498
505template<typename S, typename T, Index N>
508tensor2(Tensor<S, N> const & A, Tensor<T, N> const & B);
509
516template<typename S, typename T, Index N>
519tensor3(Tensor<S, N> const & A, Tensor<T, N> const & B);
520
527template<typename S, typename T, Index N>
530dot(Tensor4<T, N> const & A, Tensor<S, N> const & B);
531
538template<typename S, typename T, Index N>
541dot_t(Tensor4<T, N> const & A, Tensor<S, N> const & B);
542
549template<typename S, typename T, Index N>
552dot(Tensor<S> const & A, Tensor4<T, N> const & B);
553
560template<typename S, typename T, Index N>
563t_dot(Tensor<S, N> const & A, Tensor4<T, N> const & B);
564
571template<typename S, typename T, Index N>
574dot2(Tensor4<T, N> const & A, Tensor<S, N> const & B);
575
582template<typename S, typename T, Index N>
585dot2_t(Tensor4<T, N> const & A, Tensor<S, N> const & B);
586
593template<typename S, typename T, Index N>
596dot2(Tensor<S, N> const & A, Tensor4<T, N> const & B);
597
604template<typename S, typename T, Index N>
607t_dot2(Tensor<S, N> const & A, Tensor4<T, N> const & B);
608
617template<typename S, typename T, Index N>
620odot(Tensor<S, N> const & A, Tensor<T, N> const & B);
621
633template<typename S, typename T, Index N>
636kronecker(Tensor<S, N> const & A, Tensor4<T, N> const & B);
637
644template<typename T, Index N>
645std::istream &
646operator>>(std::istream & is, Tensor4<T, N> & A);
647
654template<typename T, Index N>
655std::ostream &
656operator<<(std::ostream & os, Tensor4<T, N> const & A);
657
658} // namespace minitensor
659
660namespace minitensor
661{
662
663//
664// 4th-order tensor constructor with NaNs
665//
666template<typename T, Index N>
670{
671 set_dimension(N);
672 return;
673}
674
675template<typename T, Index N>
678TensorBase<T, Store>::TensorBase(dimension, ORDER)
679{
680 return;
681}
682
683//
684// 4th-order tensor constructor with a specified value
685//
686template<typename T, Index N>
689TensorBase<T, Store>::TensorBase(N, ORDER, value)
690{
691 return;
692}
693
694template<typename T, Index N>
696Tensor4<T, N>::Tensor4(Index const dimension, Filler const value) :
697TensorBase<T, Store>::TensorBase(dimension, ORDER, value)
698{
699 return;
700}
701
702//
703// Create 4th-order tensor from array
704//
705template<typename T, Index N>
707Tensor4<T, N>::Tensor4(T const * data_ptr) :
708TensorBase<T, Store>::TensorBase(N, ORDER, data_ptr)
709{
710 return;
711}
712
713template<typename T, Index N>
715Tensor4<T, N>::Tensor4(Index const dimension, T const * data_ptr) :
716TensorBase<T, Store>::TensorBase(dimension, ORDER, data_ptr)
717{
718 return;
719}
720
721//
722// Copy constructor
723//
724template<typename T, Index N>
728{
729 return;
730}
731
732//
733// 4th-order tensor from 2nd-order tensor
734//
735
736namespace {
737
739Index
740second_to_fourth_dimension(Index const dimension_2nd)
741{
742 Index
743 dimension_4th = 0;
744
745 switch (dimension_2nd) {
746
747 default:
748 MT_ERROR_EXIT("Invalid dimension for 2nd-order tensor.");
749 break;
750
751 case 1:
752 dimension_4th = 1;
753 break;
754
755 case 4:
756 dimension_4th = 2;
757 break;
758
759 case 9:
760 dimension_4th = 3;
761 break;
762
763 case 16:
764 dimension_4th = 4;
765 break;
766
767 }
768
769 return dimension_4th;
770}
771
772} //anonymous namespace
773
774template<typename T, Index N>
777{
778 Index const
779 dimension_2nd = A.get_dimension();
780
781 Index const
782 dimension_4th = second_to_fourth_dimension(dimension_2nd);
783
785 self = (*this);
786
787 self.set_dimension(dimension_4th);
788
789 Index const
790 number_components = dimension_2nd * dimension_2nd;
791
792 for (Index i = 0; i < number_components; ++i) {
793 self[i] = A[i];
794 }
795
796 return;
797}
798//
799// 4th-order tensor simple destructor
800//
801template<typename T, Index N>
804{
805 return;
806}
807
808//
809// Get dimension
810//
811template<typename T, Index N>
813Index
818
819//
820// Set dimension
821//
822template<typename T, Index N>
824void
826{
828 return;
829}
830
831//
832// 4th-order tensor addition
833//
834template<typename S, typename T, Index N>
838{
840 C(A.get_dimension());
841
842 add(A, B, C);
843
844 return C;
845}
846
847//
848// 4th-order tensor subtraction
849//
850template<typename S, typename T, Index N>
852Tensor4<typename Promote<S, T>::type, N>
854{
856 C(A.get_dimension());
857
858 subtract(A, B, C);
859
860 return C;
861}
862
863//
864// 4th-order tensor minus
865//
866template<typename T, Index N>
868Tensor4<T, N>
870{
872 B(A.get_dimension());
873
874 minus(A, B);
875
876 return B;
877}
878
879//
880// 4th-order equality
881//
882template<typename T, Index N>
884bool
886{
887 return equal(A, B);
888}
889
890//
891// 4th-order inequality
892//
893template<typename T, Index N>
895bool
897{
898 return not_equal(A, B);
899}
900
901//
902// Scalar 4th-order tensor product
903//
904template<typename S, typename T, Index N>
906typename lazy_disable_if< order_1234<S>, apply_tensor4< Promote<S,T>, N>>::type
907operator*(S const & s, Tensor4<T, N> const & A)
908{
910 B(A.get_dimension());
911
912 scale(A, s, B);
913
914 return B;
915}
916
917//
918// 4th-order tensor scalar product
919//
920template<typename S, typename T, Index N>
922typename lazy_disable_if< order_1234<S>, apply_tensor4< Promote<S,T>, N>>::type
923operator*(Tensor4<T, N> const & A, S const & s)
924{
926 B(A.get_dimension());
927
928 scale(A, s, B);
929
930 return B;
931}
932
933//
934// 4th-order tensor scalar division
935//
936template<typename S, typename T, Index N>
938Tensor4<typename Promote<S, T>::type, N>
939operator/(Tensor4<T, N> const & A, S const & s)
940{
942 B(A.get_dimension());
943
944 divide(A, s, B);
945
946 return B;
947}
948
949//
950// 4th-order scalar tensor division
951//
952template<typename S, typename T, Index N>
954Tensor4<typename Promote<S, T>::type, N>
955operator/(S const & s, Tensor4<T, N> const & A)
956{
958 B(A.get_dimension());
959
960 split(A, s, B);
961
962 return B;
963}
964
965//
966// Indexing for constant 4th order tensor
967// \param i index
968// \param j index
969// \param k index
970// \param l index
971//
972template<typename T, Index N>
974T const &
976 Index const i, Index const j, Index const k, Index const l) const
977{
978 Tensor4<T, N> const &
979 self = (*this);
980
981 Index const
982 dimension = self.get_dimension();
983
984 return self[((i * dimension + j) * dimension + k) * dimension + l];
985}
986
987//
988// 4th-order tensor indexing
989// \param i index
990// \param j index
991// \param k index
992// \param l index
993//
994template<typename T, Index N>
996T &
998 Index const i, Index const j, Index const k, Index const l)
999{
1001 self = (*this);
1002
1003 Index const
1004 dimension = self.get_dimension();
1005
1006 return self[((i * dimension + j) * dimension + k) * dimension + l];
1007}
1008
1009//
1010// 4th-order inverse
1011//
1012template<typename T, Index N>
1019
1020} // namespace minitensor
1021namespace minitensor {
1022
1023namespace {
1024
1025template< typename T, Index N>
1027void ones_in_ikjl(Tensor4<T, N> & A)
1028{
1029
1030 Index const
1031 dimension = A.get_dimension();
1032
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) {
1038 A(i,j,k,l) = 1;
1039 }
1040 }
1041 }
1042 }
1043 }
1044
1045 return;
1046}
1047
1048template< typename T, Index N>
1050void ones_in_iljk(Tensor4<T, N> & A)
1051{
1052
1053 Index const
1054 dimension = A.get_dimension();
1055
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) {
1061 A(i,j,k,l) = 1;
1062 }
1063 }
1064 }
1065 }
1066 }
1067
1068 return;
1069}
1070
1071template< typename T, Index N>
1073void ones_in_ijkl(Tensor4<T, N> & A)
1074{
1075
1076 Index const
1077 dimension = A.get_dimension();
1078
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) {
1084 A(i,j,k,l) = 1;
1085 }
1086 }
1087 }
1088 }
1089 }
1090
1091 return;
1092}
1093
1094template<typename T, Index N>
1096void fill_levi_civita(Tensor4<T, N> & A)
1097{
1098 Index const
1099 dimension = A.get_dimension();
1100
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) {
1105 A(i, j, k, l) = levi_civita<T>(i, j, k, l);
1106 }
1107 }
1108 }
1109 }
1110
1111 return;
1112}
1113
1114} // anonymous namespace
1115
1116//
1117// 4th-order identity I1
1118// \return \f$ \delta_{ik} \delta_{jl} \f$ such that \f$ A = I_1 A \f$
1119//
1120template<typename T, Index N>
1122Tensor4<T, N> const
1124{
1126 ones_in_ikjl(I);
1127 return I;
1128}
1129
1130template<typename T>
1132const Tensor4<T, DYNAMIC>
1133identity_1(Index const dimension)
1134{
1135 Tensor4<T, DYNAMIC> I(dimension, Filler::ZEROS);
1136 ones_in_ikjl(I);
1137 return I;
1138}
1139
1143template<typename T, Index N>
1145Tensor4<T, N> const
1146identity_1(Index const dimension)
1147{
1148 if (N != DYNAMIC) assert(dimension == N);
1149
1150 Tensor4<T, N> I(dimension, Filler::ZEROS);
1151 ones_in_ikjl(I);
1152 return I;
1153}
1154
1155//
1156// 4th-order identity I2
1157// \return \f$ \delta_{il} \delta_{jk} \f$ such that \f$ A^T = I_2 A \f$
1158//
1159template<typename T, Index N>
1161Tensor4<T, N> const
1163{
1165 ones_in_iljk(I);
1166 return I;
1167}
1168
1169template<typename T>
1171const Tensor4<T, DYNAMIC>
1172identity_2(Index const dimension)
1173{
1174 Tensor4<T, DYNAMIC> I(dimension, Filler::ZEROS);
1175 ones_in_iljk(I);
1176 return I;
1177}
1178
1182template<typename T, Index N>
1184Tensor4<T, N> const
1185identity_2(Index const dimension)
1186{
1187 if (N != DYNAMIC) assert(dimension == N);
1188
1189 Tensor4<T, N> I(dimension, Filler::ZEROS);
1190 ones_in_iljk(I);
1191 return I;
1192}
1193
1194//
1195// 4th-order identity I3
1196// \return \f$ \delta_{ij} \delta_{kl} \f$ such that \f$ I_A I = I_3 A \f$
1197//
1198template<typename T, Index N>
1200Tensor4<T, N> const
1202{
1204 ones_in_ijkl(I);
1205 return I;
1206}
1207
1208template<typename T>
1210const Tensor4<T, DYNAMIC>
1211identity_3(Index const dimension)
1212{
1213 Tensor4<T, DYNAMIC> I(dimension, Filler::ZEROS);
1214 ones_in_ijkl(I);
1215 return I;
1216}
1217
1221template<typename T, Index N>
1223Tensor4<T, N> const
1224identity_3(Index const dimension)
1225{
1226 Tensor4<T, N> I(dimension, Filler::ZEROS);
1227 ones_in_ijkl(I);
1228 return I;
1229}
1230
1231//
1232// Levi-Civita symbol
1233//
1234template<typename T, Index N>
1236Tensor4<T, N> const
1238{
1240 A(N, Filler::ZEROS);
1241
1242 fill_levi_civita(A);
1243
1244 return A;
1245}
1246
1250template<typename T>
1252Tensor4<T, DYNAMIC> const
1253levi_civita_4(Index const dimension)
1254{
1256 A(dimension, Filler::ZEROS);
1257
1258 fill_levi_civita(A);
1259
1260 return A;
1261}
1262
1266template<typename T, Index N>
1268Tensor4<T, N> const
1269levi_civita_4(Index const dimension)
1270{
1271 if (N != DYNAMIC) assert(dimension == N);
1272
1274 A(dimension, Filler::ZEROS);
1275
1276 fill_levi_civita(A);
1277
1278 return A;
1279}
1280
1281//
1282// Permutation symbol
1283//
1284template<typename T, Index N>
1286Tensor4<T, N> const
1288{
1289 return levi_civita_4<T, N>();
1290}
1291
1295template<typename T>
1297Tensor4<T, DYNAMIC> const
1298permutation_4(Index const dimension)
1299{
1300 return levi_civita_4<T>(dimension);
1301}
1302
1306template<typename T, Index N>
1308Tensor4<T, N> const
1309permutation_4(Index const dimension)
1310{
1311 return levi_civita_4<T, N>(dimension);
1312}
1313
1314//
1315// Alternating symbol
1316//
1317template<typename T, Index N>
1319Tensor4<T, N> const
1321{
1322 return levi_civita_4<T, N>();
1323}
1324
1328template<typename T>
1330Tensor4<T, DYNAMIC> const
1331alternator_4(Index const dimension)
1332{
1333 return levi_civita_4<T>(dimension);
1334}
1335
1336
1340template<typename T, Index N>
1342Tensor4<T, N> const
1343alternator_4(Index const dimension)
1344{
1345 return levi_civita_4<T, N>(dimension);
1346}
1347
1348//
1349// 4th-order tensor transpose
1350// per Holzapfel 1.157
1351//
1352template<typename T, Index N>
1354Tensor4<T, N>
1356{
1357 Index const
1358 dimension = A.get_dimension();
1359
1361 B(dimension);
1362
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);
1368 }
1369 }
1370 }
1371 }
1372
1373 return B;
1374}
1375
1376//
1377// 4th-order tensor vector dot product
1378// \param A 4th-order tensor
1379// \param u vector
1380// \return 3rd-order tensor \f$ B = A \cdot u := B_{ijk}=A_{ijkp} u_{p} \f$
1381//
1382template<typename S, typename T, Index N>
1384Tensor3<typename Promote<S, T>::type, N>
1385dot(Tensor4<T, N> const & A, Vector<S, N> const & u)
1386{
1387 Index const
1388 dimension= A.get_dimension();
1389
1390 assert(u.get_dimension() == dimension);
1391
1393 B(dimension);
1394
1395 for (Index i = 0; i < dimension; ++i) {
1396 for (Index j = 0; j < dimension; ++j) {
1397 for (Index k = 0; k < dimension; ++k) {
1398
1399 typename Promote<S, T>::type
1400 s = 0.0;
1401
1402 for (Index p = 0; p < dimension; ++p) {
1403 s += A(i,j,k,p) * u(p);
1404 }
1405 B(i,j,k) = s;
1406 }
1407 }
1408 }
1409
1410 return B;
1411}
1412
1413//
1414// vector 4th-order tensor dot product
1415// \param A 4th-order tensor
1416// \param u vector
1417// \return 3rd-order tensor \f$ u dot A \f$ as \f$ B_{ijk}=u_{p} A_{pijk} \f$
1418//
1419template<typename S, typename T, Index N>
1421Tensor3<typename Promote<S, T>::type, N>
1422dot(Vector<S, N> const & u, Tensor4<T, N> const & A)
1423{
1424 Index const
1425 dimension = A.get_dimension();
1426
1427 assert(u.get_dimension() == dimension);
1428
1430 B(dimension);
1431
1432 for (Index i = 0; i < dimension; ++i) {
1433 for (Index j = 0; j < dimension; ++j) {
1434 for (Index k = 0; k < dimension; ++k) {
1435
1436 typename Promote<S, T>::type
1437 s = 0.0;
1438
1439 for (Index p = 0; p < dimension; ++p) {
1440 s += u(p) * A(p,i,j,k);
1441 }
1442 B(i,j,k) = s;
1443 }
1444 }
1445 }
1446
1447 return B;
1448}
1449
1450//
1451// 4th-order tensor vector dot2 product
1452// \param A 4th-order tensor
1453// \param u vector
1454// \return 3rd-order tensor \f$ B = A \cdot u := B_{ijk} = A_{ijpk} u_{p} \f$
1455//
1456template<typename S, typename T, Index N>
1458Tensor3<typename Promote<S, T>::type, N>
1459dot2(Tensor4<T, N> const & A, Vector<S, N> const & u)
1460{
1461 Index const
1462 dimension = A.get_dimension();
1463
1464 assert(u.get_dimension() == dimension);
1465
1467 B(dimension);
1468
1469 for (Index i = 0; i < dimension; ++i) {
1470 for (Index j = 0; j < dimension; ++j) {
1471 for (Index k = 0; k < dimension; ++k) {
1472
1473 typename Promote<S, T>::type
1474 s = 0.0;
1475
1476 for (Index p = 0; p < dimension; ++p) {
1477 s += A(i,j,p,k) * u(p);
1478 }
1479 B(i,j,k) = s;
1480 }
1481 }
1482 }
1483
1484 return B;
1485}
1486
1487//
1488// vector 4th-order tensor dot2 product
1489// \param A 4th-order tensor
1490// \param u vector
1491// \return 3rd-order tensor \f$ u dot2 A \f$ as \f$ B_{ijk}=u_{p} A_{ipjk} \f$
1492//
1493template<typename S, typename T, Index N>
1495Tensor3<typename Promote<S, T>::type, N>
1496dot2(Vector<S, N> const & u, Tensor4<T, N> const & A)
1497{
1498 Index const
1499 dimension = A.get_dimension();
1500
1501 assert(u.get_dimension() == dimension);
1502
1504 B(dimension);
1505
1506 for (Index i = 0; i < dimension; ++i) {
1507 for (Index j = 0; j < dimension; ++j) {
1508 for (Index k = 0; k < dimension; ++k) {
1509
1510 typename Promote<S, T>::type
1511 s = 0.0;
1512
1513 for (Index p = 0; p < dimension; ++p) {
1514 s += u(p) * A(i,p,j,k);
1515 }
1516 B(i,j,k) = s;
1517 }
1518 }
1519 }
1520
1521 return B;
1522}
1523
1524//
1525// \return 2nd-order tensor \f$ C = A : B := C_{ij} = A_{ijpq} B_{pq} \f$
1526//
1527template<typename S, typename T, Index N>
1529Tensor<typename Promote<S, T>::type, N>
1530dotdot(Tensor4<T, N> const & A, Tensor<S, N> const & B)
1531{
1532 Index const
1533 dimension = A.get_dimension();
1534
1535 assert(B.get_dimension() == dimension);
1536
1538 C(dimension);
1539
1540 for (Index i = 0; i < dimension; ++i) {
1541 for (Index j = 0; j < dimension; ++j) {
1542
1543 typename Promote<S, T>::type
1544 s = 0.0;
1545
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);
1549 }
1550 }
1551 C(i,j) = s;
1552 }
1553 }
1554
1555 return C;
1556}
1557
1558//
1559// \return 2nd-order tensor \f$ C = B : A := C_{ij} = B_{pq} A_{pqij} \f$
1560//
1561template<typename S, typename T, Index N>
1563Tensor<typename Promote<S, T>::type, N>
1564dotdot(Tensor<S, N> const & B, Tensor4<T, N> const & A)
1565{
1566 Index const
1567 dimension = A.get_dimension();
1568
1569 assert(B.get_dimension() == dimension);
1570
1572 C(dimension);
1573
1574 for (Index i = 0; i < dimension; ++i) {
1575 for (Index j = 0; j < dimension; ++j) {
1576
1577 typename Promote<S, T>::type
1578 s = 0.0;
1579
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);
1583 }
1584 }
1585 C(i,j) = s;
1586 }
1587 }
1588
1589 return C;
1590}
1591
1592//
1593// \return \f$ C = A : B := C_{ijkl} = A_{ijpq} B{pqkl} \f$
1594//
1595template<typename S, typename T, Index N>
1597Tensor4<typename Promote<S, T>::type, N>
1599{
1600 Index const
1601 dimension = A.get_dimension();
1602
1603 assert(B.get_dimension() == dimension);
1604
1606 C(dimension);
1607
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) {
1612
1613 typename Promote<S, T>::type
1614 s = 0.0;
1615
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);
1619 }
1620 }
1621 C(i,j,k,l) = s;
1622 }
1623 }
1624 }
1625 }
1626
1627 return C;
1628}
1629
1630//
1631// \return \f$ C = A \otimes B := C_{ijkl} = A_{ij} B_{kl} \f$
1632//
1633template<typename S, typename T, Index N>
1635Tensor4<typename Promote<S, T>::type, N>
1636tensor(Tensor<S, N> const & A, Tensor<T, N> const & B)
1637{
1638 Index const
1639 dimension = A.get_dimension();
1640
1641 assert(B.get_dimension() == dimension);
1642
1644 C(dimension);
1645
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);
1651 }
1652 }
1653 }
1654 }
1655
1656 return C;
1657}
1658
1659//
1660// \return \f$ C_{ijkl} = A_{ik} B_{jl} \f$
1661//
1662template<typename S, typename T, Index N>
1664Tensor4<typename Promote<S, T>::type, N>
1665tensor2(Tensor<S, N> const & A, Tensor<T, N> const & B)
1666{
1667 Index const
1668 dimension = A.get_dimension();
1669
1670 assert(B.get_dimension() == dimension);
1671
1673 C(dimension);
1674
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);
1680 }
1681 }
1682 }
1683 }
1684
1685 return C;
1686}
1687
1688//
1689// \return \f$ C_{ijkl} = A_{il} B_{kj} \f$
1690//
1691template<typename S, typename T, Index N>
1693Tensor4<typename Promote<S, T>::type, N>
1694tensor3(Tensor<S, N> const & A, Tensor<T, N> const & B)
1695{
1696 Index const
1697 dimension = A.get_dimension();
1698
1699 assert(B.get_dimension() == dimension);
1700
1702 C(dimension);
1703
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);
1709 }
1710 }
1711 }
1712 }
1713
1714 return C;
1715}
1716
1717//
1718// \return \f$ C = A \cdot B := C_{ijkl} = A_{ijkp} B_{pl} \f$
1719//
1720template<typename S, typename T, Index N>
1722Tensor4<typename Promote<S, T>::type, N>
1723dot(Tensor4<T, N> const & A, Tensor<S, N> const & B)
1724{
1725 Index const
1726 dimension = A.get_dimension();
1727
1728 assert(B.get_dimension() == dimension);
1729
1731 C(dimension);
1732
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) {
1737
1738 typename Promote<S, T>::type
1739 s = 0.0;
1740
1741 for (Index p = 0; p < dimension; ++p) {
1742 s += A(i,j,k,p) * B(p,l);
1743 }
1744 C(i,j,k,l) = s;
1745 }
1746 }
1747 }
1748 }
1749
1750 return C;
1751}
1752
1753//
1754// \return \f$ C = A \cdot B^T := C_{ijkl} = A_{ijkp} B_{lp} \f$
1755//
1756template<typename S, typename T, Index N>
1758Tensor4<typename Promote<S, T>::type, N>
1759dot_t(Tensor4<T, N> const & A, Tensor<S, N> const & B)
1760{
1761 Index const
1762 dimension = A.get_dimension();
1763
1764 assert(B.get_dimension() == dimension);
1765
1767 C(dimension);
1768
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) {
1773
1774 typename Promote<S, T>::type
1775 s = 0.0;
1776
1777 for (Index p = 0; p < dimension; ++p) {
1778 s += A(i,j,k,p) * B(l,p);
1779 }
1780 C(i,j,k,l) = s;
1781 }
1782 }
1783 }
1784 }
1785
1786 return C;
1787}
1788
1789//
1790// \return \f$ C = A \cdot B := C_{ijkl} = A_{ip} B_{pjkl} \f$
1791//
1796template<typename S, typename T, Index N>
1798Tensor4<typename Promote<S, T>::type, N>
1799dot(Tensor<S, N> const & A, Tensor4<T, N> const & B)
1800{
1801 Index const
1802 dimension = A.get_dimension();
1803
1804 assert(B.get_dimension() == dimension);
1805
1807 C(dimension);
1808
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) {
1813
1814 typename Promote<S, T>::type
1815 s = 0.0;
1816
1817 for (Index p = 0; p < dimension; ++p) {
1818 s += A(i,p) * B(p,j,k,l);
1819 }
1820 C(i,j,k,l) = s;
1821 }
1822 }
1823 }
1824 }
1825
1826 return C;
1827}
1828
1829//
1830// \return \f$ C = A^T \cdot B := C_{ijkl} = A_{pi} B_{pjkl} \f$
1831//
1832template<typename S, typename T, Index N>
1834Tensor4<typename Promote<S, T>::type, N>
1835t_dot(Tensor<S, N> const & A, Tensor4<T, N> const & B)
1836{
1837 Index const
1838 dimension = A.get_dimension();
1839
1840 assert(B.get_dimension() == dimension);
1841
1843 C(dimension);
1844
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) {
1849
1850 typename Promote<S, T>::type
1851 s = 0.0;
1852
1853 for (Index p = 0; p < dimension; ++p) {
1854 s += A(p,i) * B(p,j,k,l);
1855 }
1856 C(i,j,k,l) = s;
1857 }
1858 }
1859 }
1860 }
1861
1862 return C;
1863}
1864
1865//
1866// \return \f$ C = A \cdot B := C_{ijkl} = A_{ijpl} B_{pk} \f$
1867//
1868template<typename S, typename T, Index N>
1870Tensor4<typename Promote<S, T>::type, N>
1871dot2(Tensor4<T, N> const & A, Tensor<S, N> const & B)
1872{
1873 Index const
1874 dimension = A.get_dimension();
1875
1876 assert(B.get_dimension() == dimension);
1877
1879 C(dimension);
1880
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) {
1885
1886 typename Promote<S, T>::type
1887 s = 0.0;
1888
1889 for (Index p = 0; p < dimension; ++p) {
1890 s += A(i,j,p,l) * B(p,k);
1891 }
1892 C(i,j,k,l) = s;
1893 }
1894 }
1895 }
1896 }
1897
1898 return C;
1899}
1900
1901//
1902// \return \f$ C = A \cdot B^T := C_{ijkl} = A_{ijpl} B_{kp} \f$
1903//
1904template<typename S, typename T, Index N>
1906Tensor4<typename Promote<S, T>::type, N>
1907dot2_t(Tensor4<T, N> const & A, Tensor<S, N> const & B)
1908{
1909 Index const
1910 dimension = A.get_dimension();
1911
1912 assert(B.get_dimension() == dimension);
1913
1915 C(dimension);
1916
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) {
1921
1922 typename Promote<S, T>::type
1923 s = 0.0;
1924
1925 for (Index p = 0; p < dimension; ++p) {
1926 s += A(i,j,p,l) * B(k,p);
1927 }
1928 C(i,j,k,l) = s;
1929 }
1930 }
1931 }
1932 }
1933
1934 return C;
1935}
1936
1937//
1938// \return \f$ C = A \cdot B := C_{ijkl} = A_{jp} B_{ipkl} \f$
1939//
1940template<typename S, typename T, Index N>
1942Tensor4<typename Promote<S, T>::type, N>
1943dot2(Tensor<S, N> const & A, Tensor4<T, N> const & B)
1944{
1945 Index const
1946 dimension = A.get_dimension();
1947
1948 assert(B.get_dimension() == dimension);
1949
1951 C(dimension);
1952
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) {
1957
1958 typename Promote<S, T>::type
1959 s = 0.0;
1960
1961 for (Index p = 0; p < dimension; ++p) {
1962 s += A(j,p) * B(i,p,k,l);
1963 }
1964 C(i,j,k,l) = s;
1965 }
1966 }
1967 }
1968 }
1969
1970 return C;
1971}
1972
1973//
1974// \return \f$ C = A^T \cdot B := C_{ijkl} = A_{pj} B_{ipkl} \f$
1975//
1976template<typename S, typename T, Index N>
1978Tensor4<typename Promote<S, T>::type, N>
1979t_dot2(Tensor<S, N> const & A, Tensor4<T, N> const & B)
1980{
1981 Index const
1982 dimension = A.get_dimension();
1983
1984 assert(B.get_dimension() == dimension);
1985
1987 C(dimension);
1988
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) {
1993
1994 typename Promote<S, T>::type
1995 s = 0.0;
1996
1997 for (Index p = 0; p < dimension; ++p) {
1998 s += A(p,j) * B(i,p,k,l);
1999 }
2000 C(i,j,k,l) = s;
2001 }
2002 }
2003 }
2004 }
2005
2006 return C;
2007}
2008
2009//
2010// odot operator useful for \f$ \frac{\partial A^{-1}}{\partial A} \f$
2011// see Holzapfel eqn 6.165
2012// \param A 2nd-order tensor
2013// \param B 2nd-order tensor
2014// \return \f$ A \odot B \f$ which is
2015// \f$ C_{ijkl} = \frac{1}{2}(A_{ik} B_{jl} + A_{il} B_{jk}) \f$
2016//
2017template<typename S, typename T, Index N>
2019Tensor4<typename Promote<S, T>::type, N>
2020odot(Tensor<S, N> const & A, Tensor<T, N> const & B)
2021{
2022 Index const
2023 dimension = A.get_dimension();
2024
2025 assert(B.get_dimension() == dimension);
2026
2028 C(dimension);
2029
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));
2035 }
2036 }
2037 }
2038 }
2039
2040 return C;
2041}
2042
2043//
2044// \return \f$ C_{ijkl} = A_{pi} A_{qj} A_{mk} A_{nl} B_{pqmn} \f$
2045//
2046template<typename S, typename T, Index N>
2048Tensor4<typename Promote<S, T>::type, N>
2050{
2051 Index const
2052 dimension = A.get_dimension();
2053
2054 assert(B.get_dimension() == dimension);
2055
2057 C(dimension);
2058
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) {
2063
2064 typename Promote<S, T>::type
2065 s = 0.0;
2066
2067 // we assume A is the direction cosine matrix
2068 // have s_{i}\be_{i} = s_{i'}\be_{i'}, want s_{i}
2069 // s_{i} = A_{i',i}s_{i'}
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);
2075 }
2076 }
2077 }
2078 }
2079 C(i,j,k,l) = s;
2080 }
2081 }
2082 }
2083 }
2084
2085 return C;
2086}
2087
2088//
2089// 4th-order input
2090// \param A 4th-order tensor
2091// \param is input stream
2092// \return is input stream
2093//
2094template<typename T, Index N>
2095std::istream &
2096operator>>(std::istream & is, Tensor4<T, N> & A)
2097{
2098 Index const
2099 dimension = A.get_dimension();
2100
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) {
2105 is >> A(i,j,k,l);
2106 }
2107 }
2108 }
2109 }
2110
2111 return is;
2112}
2113
2114//
2115// 4th-order output
2116// \param A 4th-order tensor
2117// \param os output stream
2118// \return os output stream
2119//
2120template<typename T, Index N>
2121std::ostream &
2122operator<<(std::ostream & os, Tensor4<T, N> const & A)
2123{
2124 Index const
2125 dimension = A.get_dimension();
2126
2127 if (dimension == 0) {
2128 return os;
2129 }
2130
2131 os << std::scientific << std::setprecision(17);
2132
2133 for (Index i = 0; i < dimension; ++i) {
2134
2135 for (Index j = 0; j < dimension; ++j) {
2136
2137 for (Index k = 0; k < dimension; ++k) {
2138
2139 os << std::setw(24) << A(i,j,k,0);
2140
2141 for (Index l = 1; l < dimension; ++l) {
2142
2143 os << "," << std::setw(24) << A(i,j,k,l);
2144 }
2145
2146 os << std::endl;
2147
2148 }
2149
2150 os << std::endl;
2151 os << std::endl;
2152
2153 }
2154
2155 os << std::endl;
2156
2157 }
2158
2159 return os;
2160}
2161
2163} // namespace minitensor
2164
2165#endif //MiniTensor_Tensor4_h
#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 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)
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)
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)