Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:09:54

0001 #ifndef ATOOLS_Phys_Color_H
0002 #define ATOOLS_Phys_Color_H
0003 /*!
0004   \file Color.H
0005   \brief Declares the classes Color_Term,
0006   CNumber, Fundamental, Adjoint, Trace and Expression.
0007 */
0008 
0009 #include <iostream>
0010 #include <string>
0011 #ifndef USING__Color_only
0012 #include "ATOOLS/Math/MyComplex.H"
0013 #else
0014 #include <complex>
0015 typedef std::complex<double> Complex;
0016 #endif
0017 #include "ATOOLS/Org/Node.H"
0018 
0019 namespace ATOOLS {
0020 
0021   struct ctt {
0022     
0023     enum type {
0024       number      = 0,
0025       delta       = 1,
0026       fundamental = 2,
0027       adjoint     = 4,
0028       trace       = 8
0029     };
0030 
0031   };// end of struct ctt
0032 
0033   class Expression;
0034   
0035   class Color_Term {
0036   private:
0037 
0038     ctt::type m_type;
0039 
0040   public:
0041     
0042     // constructor
0043     inline Color_Term(const ctt::type &type): 
0044       m_type(type) {}
0045 
0046     // destructor
0047     virtual ~Color_Term();
0048 
0049     // member functions
0050     virtual bool Evaluate(Expression *const expression);
0051     virtual void Print() const;
0052 
0053     virtual Color_Term *GetCopy() const;
0054 
0055     virtual void Delete();
0056 
0057     // inline functions
0058     inline ctt::type Type() const { return m_type; }
0059 
0060   };// end of class Color_Term
0061   /*!
0062     \class Color_Term
0063     \brief The base class of all objects in color space.
0064 
0065     This class is the base class of all classes
0066     representing objects in color space.
0067   */
0068 
0069   class CNumber: public Color_Term {
0070   public:
0071     
0072     typedef std::vector<CNumber*> CNumber_Vector;
0073 
0074   private:
0075 
0076     static CNumber_Vector s_cnumbers;
0077 
0078     Complex m_n;
0079 
0080   public:
0081     
0082     // constructor
0083     inline CNumber(const Complex &n):
0084       Color_Term(ctt::number), m_n(n) {}
0085 
0086     // member functions
0087     bool Evaluate(Expression *const expression);
0088     void Print() const;
0089 
0090     Color_Term *GetCopy() const;
0091 
0092     static CNumber *New(const Complex &n);
0093 
0094     void        Delete();
0095     static void DeleteAll();
0096 
0097     // inline functions
0098     inline Complex operator()() { return m_n; }
0099 
0100   };// end of class CNumber
0101   /*!
0102     \class CNumber
0103     \brief Represents a complex number.
0104 
0105     This class represents a complex number.
0106   */
0107 
0108   class Delta: public Color_Term {
0109   public:
0110     
0111     typedef std::vector<Delta*> Delta_Vector;
0112 
0113   private:
0114 
0115     static Delta_Vector s_deltas;
0116 
0117     size_t m_i, m_j;
0118 
0119   public:
0120     
0121     // constructor
0122     inline Delta(const size_t &i,const size_t &j):
0123       Color_Term(ctt::delta), m_i(i), m_j(j) {}
0124 
0125     // member functions
0126     bool Evaluate(Expression *const expression);
0127     /*!
0128       \fn bool Evaluate(Expression *const expression)
0129       \brief Contracts delta functions.
0130 
0131       This method contracts delta functions according to
0132       \f[
0133       \delta_{ij}\delta_{jk}\,=\;\delta_{ik}
0134       \f]
0135       and
0136       \f[
0137       \delta_{ii}\,=\;N_C\;.
0138       \f]
0139     */
0140     void Print() const;
0141 
0142     Color_Term *GetCopy() const;
0143 
0144     static Delta *New(const size_t &i,const size_t &j);
0145 
0146     void        Delete();
0147     static void DeleteAll();
0148 
0149     inline void SetI(const size_t &i) { m_i=i; }
0150     inline void SetJ(const size_t &j) { m_j=j; }
0151 
0152   };// end of class Delta
0153   /*!
0154     \class Delta
0155     \brief Represents a delta function.
0156 
0157     This class represents a delta function.
0158   */
0159 
0160   class Fundamental: public Color_Term {
0161   public:
0162     
0163     typedef std::vector<Fundamental*> Fundamental_Vector;
0164 
0165   private:
0166 
0167     static Fundamental_Vector s_fundamentals;
0168 
0169     size_t m_a, m_i, m_j;
0170     bool   m_fromf;
0171     /*!
0172       \var bool m_fromf
0173       \brief Tags that this objects stems from the expansion of 
0174       a matrix in the adjoint representation.
0175     */
0176 
0177     friend class Delta;
0178     friend class Adjoint; 
0179 
0180   public:
0181     
0182     // constructor
0183     inline Fundamental(const size_t &a,const size_t &i,const size_t &j,
0184                const bool &fromf=false):
0185       Color_Term(ctt::fundamental), m_a(a), m_i(i), m_j(j), 
0186       m_fromf(fromf) {}
0187 
0188     // member functions
0189     bool Evaluate(Expression *const expression);
0190     /*!
0191       \fn bool Evaluate(Expression *const expression)
0192       \brief Expands the matrix.
0193 
0194       This method expands a contraction of two matrices 
0195       in the fundamental representation, \f$T^{a}_{ij}\f$ and 
0196       \f$T^{a}_{kl}\f$ in terms of delta functions, according to
0197       \f[
0198       T^{a}_{ij}T^{a}_{kl}\,=\;\frac{1}{2}\,\left(\,
0199       \delta_{il}\delta_{jk}-\frac{1}{N_C}\delta_{ij}\delta_{kl}
0200       \,\right)\;,
0201       \f]
0202       If the m_fromf flag is set, the \f$1/{N_C}\f$-term is dropped,
0203       since it does not contribute, see Adjoint.
0204     */
0205     void Print() const;
0206 
0207     Color_Term *GetCopy() const;
0208 
0209     static Fundamental *New(const size_t &a,const size_t &i,const size_t &j,
0210                 const bool &fromf=false);
0211 
0212     void        Delete();
0213     static void DeleteAll();
0214 
0215     inline void SetA(const size_t &a) { m_a=a; }
0216     inline void SetI(const size_t &i) { m_i=i; }
0217     inline void SetJ(const size_t &j) { m_j=j; }
0218 
0219   };// end of class Fundamental
0220   /*!
0221     \class Fundamental
0222     \brief Represents a color matrix in the fundamental representation.
0223 
0224     This class represents a color matrix in the fundamental representation.
0225   */
0226 
0227   class Adjoint: public Color_Term {
0228   public:
0229     
0230     typedef std::vector<Adjoint*> Adjoint_Vector;
0231 
0232   private:
0233 
0234     static Adjoint_Vector s_adjoints;
0235 
0236     size_t m_a, m_b, m_c;
0237 
0238   public:
0239     
0240     // constructor
0241     inline Adjoint(const size_t &a,const size_t &b,const size_t &c):
0242       Color_Term(ctt::adjoint), m_a(a), m_b(b), m_c(c) {}
0243 
0244     // member functions
0245     bool Evaluate(Expression *const expression);
0246     /*!
0247       \fn bool Evaluate(Expression *const expression)
0248       \brief Expands the matrix.
0249 
0250       This method expands a matrix of the adjoint representation, 
0251       \f$f^{abc}\f$ in terms of matrices in the fundamental representation,
0252       according to
0253       \f[
0254       f^{abc}\,=\;-2i\,{\rm tr}\left(\,T^a\left[T^b,T^c\right]\,\right)
0255       \,=\;-2i\,{\rm tr}\left(\,T^c\left[T^a,T^b\right]\,\right)
0256       \,=\;-2i\,{\rm tr}\left(\,T^b\left[T^c,T^a\right]\,\right)\;.
0257       \f]
0258       The generated Fundamental objects, such as e.g. \f$T^a_{ij}\f$, 
0259       obtain a flag, which tags that they stem from the expansion 
0260       of an \f$f\f$ matrix and therefore, in the evaluation of 
0261       \f$T^a_{ij}T^a_{kl}\f$ the \f$1/N_C\f$-term may be dropped,
0262       see Fundamental.
0263     */
0264     void Print() const;
0265 
0266     Color_Term *GetCopy() const;
0267 
0268     static Adjoint *New(const size_t &a,const size_t &b,const size_t &c);
0269 
0270     void        Delete();
0271     static void DeleteAll();
0272 
0273     inline void SetA(const size_t &a) { m_a=a; }
0274     inline void SetB(const size_t &b) { m_b=b; }
0275     inline void SetC(const size_t &c) { m_c=c; }
0276 
0277   };// end of class Adjoint
0278   /*!
0279     \class Adjoint
0280     \brief Represents a color matrix in the adjoint representation.
0281 
0282     This class represents a color matrix in the adjoint representation.
0283   */
0284 
0285   class Trace: public Color_Term {
0286   public:
0287     
0288     typedef std::vector<Trace*> Trace_Vector;
0289 
0290   private:
0291 
0292     static Trace_Vector s_traces;
0293 
0294     size_t *ma, m_i, m_j;
0295 
0296     public:
0297     
0298     // constructor
0299     Trace(size_t *a,const size_t &i,const size_t &j);
0300 
0301     //destructor
0302     ~Trace();
0303 
0304     // member functions
0305     bool Evaluate(Expression *const expression);
0306     /*!
0307       \fn bool Evaluate(Expression *const expression)
0308       \brief Expands the trace.
0309 
0310       This method expands a trace, 
0311       \f$tr(T^a T^b ... T^n)\f$ in terms of matrices in the fundamental representation,
0312       according to
0313       \f[
0314       tr(T^a T^b T^c ...)\,=\;T^a_{ij}T^b_{jk} ... T^n_{li} 
0315       \f].
0316     */
0317     void Print() const;
0318 
0319     Color_Term *GetCopy() const;
0320 
0321     static Trace *New(size_t *a,const size_t &i,const size_t &j);
0322 
0323     void        Delete();
0324     static void DeleteAll();
0325 
0326   };// end of class Trace
0327   /*!
0328     \class Trace
0329     \brief Represents a trace of the product of matrices in the fundamental representation.
0330 
0331     This class represents a trace of the product of matrices in the fundamental representation.
0332   */
0333 
0334   class Expression: public ATOOLS::Node<Color_Term*> {
0335   public:
0336 
0337     typedef std::vector<Color_Term*> Color_Term_Vector;
0338 
0339     typedef std::vector<ATOOLS::Node<Color_Term*>*> Expression_Vector;
0340 
0341   private:
0342 
0343     static Expression_Vector s_expressions;
0344 
0345     Complex m_result;
0346 
0347     double m_NC, m_TR;
0348 
0349     size_t m_findex, m_aindex;
0350     size_t m_evaluated, m_cindex;
0351 
0352   public:
0353     
0354     // constructor
0355     inline Expression(): 
0356       Node<Color_Term*>(NULL,true), m_result(0.0,0.0), m_NC(3.0), m_TR(0.5),
0357       m_findex(0), m_aindex(0), m_evaluated(0), m_cindex(0) {}
0358 
0359     inline Expression(int ma,int mf): 
0360       Node<Color_Term*>(NULL,true), m_result(0.0,0.0), m_NC(3.0), m_TR(0.5),
0361       m_findex(mf+1), m_aindex(ma+1), m_evaluated(0), m_cindex(0) {}
0362 
0363     Expression(const std::string &expression); 
0364     
0365     // destructor
0366     ~Expression();
0367     
0368     // member functions
0369     bool Evaluate();
0370     void Print();
0371 
0372     inline void Add(Expression *const expression)
0373     {
0374       (*this)().push_back(expression);
0375       (*expression)<<this;
0376     }
0377 
0378     size_t Size();
0379     size_t Evaluated();
0380 
0381     Expression *GetCopy() const;
0382 
0383     static Expression *New(const size_t &terms);
0384     
0385     void        Delete();
0386     static void DeleteAll();
0387 
0388     void PrintStatus(const bool endline=true,
0389              const bool print=true);
0390 
0391     // inline functions
0392     inline Complex Result() const { return m_result; }
0393 
0394     inline double NC() const { return m_NC; }
0395     inline double TR() const { return m_TR; }
0396 
0397     inline size_t FIndex() { return ++m_findex; }
0398     inline size_t AIndex() { return ++m_aindex; }
0399 
0400     inline size_t CIndex() const { return m_cindex; }
0401 
0402     inline void SetNC(const double &nc) { m_NC=nc; }
0403     inline void SetTR(const double &tr) { m_TR=tr; }
0404 
0405   };// end of class Expression
0406   /*!
0407     \class Expression
0408     \brief Represents a single color amplitude.
0409     
0410     This class represents a single color amplitude.
0411   */
0412 
0413 }// end of namespace ATOOLS
0414 
0415 #endif