herwig is hosted by Hepforge, IPPP Durham
Herwig  7.1.5
Polynomial.h
1 // -*- C++ -*-
2 /*
3  * Polynomial.h
4  * Contains declaration of the class Polynomial and associated types and operators.
5  * Created on: Jul 7, 2010
6  * Author: Malin Sjodahl
7  */
8 
9 #ifndef COLORFULL_Polynomial_h
10 #define COLORFULL_Polynomial_h
11 
12 #include "Monomial.h"
13 
14 namespace ColorFull {
15 
22 typedef std::vector < Monomial > polynomial;
23 
24 
30 class Polynomial {
31 public:
32 
35 
40  Polynomial( const std::string str );
41 
45  Polynomial( double dnum );
46 
50  Polynomial( int num );
51 
55  polynomial poly;
56 
59  void read_in_Polynomial( std::string filename );
60 
63  void write_out_Polynomial( std::string filename ) const;
64 
66  const Monomial& at( int i ) const {return poly.at(i);}
67 
69  Monomial& at( int i ) {return poly.at(i);}
70 
72  int size() const {return poly.size();}
73 
75  void push_back( const Monomial Mon ) {poly.push_back(Mon);}
76 
78  void erase( int i ) {poly.erase(poly.begin() + i);}
79 
81  bool empty() const {return poly.empty();}
82 
84  void clear() {poly.clear();}
85 
88  void conjugate();
89 
91  void simplify();
92 
94  void remove_CF();
95 
99  void normal_order();
100 
101 private:
103  int factorial (int i) const;
104 
109  void Polynomial_of_str( const std::string str );
110 
111 };
112 
114 std::ostream& operator<<(std::ostream& out, const Polynomial & Poly);
115 
117 std::ostream& operator<<(std::ostream& out, const polynomial & poly);
118 
122 bool operator==( const Polynomial & Poly1, const Polynomial & Poly2);
123 
124 
127 bool operator!=( const Polynomial & Poly1, const Polynomial & Poly2 );
128 
130 Polynomial operator+(const Polynomial & Poly, const Monomial & Mon );
131 
134 Polynomial operator+(const Monomial & Mon, const Polynomial & Poly );
135 
138 Polynomial operator+=( Polynomial & Poly, const Monomial & Mon );
139 
142 Polynomial operator+=( Polynomial & Poly1, const Polynomial & Poly2 );
143 
146 Polynomial operator-(const Polynomial & Poly, const Monomial & Mon);
147 
151 Polynomial operator-(const Monomial & Mon, const Polynomial & Poly);
152 
156 Polynomial operator+( const Polynomial & Poly1, const Polynomial & Poly2 );
157 
160 Polynomial operator-(const Polynomial & Poly1, const Polynomial & Poly2);
161 
166 Polynomial operator*(const Polynomial & Poly, int i);
167 
170 Polynomial operator*(int i, const Polynomial & Poly);
171 
176 Polynomial operator*( const Polynomial & Poly, const cnum c);
177 
179 Polynomial operator*( const cnum c, const Polynomial & Poly);
180 
185 Polynomial operator*( const Polynomial & Poly, const double d );
186 
188 Polynomial operator*( const double d, const Polynomial & Poly );
189 
193 Polynomial operator*( const Polynomial & Poly, const Monomial & Mon );
194 
197 Polynomial operator*( const Monomial & Mon, const Polynomial & Poly );
198 
200 Polynomial operator*( const Polynomial & Poly1, const Polynomial & Poly2 );
201 
202 }
203 
204 
205 #endif /* COLORFULL_Polynomial_h */
void write_out_Polynomial(std::string filename) const
Function for writing out the Quark_linePolynomial to a file with name filename.
void normal_order()
Order terms in Polynomial in a unique form, first according to pow_Nc+pow_CF, then according to pow_N...
bool operator==(const LorentzVector< Value > &a, const LorentzVector< Value > &b)
int factorial(int i) const
The factorial of an int.
For containing a Polynomial (in Nc, CF and TR), as a sum of Monomials.
Definition: Polynomial.h:30
bool empty() const
Is the polynomial empty?
Definition: Polynomial.h:81
Generator< Sum< Density1, Density2 > > operator+(const Generator< Density1 > &first, const Generator< Density2 > &second)
Construct the sum of two densities.
void push_back(const Monomial Mon)
Adding Monomial term.
Definition: Polynomial.h:75
void remove_CF()
Replaces CF as TR*Nc-TR/Nc.
void conjugate()
Take complex conjugate of the polynomial.
int size() const
Returning number of terms in Polynomial.
Definition: Polynomial.h:72
Monomial & at(int i)
Returning Monomial at place i.
Definition: Polynomial.h:69
void simplify()
Collects terms with same power of TR and Nc and Cf.
Polynomial()
Default constructor.
Definition: Polynomial.h:34
void erase(int i)
Erase the Monomial at place i.
Definition: Polynomial.h:78
A class to contain the factor of form TR^a*Nc^b*CF^c*int_part*cnum_part, where the powers a...
Definition: Monomial.h:23
const Monomial & at(int i) const
Returning Monomial at place i.
Definition: Polynomial.h:66
void read_in_Polynomial(std::string filename)
Function for reading in the Polynomial from the file filename, uses Polynomial_of_str.
polynomial poly
Contains the polynomial, a sum of Monomials, as an std::vector of Monomials.
Definition: Polynomial.h:55
vector< T > & operator<<(vector< T > &tv, const U &u)
BinaryOpTraits< ValueA, ValueB >::MulT operator*(const ThreeVector< ValueA > &a, const ThreeVector< ValueB > &b)
void Polynomial_of_str(const std::string str)
Function for setting the Polynomial using a string, used by string constructor.
void clear()
Erase info in polynomial.
Definition: Polynomial.h:84