herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
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 append( 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 
126 bool operator!=( const Polynomial & Poly1, const Polynomial & Poly2 );
127 
129 Polynomial operator+(const Polynomial & Poly, const Monomial & Mon );
130 
133 Polynomial operator+(const Monomial & Mon, const Polynomial & Poly );
134 
137 Polynomial operator+=( Polynomial & Poly, const Monomial & Mon );
138 
141 Polynomial operator+=( Polynomial & Poly1, const Polynomial & Poly2 );
142 
145 Polynomial operator-(const Polynomial & Poly, const Monomial & Mon);
146 
150 Polynomial operator-(const Monomial & Mon, const Polynomial & Poly);
151 
155 Polynomial operator+( const Polynomial & Poly1, const Polynomial & Poly2 );
156 
159 Polynomial operator-(const Polynomial & Poly1, const Polynomial & Poly2);
160 
165 Polynomial operator*( const Polynomial & Poly, int i );
166 
169 Polynomial operator*( int i, const Polynomial & Poly );
170 
175 Polynomial operator*( const Polynomial & Poly, const cnum c );
176 
178 Polynomial operator*( const cnum c, const Polynomial & Poly );
179 
184 Polynomial operator*( const Polynomial & Poly, const double d );
185 
187 Polynomial operator*( const double d, const Polynomial & Poly );
188 
192 Polynomial operator*( const Polynomial & Poly, const Monomial & Mon );
193 
196 Polynomial operator*( const Monomial & Mon, const Polynomial & Poly );
197 
199 Polynomial operator*( const Polynomial & Poly1, const Polynomial & Poly2 );
200 
203 Polynomial operator*=( Polynomial & Poly, const int i );
204 
207 Polynomial operator*=( Polynomial & Poly, const double d );
208 
211 Polynomial operator*=( Polynomial & Poly, const cnum c );
212 
215 Polynomial operator*=( Polynomial & Poly, const Monomial & Mon );
216 
219 Polynomial operator*=( Polynomial & Poly1, const Polynomial & Poly2 );
220 
221 }
222 
223 
224 #endif /* COLORFULL_Polynomial_h */
void write_out_Polynomial(std::string filename) const
Function for writing out the Polynomial to a file with name filename.
auto operator*(const ThreeVector< ValueA > &a, const ThreeVector< ValueB > &b) -> decltype(a.x() *b.x())
void normal_order()
Orders terms in Polynomial in a unique form, first according to pow_Nc+pow_CF, then according to pow_...
void append(const Monomial Mon)
Adding a Monomial term.
Definition: Polynomial.h:75
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 remove_CF()
Replaces CF with TR*Nc-TR/Nc.
void conjugate()
Take complex conjugate of the polynomial.
int size() const
Returns the number of terms in the Polynomial.
Definition: Polynomial.h:72
Monomial & at(int i)
Returns Monomial at place i.
Definition: Polynomial.h:69
void simplify()
Collects terms with same power of TR and Nc and Cf.
Polynomial()
Default constructor, leaves polynomial empty=1.
Definition: Polynomial.h:34
void erase(int i)
Erases 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
Returns 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)
void Polynomial_of_str(const std::string str)
Function for setting the Polynomial using a string, used by string constructor.
void clear()
Erases info in polynomial.
Definition: Polynomial.h:84