Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:11

0001 // -*- C++ -*-
0002 
0003 /*
0004  * Col_amp.h
0005  *  Contains the declarations of the class Col_amp, related types and operators
0006  *  Created on: Jul 7, 2010
0007  *  Author: Malin Sjodahl
0008  */
0009 
0010 #ifndef COLORFULL_Col_amp_h
0011 #define COLORFULL_Col_amp_h
0012 
0013 #include "Col_str.h"
0014 
0015 namespace ColorFull {
0016 
0017 /// Define a type to contain a linear combination of color structures,
0018 /// a col_amp contains the actual color amplitude in a Col_amp.
0019 typedef std::vector<Col_str> col_amp;
0020 
0021 
0022 /// The full color amplitude is Scalar + Cs1+Cs2+Cs3...
0023 /// Col_amp is a class to contain info on several Col_strs, a color amplitude.
0024 class Col_amp {
0025 
0026 public:
0027 
0028     /// Default constructor, sets Scalar=0, and leaves ca empty.
0029     Col_amp() {Scalar = Scalar * 0;}
0030 
0031     /// Constructor taking a string as argument.
0032     /// The string should be of form
0033     /// Polynomial1* col_str1 + Polynomial2*col_str2,
0034     /// for example:
0035     /// Col_amp Ca("13*Nc*[(1, 3, 4, 2)] +2 TR 5 Nc^(-3) [(1, 4) (3,  2)]").
0036     /// (The Polynomials should multiply the whole col_strs in square brackets,
0037     /// rather than a quark_line inside the []-brackets.)
0038     Col_amp( const std::string str ){Col_amp_of_str( str );}
0039 
0040     /// Constructor converting a Col_str to a Col_amp.
0041     Col_amp( Col_str Cs ) {
0042         Scalar = Scalar * 0;
0043         ca.push_back(Cs);
0044     }
0045 
0046     /// To actually contain the information about the Col_strs, ca=Cs1+Cs2+Cs3+... .
0047     /// Technically the ca is a vector of Col_strs, a col_amp.
0048     col_amp ca;
0049 
0050     /// Scalar is Polynomial for collecting color factors appearing when
0051     /// the color structure has been fully contracted.
0052     /// The full color amplitude is Scalar + Cs1+Cs2+Cs3....
0053     /// Scalar should thus be non-zero only if all indices can be contracted.
0054     Polynomial Scalar;
0055 
0056     /// Reads in the Col_amp to the member ca from the file filename.
0057     /// (This is for reading in an actual color amplitude,
0058     /// nothing is read in the the Polynomial member scalar.)
0059     void read_in_Col_amp( std::string filename );
0060 
0061     /// Function for writing out the Col_amp to a file
0062     /// with name filename.
0063     void write_out_Col_amp( std::string filename ) const;
0064 
0065     /// Returns the Col_str at place i.
0066     const Col_str & at( int i ) const{ return ca.at(i); }
0067 
0068     /// Returns the Col_str at place i.
0069     Col_str & at( int i ) {return ca.at(i);}
0070 
0071     /// The size of the col_amp ca.
0072     uint size() const {return ca.size();}
0073 
0074     /// Is the col_amp empty?
0075     bool empty() const { return ca.empty(); }
0076 
0077     /// Erases the information in the col_amp.
0078     void clear() { ca.clear(); }
0079 
0080     /// Erases the Col_str at place i.
0081     void erase( int i );
0082 
0083     /// Appends a Col_str to the data member ca.
0084     void append( Col_str Cs ) {ca.push_back( Cs );}
0085 
0086     /// Appends the Col_strs in ca_in to the col_amp member ca.
0087     void append( col_amp ca_in );
0088 
0089 
0090     // Functions for probing the Col_amp
0091 
0092     /// Checks if the Col_amp only contains gluons, i.e., if all Quark_lines are closed.
0093     bool gluons_only() const;
0094 
0095     /// Returns the number of gluons in the Col_amp as the number of gluons in the first Col_str.
0096     /// Note that the other Col_strs could have a different number of (contracted) gluons.
0097     /// (Intended for tree-level Col_ams with only one Col_str.)
0098     int n_gluon() const;
0099 
0100     /// Returns the number of quarks  in the Col_amp as the number of quarks in the first Col_str.
0101     /// Note that the other Col_strs could have a different number of (contracted) quarks.
0102     /// (Intended for tree-level Col_ams with only one Col_str.)
0103     int n_quark() const;
0104 
0105     /// Returns the number of quarks in the Col_amp after checking that each Col_str
0106     /// has the same number of quarks.
0107     int n_quark_check() const;
0108 
0109     /// Returns the number of gluons in the Col_amp after checking that each Col_str
0110     /// has the same number of gluons.
0111     int n_gluon_check() const;
0112 
0113     /// Returns the length of the longest Quark_line in any Col_str.
0114     int longest_quark_line() const;
0115 
0116     // Functions for manipulating the Col_amp
0117 
0118     /// Remove Col_strs with quark_lines with just 1 gluon, they are 0 as Tr[t^a]=0.
0119     void remove_1_rings();
0120 
0121     /// Remove quark_lines with no gluons, they are Nc if closed, and defined to be 1 if open.
0122     void remove_0_rings();
0123 
0124     /// Removes empty Col_strs, an empty Col_str means that all indices have been contracted,
0125     /// so the Col_str is equal to its Polynomial, which is moved to the scalar part
0126     /// of the Col_amp.
0127     void remove_empty_Col_strs();
0128 
0129     /// Compares col_strs in a Col_amp to collect similar col_strs
0130     /// and only store once in ca.
0131     void collect_col_strs();
0132 
0133     /// Normal orders all col_strs in ca.
0134     void normal_order_col_strs();
0135 
0136     /// Normal orders the individual col_strs and then
0137     /// orders the Col_strs using the order defined in
0138     /// the Col_str member function smallest.
0139     void normal_order();
0140 
0141     /// Function for simplifying an amplitude,
0142     /// removes 0 and 1-rings,
0143     /// compares col_strs,
0144     /// removes Col_strs multiplying 0 and
0145     /// simplifies Polynomials of the individual Col_strs.
0146     void simplify();
0147 
0148     /// Function for taking the conjugate of the Col_amp
0149     /// by conjugating each Col_str in ca and the
0150     /// Polynomial member Scalar.
0151     void conjugate();
0152 
0153     /// Contracts up to next to neighboring gluons in each Quark_line
0154     /// in each Col_str in each Col_amp, only intended for closed Quark_lines.
0155     void contract_next_neighboring_gluons( );
0156 
0157     /// Contract closed Quark_lines with only 2 gluons in
0158     /// each Quark_line in each Col_str in the Col_amp.
0159     /// This removes the 2-ring, replaces one of the gluon indices and
0160     /// multiplies with a factor tr[t^a t^a]=TR (no sum).
0161     /// only intended for fully contractable Col_strs.
0162     void contract_2_rings( );
0163 
0164     /// Function for contracting gluon indices within the Quark_lines.
0165     /// Checks only for ONE pair in each Quark_line.
0166     void contract_Quark_line_gluons( );
0167 
0168     /// Contracts one gluon, the first gluon in first Quark_line (in each Col_str),
0169     /// only intended for closed Quark_lines.
0170     void contract_a_gluon( );
0171 
0172     /// Function for contracting all gluon indices in a Col_amp,
0173     /// only intended for closed Quark_lines.
0174     void contract_all_gluons( );
0175 
0176     /// Function for contracting the (anti-)quarks in Ca1 with those
0177     /// in Ca2. The results is saved in this Col_amp.
0178     void contract_quarks( const Col_amp & Ca1, const Col_amp & Ca2 );
0179 
0180 private:
0181 
0182 
0183     /// Contracts one gluon, the first gluon in first Quark_line, only intended
0184     /// for closed Quark_lines. This function is a member of Col_amp as
0185     /// the result is contained in this Col_amp.
0186     void contract_a_gluon( Col_str & Cs );
0187 
0188     /// Function for contracting gluon indices within the same Quark_line.
0189     /// Checks only for ONE pair, i.e. if several gluon indices appear
0190     /// within the Quark_line, only one pair is contracted,
0191     /// only intended for closed Quark_lines.
0192     /// This function is a member of Col_amp as the result is a Col_amp.
0193     void contract_Quark_line_gluons( Quark_line & Ql );
0194 
0195     /// Function for contracting gluon indices within the same Quark_line.
0196     /// Checks only for ONE pair in each Quark_line in each Col_str,
0197     /// i.e. if several gluon indices appear within the Quark_line,
0198     /// only one pair is contracted.
0199     /// The function is only intended for closed Quark_lines.
0200     /// This function is a member of Col_amp as it saves the result in
0201     /// this Col_amp.
0202     void contract_Quark_line_gluons( Col_str & Cs );
0203 
0204     /// Function for contracting all gluon indices in a Col_str,
0205     /// assumes quarks already contracted and is only intended for
0206     /// closed Quark_lines. This function is a member of Col_amp as
0207     /// the result is contained in this Col_amp.
0208     void contract_all_gluons( Col_str & Cs );
0209 
0210     /// Converts a text string to a Col_amp,
0211     /// used by string constructor, and by read_in_Col_amp.
0212     /// The string should be of form
0213     /// Polynomial1* col_str1 + Polynomial2 col_str2,
0214     /// for example:
0215     /// Col_amp Ca("13*Nc*[(1,3,4,2)] +2 TR 5 Nc^(-3) [(1,4) (3,2)]").
0216     void Col_amp_of_str( const std::string str );
0217 
0218 };
0219 
0220 // Define operators involving Col_amp
0221 
0222 /// Define the operator << for col_amp
0223 std::ostream& operator<<( std::ostream& out, const col_amp & ca );
0224 
0225 /// Define the operator << for Col_amp.
0226 std::ostream& operator<<( std::ostream& out, const Col_amp & Ca );
0227 
0228 /// Define the operator == for two Col_amps.
0229 bool operator==( const Col_amp & Ca1, const Col_amp & Ca2 );
0230 
0231 /// Define the operator != for two Col_amps.
0232 bool operator!=( const Col_amp & Ca1, const Col_amp & Ca2 );
0233 
0234 /// Define the operator + for Col_amp and Col_str, adds Col_str Cs to ca.
0235 Col_amp operator+( const Col_amp & Ca, const Col_str & Cs );
0236 
0237 /// Define the operator + for Col_str and Col_amp, adds Col_str Cs to ca.
0238 Col_amp operator+( const Col_str & Cs, const Col_amp & Ca );
0239 
0240 /// Define the operator + for two Col_amps.
0241 /// Adds Scalars, and adds Col_strs.
0242 Col_amp operator+( const Col_amp & Ca1, const Col_amp & Ca2 );
0243 
0244 /// Define the operator += for two Col_amp+=Col_str.
0245 Col_amp operator+=( Col_amp & Ca, const Col_str & Cs );
0246 
0247 /// Define the operator += for two Col_amps.
0248 Col_amp operator+=( Col_amp & Ca1, const Col_amp & Ca2 );
0249 
0250 /// Define the operator - for two Col_amps.
0251 /// Subtract Scalar of Ca2 from Ca1, and subtracts (=appends with minus sign) Col_strs.
0252 Col_amp operator-( const Col_amp & Ca1, const Col_amp & Ca2 );
0253 
0254 /// Define the operator - for Col_amp-Col_str.
0255 Col_amp operator-( const Col_amp & Ca, const Col_str & Cs );
0256 
0257 /// Define the operator - for Col_str-Col_amp.
0258 Col_amp operator-( const Col_amp & Ca, const Col_str & Cs );
0259 
0260 /// Define the operator * for Col_amps and integers.
0261 Col_amp operator*( const Col_amp & Ca, const int i );
0262 
0263 /// Define the operator * for integers number and Col_amp.
0264 Col_amp operator*( const int i, const Col_amp & Ca );
0265 
0266 /// Define the operator * for Col_amps and complex number.
0267 Col_amp operator*( const Col_amp & Ca, const cnum c );
0268 
0269 /// Define the operator * for complex number and Col_amp.
0270 Col_amp operator*( const cnum c, const Col_amp & Ca );
0271 
0272 /// Define the operator * for Col_amp and double.
0273 Col_amp operator*( const Col_amp & Ca, const double d );
0274 
0275 /// Define the operator * for double and Col_amp.
0276 Col_amp operator*( const double d, const Col_amp & Ca );
0277 
0278 /// Define the operator * for Col_amp and Monomial.
0279 Col_amp operator*( const Col_amp & Ca, const Monomial & Mon );
0280 
0281 /// Define the operator * for Monomial and Col_amp.
0282 Col_amp operator*( const Monomial & Mon, const Col_amp & Ca );
0283 
0284 /// Define the operator * for Col_amp and Polynomial.
0285 Col_amp operator*( const Col_amp & Ca, const Polynomial & Poly );
0286 
0287 /// Define the operator * for Monomial and Col_amp.
0288 Col_amp operator*( const Polynomial & Poly, const  Col_amp & Ca );
0289 
0290 /// Define the operator * for Col_amp and Quark_line.
0291 Col_amp operator*( const Col_amp & Ca, const Quark_line & Ql );
0292 
0293 /// Define the operator * for Quark_line and Col_amp.
0294 Col_amp operator*( const Quark_line & Ql, const Col_amp & Ca );
0295 
0296 /// Define the operator * for Col_amp and Col_str.
0297 Col_amp operator*( const Col_amp & Ca, const Col_str & Cs );
0298 
0299 /// Define the operator * for Col_str and Col_amp.
0300 Col_amp operator*( const Col_str & Cs, const Col_amp & Ca );
0301 
0302 /// Define the operator * for Col_amps.
0303 Col_amp operator*( const Col_amp & Ca1, const Col_amp & Ca2 );
0304 
0305 /// Define the operator *= for two Col_amps.
0306 Col_amp operator*=( Col_amp & Ca1, const Col_amp & Ca2 );
0307 
0308 }// end namespace ColorFull
0309 
0310 #endif /* COLORFULL_Col_amp_h */