File indexing completed on 2025-04-19 09:09:49
0001 #ifndef ATOOLS_Math_Lorentz_Ten4_H
0002 #define ATOOLS_Math_Lorentz_Ten4_H
0003
0004 #include "ATOOLS/Math/MathTools.H"
0005
0006 namespace ATOOLS {
0007 template<typename Scalar> class Lorentz_Ten3;
0008
0009 template<typename Scalar>
0010 class Lorentz_Ten4 {
0011 Scalar m_x[4][4][4][4];
0012 public:
0013 inline Lorentz_Ten4() {}
0014 inline Lorentz_Ten4(const Scalar& s) {
0015 for (unsigned short int i=0; i<4; ++i)
0016 for (unsigned short int j=0; j<4; ++j)
0017 for (unsigned short int k=0; k<4; ++k)
0018 for (unsigned short int l=0; l<4; ++l)
0019 m_x[i][j][k][l] = s;
0020 }
0021 template<typename Scalar2>
0022 inline Lorentz_Ten4(const Lorentz_Ten4<Scalar2> & ten) {
0023 for (unsigned short int i=0; i<4; ++i)
0024 for (unsigned short int j=0; j<4; ++j)
0025 for (unsigned short int k=0; k<4; ++k)
0026 for (unsigned short int l=0; l<4; ++l)
0027 m_x[i][j][k][l] = ten.at(i,j,k,l);
0028 }
0029 inline Lorentz_Ten4(
0030 const Scalar& x0000, const Scalar& x1000, const Scalar& x2000, const Scalar& x3000,
0031 const Scalar& x0100, const Scalar& x1100, const Scalar& x2100, const Scalar& x3100,
0032 const Scalar& x0200, const Scalar& x1200, const Scalar& x2200, const Scalar& x3200,
0033 const Scalar& x0300, const Scalar& x1300, const Scalar& x2300, const Scalar& x3300,
0034
0035 const Scalar& x0010, const Scalar& x1010, const Scalar& x2010, const Scalar& x3010,
0036 const Scalar& x0110, const Scalar& x1110, const Scalar& x2110, const Scalar& x3110,
0037 const Scalar& x0210, const Scalar& x1210, const Scalar& x2210, const Scalar& x3210,
0038 const Scalar& x0310, const Scalar& x1310, const Scalar& x2310, const Scalar& x3310,
0039
0040 const Scalar& x0020, const Scalar& x1020, const Scalar& x2020, const Scalar& x3020,
0041 const Scalar& x0120, const Scalar& x1120, const Scalar& x2120, const Scalar& x3120,
0042 const Scalar& x0220, const Scalar& x1220, const Scalar& x2220, const Scalar& x3220,
0043 const Scalar& x0320, const Scalar& x1320, const Scalar& x2320, const Scalar& x3320,
0044
0045 const Scalar& x0030, const Scalar& x1030, const Scalar& x2030, const Scalar& x3030,
0046 const Scalar& x0130, const Scalar& x1130, const Scalar& x2130, const Scalar& x3130,
0047 const Scalar& x0230, const Scalar& x1230, const Scalar& x2230, const Scalar& x3230,
0048 const Scalar& x0330, const Scalar& x1330, const Scalar& x2330, const Scalar& x3330,
0049
0050 const Scalar& x0001, const Scalar& x1001, const Scalar& x2001, const Scalar& x3001,
0051 const Scalar& x0101, const Scalar& x1101, const Scalar& x2101, const Scalar& x3101,
0052 const Scalar& x0201, const Scalar& x1201, const Scalar& x2201, const Scalar& x3201,
0053 const Scalar& x0301, const Scalar& x1301, const Scalar& x2301, const Scalar& x3301,
0054
0055 const Scalar& x0011, const Scalar& x1011, const Scalar& x2011, const Scalar& x3011,
0056 const Scalar& x0111, const Scalar& x1111, const Scalar& x2111, const Scalar& x3111,
0057 const Scalar& x0211, const Scalar& x1211, const Scalar& x2211, const Scalar& x3211,
0058 const Scalar& x0311, const Scalar& x1311, const Scalar& x2311, const Scalar& x3311,
0059
0060 const Scalar& x0021, const Scalar& x1021, const Scalar& x2021, const Scalar& x3021,
0061 const Scalar& x0121, const Scalar& x1121, const Scalar& x2121, const Scalar& x3121,
0062 const Scalar& x0221, const Scalar& x1221, const Scalar& x2221, const Scalar& x3221,
0063 const Scalar& x0321, const Scalar& x1321, const Scalar& x2321, const Scalar& x3321,
0064
0065 const Scalar& x0031, const Scalar& x1031, const Scalar& x2031, const Scalar& x3031,
0066 const Scalar& x0131, const Scalar& x1131, const Scalar& x2131, const Scalar& x3131,
0067 const Scalar& x0231, const Scalar& x1231, const Scalar& x2231, const Scalar& x3231,
0068 const Scalar& x0331, const Scalar& x1331, const Scalar& x2331, const Scalar& x3331,
0069
0070 const Scalar& x0002, const Scalar& x1002, const Scalar& x2002, const Scalar& x3002,
0071 const Scalar& x0102, const Scalar& x1102, const Scalar& x2102, const Scalar& x3102,
0072 const Scalar& x0202, const Scalar& x1202, const Scalar& x2202, const Scalar& x3202,
0073 const Scalar& x0302, const Scalar& x1302, const Scalar& x2302, const Scalar& x3302,
0074
0075 const Scalar& x0012, const Scalar& x1012, const Scalar& x2012, const Scalar& x3012,
0076 const Scalar& x0112, const Scalar& x1112, const Scalar& x2112, const Scalar& x3112,
0077 const Scalar& x0212, const Scalar& x1212, const Scalar& x2212, const Scalar& x3212,
0078 const Scalar& x0312, const Scalar& x1312, const Scalar& x2312, const Scalar& x3312,
0079
0080 const Scalar& x0022, const Scalar& x1022, const Scalar& x2022, const Scalar& x3022,
0081 const Scalar& x0122, const Scalar& x1122, const Scalar& x2122, const Scalar& x3122,
0082 const Scalar& x0222, const Scalar& x1222, const Scalar& x2222, const Scalar& x3222,
0083 const Scalar& x0322, const Scalar& x1322, const Scalar& x2322, const Scalar& x3322,
0084
0085 const Scalar& x0032, const Scalar& x1032, const Scalar& x2032, const Scalar& x3032,
0086 const Scalar& x0132, const Scalar& x1132, const Scalar& x2132, const Scalar& x3132,
0087 const Scalar& x0232, const Scalar& x1232, const Scalar& x2232, const Scalar& x3232,
0088 const Scalar& x0332, const Scalar& x1332, const Scalar& x2332, const Scalar& x3332,
0089
0090 const Scalar& x0003, const Scalar& x1003, const Scalar& x2003, const Scalar& x3003,
0091 const Scalar& x0103, const Scalar& x1103, const Scalar& x2103, const Scalar& x3103,
0092 const Scalar& x0203, const Scalar& x1203, const Scalar& x2203, const Scalar& x3203,
0093 const Scalar& x0303, const Scalar& x1303, const Scalar& x2303, const Scalar& x3303,
0094
0095 const Scalar& x0013, const Scalar& x1013, const Scalar& x2013, const Scalar& x3013,
0096 const Scalar& x0113, const Scalar& x1113, const Scalar& x2113, const Scalar& x3113,
0097 const Scalar& x0213, const Scalar& x1213, const Scalar& x2213, const Scalar& x3213,
0098 const Scalar& x0313, const Scalar& x1313, const Scalar& x2313, const Scalar& x3313,
0099
0100 const Scalar& x0023, const Scalar& x1023, const Scalar& x2023, const Scalar& x3023,
0101 const Scalar& x0123, const Scalar& x1123, const Scalar& x2123, const Scalar& x3123,
0102 const Scalar& x0223, const Scalar& x1223, const Scalar& x2223, const Scalar& x3223,
0103 const Scalar& x0323, const Scalar& x1323, const Scalar& x2323, const Scalar& x3323,
0104
0105 const Scalar& x0033, const Scalar& x1033, const Scalar& x2033, const Scalar& x3033,
0106 const Scalar& x0133, const Scalar& x1133, const Scalar& x2133, const Scalar& x3133,
0107 const Scalar& x0233, const Scalar& x1233, const Scalar& x2233, const Scalar& x3233,
0108 const Scalar& x0333, const Scalar& x1333, const Scalar& x2333, const Scalar& x3333
0109 ) {
0110 m_x[0][0][0][0]=x0000; m_x[1][0][0][0]=x1000; m_x[2][0][0][0]=x2000; m_x[3][0][0][0]=x3000;
0111 m_x[0][1][0][0]=x0100; m_x[1][1][0][0]=x1100; m_x[2][1][0][0]=x2100; m_x[3][1][0][0]=x3100;
0112 m_x[0][2][0][0]=x0200; m_x[1][2][0][0]=x1200; m_x[2][2][0][0]=x2200; m_x[3][2][0][0]=x3200;
0113 m_x[0][3][0][0]=x0300; m_x[1][3][0][0]=x1300; m_x[2][3][0][0]=x2300; m_x[3][3][0][0]=x3300;
0114
0115 m_x[0][0][1][0]=x0010; m_x[1][0][1][0]=x1010; m_x[2][0][1][0]=x2010; m_x[3][0][1][0]=x3010;
0116 m_x[0][1][1][0]=x0110; m_x[1][1][1][0]=x1110; m_x[2][1][1][0]=x2110; m_x[3][1][1][0]=x3110;
0117 m_x[0][2][1][0]=x0210; m_x[1][2][1][0]=x1210; m_x[2][2][1][0]=x2210; m_x[3][2][1][0]=x3210;
0118 m_x[0][3][1][0]=x0310; m_x[1][3][1][0]=x1310; m_x[2][3][1][0]=x2310; m_x[3][3][1][0]=x3310;
0119
0120 m_x[0][0][2][0]=x0020; m_x[1][0][2][0]=x1020; m_x[2][0][2][0]=x2020; m_x[3][0][2][0]=x3020;
0121 m_x[0][1][2][0]=x0120; m_x[1][1][2][0]=x1120; m_x[2][1][2][0]=x2120; m_x[3][1][2][0]=x3120;
0122 m_x[0][2][2][0]=x0220; m_x[1][2][2][0]=x1220; m_x[2][2][2][0]=x2220; m_x[3][2][2][0]=x3220;
0123 m_x[0][3][2][0]=x0320; m_x[1][3][2][0]=x1320; m_x[2][3][2][0]=x2320; m_x[3][3][2][0]=x3320;
0124
0125 m_x[0][0][3][0]=x0030; m_x[1][0][3][0]=x1030; m_x[2][0][3][0]=x2030; m_x[3][0][3][0]=x3030;
0126 m_x[0][1][3][0]=x0130; m_x[1][1][3][0]=x1130; m_x[2][1][3][0]=x2130; m_x[3][1][3][0]=x3130;
0127 m_x[0][2][3][0]=x0230; m_x[1][2][3][0]=x1230; m_x[2][2][3][0]=x2230; m_x[3][2][3][0]=x3230;
0128 m_x[0][3][3][0]=x0330; m_x[1][3][3][0]=x1330; m_x[2][3][3][0]=x2330; m_x[3][3][3][0]=x3330;
0129
0130 m_x[0][0][0][1]=x0001; m_x[1][0][0][1]=x1001; m_x[2][0][0][1]=x2001; m_x[3][0][0][1]=x3001;
0131 m_x[0][1][0][1]=x0101; m_x[1][1][0][1]=x1101; m_x[2][1][0][1]=x2101; m_x[3][1][0][1]=x3101;
0132 m_x[0][2][0][1]=x0201; m_x[1][2][0][1]=x1201; m_x[2][2][0][1]=x2201; m_x[3][2][0][1]=x3201;
0133 m_x[0][3][0][1]=x0301; m_x[1][3][0][1]=x1301; m_x[2][3][0][1]=x2301; m_x[3][3][0][1]=x3301;
0134
0135 m_x[0][0][1][1]=x0011; m_x[1][0][1][1]=x1011; m_x[2][0][1][1]=x2011; m_x[3][0][1][1]=x3011;
0136 m_x[0][1][1][1]=x0111; m_x[1][1][1][1]=x1111; m_x[2][1][1][1]=x2111; m_x[3][1][1][1]=x3111;
0137 m_x[0][2][1][1]=x0211; m_x[1][2][1][1]=x1211; m_x[2][2][1][1]=x2211; m_x[3][2][1][1]=x3211;
0138 m_x[0][3][1][1]=x0311; m_x[1][3][1][1]=x1311; m_x[2][3][1][1]=x2311; m_x[3][3][1][1]=x3311;
0139
0140 m_x[0][0][2][1]=x0021; m_x[1][0][2][1]=x1021; m_x[2][0][2][1]=x2021; m_x[3][0][2][1]=x3021;
0141 m_x[0][1][2][1]=x0121; m_x[1][1][2][1]=x1121; m_x[2][1][2][1]=x2121; m_x[3][1][2][1]=x3121;
0142 m_x[0][2][2][1]=x0221; m_x[1][2][2][1]=x1221; m_x[2][2][2][1]=x2221; m_x[3][2][2][1]=x3221;
0143 m_x[0][3][2][1]=x0321; m_x[1][3][2][1]=x1321; m_x[2][3][2][1]=x2321; m_x[3][3][2][1]=x3321;
0144
0145 m_x[0][0][3][1]=x0031; m_x[1][0][3][1]=x1031; m_x[2][0][3][1]=x2031; m_x[3][0][3][1]=x3031;
0146 m_x[0][1][3][1]=x0131; m_x[1][1][3][1]=x1131; m_x[2][1][3][1]=x2131; m_x[3][1][3][1]=x3131;
0147 m_x[0][2][3][1]=x0231; m_x[1][2][3][1]=x1231; m_x[2][2][3][1]=x2231; m_x[3][2][3][1]=x3231;
0148 m_x[0][3][3][1]=x0331; m_x[1][3][3][1]=x1331; m_x[2][3][3][1]=x2331; m_x[3][3][3][1]=x3331;
0149
0150 m_x[0][0][0][2]=x0002; m_x[1][0][0][2]=x1002; m_x[2][0][0][2]=x2002; m_x[3][0][0][2]=x3002;
0151 m_x[0][1][0][2]=x0102; m_x[1][1][0][2]=x1102; m_x[2][1][0][2]=x2102; m_x[3][1][0][2]=x3102;
0152 m_x[0][2][0][2]=x0202; m_x[1][2][0][2]=x1202; m_x[2][2][0][2]=x2202; m_x[3][2][0][2]=x3202;
0153 m_x[0][3][0][2]=x0302; m_x[1][3][0][2]=x1302; m_x[2][3][0][2]=x2302; m_x[3][3][0][2]=x3302;
0154
0155 m_x[0][0][1][2]=x0012; m_x[1][0][1][2]=x1012; m_x[2][0][1][2]=x2012; m_x[3][0][1][2]=x3012;
0156 m_x[0][1][1][2]=x0112; m_x[1][1][1][2]=x1112; m_x[2][1][1][2]=x2112; m_x[3][1][1][2]=x3112;
0157 m_x[0][2][1][2]=x0212; m_x[1][2][1][2]=x1212; m_x[2][2][1][2]=x2212; m_x[3][2][1][2]=x3212;
0158 m_x[0][3][1][2]=x0312; m_x[1][3][1][2]=x1312; m_x[2][3][1][2]=x2312; m_x[3][3][1][2]=x3312;
0159
0160 m_x[0][0][2][2]=x0022; m_x[1][0][2][2]=x1022; m_x[2][0][2][2]=x2022; m_x[3][0][2][2]=x3022;
0161 m_x[0][1][2][2]=x0122; m_x[1][1][2][2]=x1122; m_x[2][1][2][2]=x2122; m_x[3][1][2][2]=x3122;
0162 m_x[0][2][2][2]=x0222; m_x[1][2][2][2]=x1222; m_x[2][2][2][2]=x2222; m_x[3][2][2][2]=x3222;
0163 m_x[0][3][2][2]=x0322; m_x[1][3][2][2]=x1322; m_x[2][3][2][2]=x2322; m_x[3][3][2][2]=x3322;
0164
0165 m_x[0][0][3][2]=x0032; m_x[1][0][3][2]=x1032; m_x[2][0][3][2]=x2032; m_x[3][0][3][2]=x3032;
0166 m_x[0][1][3][2]=x0132; m_x[1][1][3][2]=x1132; m_x[2][1][3][2]=x2132; m_x[3][1][3][2]=x3132;
0167 m_x[0][2][3][2]=x0232; m_x[1][2][3][2]=x1232; m_x[2][2][3][2]=x2232; m_x[3][2][3][2]=x3232;
0168 m_x[0][3][3][2]=x0332; m_x[1][3][3][2]=x1332; m_x[2][3][3][2]=x2332; m_x[3][3][3][2]=x3332;
0169
0170 m_x[0][0][0][3]=x0003; m_x[1][0][0][3]=x1003; m_x[2][0][0][3]=x2003; m_x[3][0][0][3]=x3003;
0171 m_x[0][1][0][3]=x0103; m_x[1][1][0][3]=x1103; m_x[2][1][0][3]=x2103; m_x[3][1][0][3]=x3103;
0172 m_x[0][2][0][3]=x0203; m_x[1][2][0][3]=x1203; m_x[2][2][0][3]=x2203; m_x[3][2][0][3]=x3203;
0173 m_x[0][3][0][3]=x0303; m_x[1][3][0][3]=x1303; m_x[2][3][0][3]=x2303; m_x[3][3][0][3]=x3303;
0174
0175 m_x[0][0][1][3]=x0013; m_x[1][0][1][3]=x1013; m_x[2][0][1][3]=x2013; m_x[3][0][1][3]=x3013;
0176 m_x[0][1][1][3]=x0113; m_x[1][1][1][3]=x1113; m_x[2][1][1][3]=x2113; m_x[3][1][1][3]=x3113;
0177 m_x[0][2][1][3]=x0213; m_x[1][2][1][3]=x1213; m_x[2][2][1][3]=x2213; m_x[3][2][1][3]=x3213;
0178 m_x[0][3][1][3]=x0313; m_x[1][3][1][3]=x1313; m_x[2][3][1][3]=x2313; m_x[3][3][1][3]=x3313;
0179
0180 m_x[0][0][2][3]=x0023; m_x[1][0][2][3]=x1023; m_x[2][0][2][3]=x2023; m_x[3][0][2][3]=x3023;
0181 m_x[0][1][2][3]=x0123; m_x[1][1][2][3]=x1123; m_x[2][1][2][3]=x2123; m_x[3][1][2][3]=x3123;
0182 m_x[0][2][2][3]=x0223; m_x[1][2][2][3]=x1223; m_x[2][2][2][3]=x2223; m_x[3][2][2][3]=x3223;
0183 m_x[0][3][2][3]=x0323; m_x[1][3][2][3]=x1323; m_x[2][3][2][3]=x2323; m_x[3][3][2][3]=x3323;
0184
0185 m_x[0][0][3][3]=x0033; m_x[1][0][3][3]=x1033; m_x[2][0][3][3]=x2033; m_x[3][0][3][3]=x3033;
0186 m_x[0][1][3][3]=x0133; m_x[1][1][3][3]=x1133; m_x[2][1][3][3]=x2133; m_x[3][1][3][3]=x3133;
0187 m_x[0][2][3][3]=x0233; m_x[1][2][3][3]=x1233; m_x[2][2][3][3]=x2233; m_x[3][2][3][3]=x3233;
0188 m_x[0][3][3][3]=x0333; m_x[1][3][3][3]=x1333; m_x[2][3][3][3]=x2333; m_x[3][3][3][3]=x3333;
0189 }
0190 inline Lorentz_Ten4(const Scalar ten[4][4][4][4]) {
0191 for (unsigned short int i=0; i<4; ++i)
0192 for (unsigned short int j=0; j<4; ++j)
0193 for (unsigned short int k=0; k<4; ++k)
0194 for (unsigned short int l=0; l<4; ++l)
0195 m_x[i][j][k][l] = ten[i][j][k][l];
0196 }
0197
0198
0199 inline const Scalar at(unsigned short int i, unsigned short int j,
0200 unsigned short int k, unsigned short int l) const {
0201 return m_x[i][j][k][l];
0202 }
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218 inline Lorentz_Ten4<Scalar> operator-() const {
0219 Scalar x[4][4][4][4];
0220 for (unsigned short int i=0; i<4; ++i)
0221 for (unsigned short int j=0; j<4; ++j)
0222 for (unsigned short int k=0; k<4; ++k)
0223 for (unsigned short int l=0; l<4; ++l)
0224 x[i][j][k][l] = -m_x.at(i,j,k,l);
0225 return Lorentz_Ten4<Scalar>(x);
0226 }
0227
0228
0229 inline Lorentz_Ten4<Scalar> Transpose(unsigned short int a, unsigned short int b) const {
0230 Scalar x[4][4][4][4];
0231 if (((a==1) && (b==2)) || ((a==2) && (b==1)))
0232 for (unsigned short int i=0; i<4; ++i)
0233 for (unsigned short int j=0; j<4; ++j)
0234 for (unsigned short int k=0; k<4; ++k)
0235 for (unsigned short int l=0; l<4; ++l)
0236 x[i][j][k][l] = m_x[j][i][k][l];
0237 else if (((a==1) && (b==3)) || ((a==3) && (b==1)))
0238 for (unsigned short int i=0; i<4; ++i)
0239 for (unsigned short int j=0; j<4; ++j)
0240 for (unsigned short int k=0; k<4; ++k)
0241 for (unsigned short int l=0; l<4; ++l)
0242 x[i][j][k][l] = m_x[k][j][i][l];
0243 else if (((a==1) && (b==4)) || ((a==4) && (b==1)))
0244 for (unsigned short int i=0; i<4; ++i)
0245 for (unsigned short int j=0; j<4; ++j)
0246 for (unsigned short int k=0; k<4; ++k)
0247 for (unsigned short int l=0; l<4; ++l)
0248 x[i][j][k][l] = m_x[l][j][k][i];
0249 else if (((a==2) && (b==3)) || ((a==3) && (b==2)))
0250 for (unsigned short int i=0; i<4; ++i)
0251 for (unsigned short int j=0; j<4; ++j)
0252 for (unsigned short int k=0; k<4; ++k)
0253 for (unsigned short int l=0; l<4; ++l)
0254 x[i][j][k][l] = m_x[i][k][j][l];
0255 else if (((a==2) && (b==4)) || ((a==4) && (b==2)))
0256 for (unsigned short int i=0; i<4; ++i)
0257 for (unsigned short int j=0; j<4; ++j)
0258 for (unsigned short int k=0; k<4; ++k)
0259 for (unsigned short int l=0; l<4; ++l)
0260 x[i][j][k][l] = m_x[i][l][k][j];
0261 else if (((a==3) && (b==4)) || ((a==4) && (b==3)))
0262 for (unsigned short int i=0; i<4; ++i)
0263 for (unsigned short int j=0; j<4; ++j)
0264 for (unsigned short int k=0; k<4; ++k)
0265 for (unsigned short int l=0; l<4; ++l)
0266 x[i][j][k][l] = m_x[i][j][l][k];
0267 return Lorentz_Ten4<Scalar>(x);
0268 }
0269
0270
0271 inline Lorentz_Ten4<Scalar>& operator+=(const Lorentz_Ten4<Scalar>& t) {
0272 for (unsigned short int i=0; i<4; ++i)
0273 for (unsigned short int j=0; j<4; ++j)
0274 for (unsigned short int k=0; k<4; ++k)
0275 for (unsigned short int l=0; l<4; ++l)
0276 m_x[i][j][k][l] += t.at(i,j,k,l);
0277 return *this;
0278 }
0279
0280 inline Lorentz_Ten4<Scalar>& operator-=(const Lorentz_Ten4<Scalar>& t) {
0281 for (unsigned short int i=0; i<4; ++i)
0282 for (unsigned short int j=0; j<4; ++j)
0283 for (unsigned short int k=0; k<4; ++k)
0284 for (unsigned short int l=0; l<4; ++l)
0285 m_x[i][j][k][l] -= t.at(i,j,k,l);
0286 return *this;
0287 }
0288
0289 template<typename Scalar2>
0290 inline Lorentz_Ten4<PROMOTE(Scalar,Scalar2)>
0291 operator+ (const Lorentz_Ten4<Scalar2>& ten) const {
0292 PROMOTE(Scalar,Scalar2) x[4][4][4][4];
0293 for (unsigned short int i=0; i<4; ++i)
0294 for (unsigned short int j=0; j<4; ++j)
0295 for (unsigned short int k=0; k<4; ++k)
0296 for (unsigned short int l=0; l<4; ++l)
0297 x[i][j][k][l] = m_x[i][j][k][l]+ten.at(i,j,k,l);
0298 return Lorentz_Ten4<PROMOTE(Scalar,Scalar2)>(x);
0299 }
0300
0301 template<typename Scalar2>
0302 inline Lorentz_Ten4<PROMOTE(Scalar,Scalar2)>
0303 operator- (const Lorentz_Ten4<Scalar2>& ten) const {
0304 PROMOTE(Scalar,Scalar2) x[4][4][4][4];
0305 for (unsigned short int i=0; i<4; ++i)
0306 for (unsigned short int j=0; j<4; ++j)
0307 for (unsigned short int k=0; k<4; ++k)
0308 for (unsigned short int l=0; l<4; ++l)
0309 x[i][j][k][l] = m_x[i][j][k][l]-ten.at(i,j,k,l);
0310 return Lorentz_Ten4<PROMOTE(Scalar,Scalar2)>(x);
0311 }
0312
0313
0314 inline Lorentz_Ten4<Scalar>& operator*= (const Scalar& scal) {
0315 for (unsigned short int i=0; i<4; ++i)
0316 for (unsigned short int j=0; j<4; ++j)
0317 for (unsigned short int k=0; k<4; ++k)
0318 for (unsigned short int l=0; l<4; ++l)
0319 m_x[i][j][k][l] *= scal;
0320 return *this;
0321 }
0322
0323 template<typename Scalar2>
0324 inline Lorentz_Ten4<PROMOTE(Scalar,Scalar2)> operator* (const Scalar2 scal) const {
0325 PROMOTE(Scalar,Scalar2) x[4][4][4][4];
0326 for (unsigned short int i=0; i<4; ++i)
0327 for (unsigned short int j=0; j<4; ++j)
0328 for (unsigned short int k=0; k<4; ++k)
0329 for (unsigned short int l=0; l<4; ++l)
0330 x[i][j][k][l] = scal*m_x[i][j][k][l];
0331 return Lorentz_Ten4<PROMOTE(Scalar,Scalar2)>(x);
0332 }
0333
0334 template<typename Scalar2>
0335 inline Lorentz_Ten4<PROMOTE(Scalar,Scalar2)> operator/ (const Scalar2 scal) const {
0336 return (*this)*(1./scal);
0337 }
0338
0339 inline bool Nan() const {
0340 for (unsigned short int i=0; i<4; ++i)
0341 for (unsigned short int j=0; j<4; ++j)
0342 for (unsigned short int k=0; k<4; ++k)
0343 for (unsigned short int l=0; l<4; ++l)
0344 if (ATOOLS::IsNan<Scalar>(m_x[i][j][k][l])) return true;
0345 return false;
0346 }
0347
0348 inline bool IsZero() const {
0349 for (unsigned short int i=0; i<4; ++i)
0350 for (unsigned short int j=0; j<4; ++j)
0351 for (unsigned short int k=0; k<4; ++k)
0352 for (unsigned short int l=0; l<4; ++l)
0353 if (!ATOOLS::IsZero<Scalar>(m_x[i][j][k][l])) return false;
0354 return true;
0355 }
0356 };
0357
0358 template<typename Scalar,typename Scal2>
0359 inline Lorentz_Ten4<PROMOTE(Scalar,Scal2)>
0360 operator* (const Scal2 s, const Lorentz_Ten4<Scalar>& t) {
0361 return Lorentz_Ten4<PROMOTE(Scalar,Scal2)>(t*s);
0362 }
0363
0364 template<typename Scalar>
0365 std::ostream& operator<<(std::ostream& s, const Lorentz_Ten4<Scalar>& ten) {
0366 return s<<"not implemented for tensors of fourth rank ... "
0367 <<"please project to second rank and display then ..."<<std::endl;
0368 }
0369 }
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466 #endif