OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Taylor.h
Go to the documentation of this file.
1 #ifndef CLASSIC_Taylor_HH
2 #define CLASSIC_Taylor_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Taylor.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.2 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Template class: Taylor<T>
13 //
14 // ------------------------------------------------------------------------
15 // Class category: FixedAlgebra
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2001/11/15 08:52:26 $
19 // $Author: jsberg $
20 //
21 // ------------------------------------------------------------------------
22 
23 #include "Algebra/Array1D.h"
24 
25 
26 // Template class Taylor<T>.
27 // ------------------------------------------------------------------------
29 // whose coefficients are of type T. For some operations this class
30 // assumes that the type T has particular operations, like PoissonBracket.
31 // The class Taylor<T> is mainly meant for implementing a Lie generator
32 // with one parameter as a Taylor series in this parameter. This permits
33 // easy integration with respect to the parameter.
34 
35 template <class T>
36 class Taylor {
37 
38 public:
39 
41  explicit Taylor(int);
42 
43  Taylor();
44  Taylor(const Taylor &);
45  ~Taylor();
46  const Taylor &operator=(const Taylor &);
47 
48 
50  // Version for non-constant series.
51  inline T *begin();
52 
54  // Version for constant series.
55  inline const T *begin() const;
56 
58  // Version for non-constant series.
59  inline T *end();
60 
62  // Version for constant series.
63  inline const T *end() const;
64 
66  // Return a reference to coefficient of order [b]n[/b].
67  // Result is undefined, if [b]n[/b] is out of range.
68  T &operator[](int n);
69 
71  // Return a reference to constant coefficient of order [b]n[/b].
72  // Result is undefined, if [b]n[/b] is out of range.
73  const T &operator[](int n) const;
74 
75 
77  Taylor operator-() const;
78 
80  Taylor &operator*=(const T &);
81 
83  Taylor &operator/=(const T &);
84 
86  Taylor &operator+=(const Taylor &);
87 
89  Taylor &operator-=(const Taylor &);
90 
91 
93  void clear();
94 
96  Taylor integrate() const;
97 
99  T sum() const;
100 
101 
103  inline int getOrder() const;
104 
105 private:
106 
107  // The representation of the coefficients.
109 };
110 
111 
112 // Global functions.
113 // ------------------------------------------------------------------------
114 
116 template <class T>
117 Taylor<T>
118 operator+(const Taylor<T> &, const Taylor<T> &);
119 
121 template <class T>
122 Taylor<T>
123 operator-(const Taylor<T> &, const Taylor<T> &);
124 
126 template <class T>
127 Taylor<T>
128 operator*(const Taylor<T> &, double);
129 
131 template <class T>
132 Taylor<T>
133 operator*(double, const Taylor<T> &);
134 
136 template <class T>
137 Taylor<T>
138 operator/(const Taylor<T> &, double);
139 
141 // For this function the coefficients must have a Poisson bracket operation.
142 template <class T>
143 Taylor<T>
144 PoissonBracket(const Taylor<T> &, const Taylor<T> &);
145 
147 template <class T>
148 std::ostream &operator<<(std::ostream &, const Taylor<T> &);
149 
150 #include "FixedAlgebra/Taylor.hpp"
151 
152 #endif // CLASSIC_Taylor_HH
Matrix< T > operator+(const Matrix< T > &, const Matrix< T > &)
Matrix addition.
Definition: Matrix.h:275
Taylor & operator/=(const T &)
Divide by scalar and assign.
Definition: Taylor.hpp:123
~Taylor()
Definition: Taylor.hpp:54
T sum() const
Return sum of series.
Definition: Taylor.hpp:185
Matrix< T > operator/(const Matrix< T > &, const T &)
Matrix divided by scalar.
Definition: Matrix.h:329
Taylor()
Definition: Taylor.hpp:40
Taylor & operator-=(const Taylor &)
Subtract series and assign.
Definition: Taylor.hpp:145
Definition: rbendmap.h:8
void clear()
Clear all coefficients.
Definition: Taylor.hpp:160
Matrix< T > operator*(const Matrix< T > &, const Matrix< T > &)
Matrix multiply.
Definition: Matrix.h:297
Taylor & operator+=(const Taylor &)
Add series and assign.
Definition: Taylor.hpp:131
Array1D< T > itsCoeffs
Definition: Taylor.h:108
const Taylor & operator=(const Taylor &)
Definition: Taylor.hpp:60
Tps< T > PoissonBracket(const Tps< T > &x, const Tps< T > &y)
Poisson bracket.
Definition: LieMap.h:154
T * begin()
Get pointer to beginning of series (zero-order term).
Definition: Taylor.hpp:68
T * end()
Get pointer to end of series (one beyond highest term).
Definition: Taylor.hpp:82
Taylor integrate() const
Integrate with respect to the variable.
Definition: Taylor.hpp:167
T & operator[](int n)
Get coefficient.
Definition: Taylor.hpp:95
Taylor operator-() const
Change sign of series.
Definition: Taylor.hpp:107
int getOrder() const
Return order of this series.
Definition: Taylor.hpp:192
A representation for a Taylor series in one variable,.
Definition: Taylor.h:36
One-dimensional array.
Definition: Array1D.h:36
Matrix< T > operator-(const Matrix< T > &, const Matrix< T > &)
Matrix subtraction.
Definition: Matrix.h:282
Taylor & operator*=(const T &)
Multiply by scalar and assign.
Definition: Taylor.hpp:115