colorfull is hosted by Hepforge, IPPP Durham
ColorFull  1.1
/data/Documents/eclipse/workspace/ColorFull/Polynomial.h
Go to the documentation of this file.
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 */
int size() const
Returns the number of terms in the Polynomial.
Definition: Polynomial.h:72
void read_in_Polynomial(std::string filename)
void simplify()
Collects terms with same power of TR and Nc and Cf.
void write_out_Polynomial(std::string filename) const
void clear()
Erases info in polynomial.
Definition: Polynomial.h:84
bool empty() const
Is the polynomial empty?
Definition: Polynomial.h:81
Col_amp operator*(const Col_amp &Ca, const int i)
Define the operator * for Col_amps and integers.
bool operator==(const Col_amp &Ca1, const Col_amp &Ca2)
Define the operator == for two Col_amps.
Col_amp operator+=(Col_amp &Ca, const Col_str &Cs)
Define the operator += for two Col_amp+=Col_str.
std::vector< Monomial > polynomial
Definition: Polynomial.h:22
Polynomial()
Default constructor, leaves polynomial empty=1.
Definition: Polynomial.h:34
Definition: Col_amp.h:15
Definition: Polynomial.h:30
std::ostream & operator<<(std::ostream &out, const col_amp &ca)
Define the operator << for col_amp.
const Monomial & at(int i) const
Returns Monomial at place i.
Definition: Polynomial.h:66
void erase(int i)
Erases the Monomial at place i.
Definition: Polynomial.h:78
Col_amp operator+(const Col_amp &Ca, const Col_str &Cs)
Define the operator + for Col_amp and Col_str, adds Col_str Cs to ca.
std::complex< double > cnum
A complex number, needed as amplitudes in general are complex.
Definition: types.h:20
Monomial & at(int i)
Returns Monomial at place i.
Definition: Polynomial.h:69
Definition: Monomial.h:23
Col_amp operator*=(Col_amp &Ca1, const Col_amp &Ca2)
Define the operator *= for two Col_amps.
void remove_CF()
Replaces CF with TR*Nc-TR/Nc.
bool operator!=(const Col_amp &Ca1, const Col_amp &Ca2)
Define the operator != for two Col_amps.
polynomial poly
Definition: Polynomial.h:55
void append(const Monomial Mon)
Adding a Monomial term.
Definition: Polynomial.h:75
Col_amp operator-(const Col_amp &Ca1, const Col_amp &Ca2)