Back to home page

EIC code displayed by LXR

 
 

    


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    * @brief Pseudoscalar made necessary by the decomposition of
0011    *   (for example) a four-leg vertex into two three-leg vertices
0012    *
0013    * @tparam Scalar The underlying floating point type.
0014    */
0015   template <class Scalar>
0016   class CAsT4: public CObject {
0017   public:
0018 
0019     typedef std::complex<Scalar> SComplex;
0020 
0021   private:
0022 
0023     /// @brief The spin components of the current.
0024     SComplex m_x[6];
0025 
0026     /// @brief The accuracy for all scalars.
0027     /// @note Not used anywhere
0028     static double s_accu;
0029 
0030     /// @brief A vector of CAsT4 objects that cleans its memory upon destruction.
0031     ///
0032     /// If threading is enabled, all the CScalars created with the CAsT4<Scalar>::New() method
0033     /// will be allocated inside this vector behind the scenes.
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     /// @name New pointer creator methods
0043     /// @{
0044     /// @brief Create a pointer to a new CAsT4 object.
0045     /// If threading is enabled, existing slots inside CAsT4<Scalar>::s_objects will be re-used.
0046     static CAsT4 *New();
0047     static CAsT4 *New(const CAsT4 &s);
0048     /// @}
0049 
0050     CObject* Copy() const;
0051 
0052     /// @brief Deletes this object.
0053     ///
0054     /// If threading is enabled, the memory it occupies is afded to CAsT4<Scalar>::s_objects
0055     /// in order to be re-used in the future.
0056     void Delete();
0057 
0058     /// @brief Return true if CAsT4<Scalar>::m_x is zero.
0059     bool IsZero() const;
0060 
0061 
0062     /// @name Constructors
0063     /// @{
0064 
0065     /// @brief Default constructor.
0066     ///
0067     /// Initialize all data members to zero (m_x, m_c, m_h, m_s)
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     /// @brief Copy constructor
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     /// @brief Constructor
0082     ///
0083     /// @param x0-x5  the spin components
0084     /// @param c1 the color index
0085     /// @param c2 the anti-color index
0086     /// @param h  the helicity
0087     /// @param s  the NLO subtraction flag (m_s)
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     /// @name Access operators
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     /// @name Arithmetic operations
0129     /// @{
0130     /// These operations apply only to the CAsT4::m_x member (spin components).
0131 
0132     /// @brief Add a CObject @a c to this pseudoscalar
0133     void Add(const CObject *c);
0134 
0135     /// @brief Divide this pseudoscalars by a floating point @a d
0136     void Divide(const double &d);
0137 
0138     /// @brief Multiply this pseudoscalar by a complex number @a c
0139     void Multiply(const Complex &c);
0140 
0141     /// @brief Inverts this pseudoscalar
0142     void Invert();
0143 
0144     /// @brief Non-modifying addition of two pseudoscalars
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     /// @brief Non-modifying subtraction of two pseudoscalars
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     /// @brief Returns the negative of this pseudoscalars
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     /// @brief Add a pseudoscalar @a v to this pseudoscalar
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     /// @brief Subtract a pseudoscalar @a v from this pseudoscalar
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     /// @brief Multiply this pseudoscalar with pseudoscalar @a v
0179     CAsT4& operator*=(const SComplex &c);
0180 
0181     /// @brief Return complex conjugate of this pseudoscalar
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     /// @brief Check if any elements in m_x is NaN
0191     bool Nan() const;
0192 
0193     /// @name Access or manipulate the CAsT4::s_accu data member
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   };// end of class CAsT4
0203 
0204   /// @name Operators
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 }// end of namespace ATOOLS
0234 
0235 #define DCAsT4D METOOLS::CAsT4<double>
0236 #define QCAsT4D METOOLS::CAsT4<long double>
0237 
0238 #endif