File indexing completed on 2025-04-19 09:10:05
0001 #ifndef METOOLS_Explicit_C_Tensor_H
0002 #define METOOLS_Explicit_C_Tensor_H
0003
0004 #include "METOOLS/Currents/C_Vector.H"
0005 #include "ATOOLS/Org/STL_Tools.H"
0006
0007 namespace METOOLS {
0008
0009
0010
0011
0012
0013
0014
0015 template <class Scalar>
0016 class CAsT4: public CObject {
0017 public:
0018
0019 typedef std::complex<Scalar> SComplex;
0020
0021 private:
0022
0023
0024 SComplex m_x[6];
0025
0026
0027
0028 static double s_accu;
0029
0030
0031
0032
0033
0034 static ATOOLS::AutoDelete_Vector<CAsT4> s_objects;
0035
0036 template <class _Scalar> friend std::ostream &
0037 operator<<(std::ostream &s,const CAsT4<_Scalar> &ten);
0038
0039 public:
0040
0041
0042
0043
0044
0045
0046 static CAsT4 *New();
0047 static CAsT4 *New(const CAsT4 &s);
0048
0049
0050 CObject* Copy() const;
0051
0052
0053
0054
0055
0056 void Delete();
0057
0058
0059 bool IsZero() const;
0060
0061
0062
0063
0064
0065
0066
0067
0068 inline CAsT4() {
0069 m_x[0]=m_x[1]=m_x[2]=m_x[3]=m_x[4]=m_x[5]=0.0;
0070 m_c[0]=m_c[1]=0; m_h=m_s=0;
0071 }
0072
0073
0074 inline CAsT4(const CAsT4 &t) {
0075 m_x[0]=t[0]; m_x[1]=t[1]; m_x[2]=t[2];
0076 m_x[3]=t[3]; m_x[4]=t[4]; m_x[5]=t[5];
0077 m_c[0]=t(0); m_c[1]=t(1); m_h=t.m_h; m_s=t.m_s;
0078 }
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 inline CAsT4(const Scalar &x0, const Scalar &x1,
0089 const Scalar &x2, const Scalar &x3,
0090 const Scalar &x4, const Scalar &x5,
0091 const int c1=0,const int c2=0,
0092 const size_t &h=0,const size_t &s=0) {
0093 m_x[0]=x0; m_x[1]=x1; m_x[2]=x2;
0094 m_x[3]=x3; m_x[4]=x4; m_x[5]=x5;
0095 m_c[0]=c1; m_c[1]=c2; m_h=h; m_s=s;
0096 }
0097
0098 inline CAsT4(const int c1,const int c2,
0099 const size_t &h=0,const size_t &s=0)
0100 {
0101 m_x[0]=m_x[1]=m_x[2]=m_x[3]=m_x[4]=m_x[5]=0.0;
0102 m_c[0]=c1; m_c[1]=c2; m_h=h; m_s=s;
0103 }
0104 inline CAsT4(const SComplex &x0, const SComplex &x1,
0105 const SComplex &x2, const SComplex &x3,
0106 const SComplex &x4, const SComplex &x5,
0107 const int c1=-1,const int c2=-1,
0108 const size_t &h=0,const size_t &s=0)
0109 {
0110 m_x[0]=x0; m_x[1]=x1; m_x[2]=x2;
0111 m_x[3]=x3; m_x[4]=x4; m_x[5]=x5;
0112 m_c[0]=c1; m_c[1]=c2; m_h=h; m_s=s;
0113 }
0114
0115 CAsT4(const CVec4<Scalar> &v1,const CVec4<Scalar> &v2);
0116 CAsT4(const CAsT4 &v,const SComplex &c);
0117 CAsT4(const CAsT4 &v,const Scalar &c);
0118
0119
0120
0121
0122 inline SComplex &operator[](const int i) { return m_x[i]; }
0123
0124 inline const SComplex &operator[](const int i) const { return m_x[i]; }
0125
0126
0127
0128
0129
0130
0131
0132
0133 void Add(const CObject *c);
0134
0135
0136 void Divide(const double &d);
0137
0138
0139 void Multiply(const Complex &c);
0140
0141
0142 void Invert();
0143
0144
0145 inline CAsT4 operator+(const CAsT4 &v) const {
0146 return CAsT4(m_x[0]+v[0],m_x[1]+v[1],m_x[2]+v[2],
0147 m_x[3]+v[3],m_x[4]+v[4],m_x[5]+v[5],
0148 m_c[0],m_c[1],m_h,m_s);
0149 }
0150
0151
0152 inline CAsT4 operator-(const CAsT4 &v) const {
0153 return CAsT4(m_x[0]-v[0],m_x[1]-v[1],m_x[2]-v[2],
0154 m_x[3]-v[3],m_x[4]-v[4],m_x[5]-v[5],
0155 m_c[0],m_c[1],m_h,m_s);
0156 }
0157
0158
0159 inline CAsT4 operator-() const{
0160 return CAsT4(-m_x[0],-m_x[1],-m_x[2],-m_x[3],-m_x[4],-m_x[5],
0161 m_c[0],m_c[1],m_h,m_s);
0162 }
0163
0164
0165 inline CAsT4& operator+=(const CAsT4 &v) {
0166 m_x[0]+=v[0]; m_x[1]+=v[1]; m_x[2]+=v[2];
0167 m_x[3]+=v[3]; m_x[4]+=v[4]; m_x[5]+=v[5];
0168 return *this;
0169 }
0170
0171
0172 inline CAsT4& operator-=(const CAsT4 &v) {
0173 m_x[0]-=v[0]; m_x[1]-=v[1]; m_x[2]-=v[2];
0174 m_x[3]-=v[3]; m_x[4]-=v[4]; m_x[5]-=v[5];
0175 return *this;
0176 }
0177
0178
0179 CAsT4& operator*=(const SComplex &c);
0180
0181
0182 inline CAsT4 Conj() const {
0183 return CAsT4(std::conj(m_x[0]),std::conj(m_x[1]),std::conj(m_x[2]),
0184 std::conj(m_x[3]),std::conj(m_x[4]),std::conj(m_x[5]),
0185 m_c[0],m_c[1],m_h,m_s);
0186 }
0187
0188
0189
0190
0191 bool Nan() const;
0192
0193
0194
0195
0196 static void ResetAccu();
0197 inline static void SetAccu(const double &accu) { s_accu=accu; }
0198 inline static double Accu() { return s_accu; }
0199
0200
0201
0202 };
0203
0204
0205
0206
0207 template <class Scalar> inline CAsT4<Scalar>
0208 operator*(const Scalar &c,const CAsT4<Scalar> &t)
0209 { return CAsT4<Scalar>(t,c); }
0210 template <class Scalar> inline CAsT4<Scalar>
0211 operator*(const CAsT4<Scalar> &t,const Scalar &c)
0212 { return CAsT4<Scalar>(t,c); }
0213 template <class Scalar> inline CAsT4<Scalar>
0214 operator*(const std::complex<Scalar> &c,const CAsT4<Scalar> &t)
0215 { return CAsT4<Scalar>(t,c); }
0216 template <class Scalar> inline CAsT4<Scalar>
0217 operator*(const CAsT4<Scalar> &t,const std::complex<Scalar> &c)
0218 { return CAsT4<Scalar>(t,c); }
0219 template <class Scalar> inline CAsT4<Scalar>
0220 operator/(const CAsT4<Scalar> &t,const std::complex<Scalar> &c)
0221 { return CAsT4<Scalar>(t,1.0/c); }
0222 template <class Scalar> CVec4<Scalar>
0223 operator*(const CVec4<Scalar> &v,const CAsT4<Scalar> &t);
0224 template <class Scalar> inline CVec4<Scalar>
0225 operator*(const CAsT4<Scalar> &t,const CVec4<Scalar> &v)
0226 { return -(v*t); }
0227
0228
0229
0230 template <class Scalar>
0231 std::ostream &operator<<(std::ostream &s,const CAsT4<Scalar> &ten);
0232
0233 }
0234
0235 #define DCAsT4D METOOLS::CAsT4<double>
0236 #define QCAsT4D METOOLS::CAsT4<long double>
0237
0238 #endif