OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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
std::ostream & operator<<(std::ostream &, const Taylor< T > &)
Output.
Definition: Taylor.hpp:290
Taylor< T > PoissonBracket(const Taylor< T > &, const Taylor< T > &)
Poisson bracket of two Taylor seriess.
Definition: Taylor.hpp:274
Taylor< T > operator/(const Taylor< T > &, double)
Divide by scalar.
Definition: Taylor.hpp:261
Taylor< T > operator+(const Taylor< T > &, const Taylor< T > &)
Add.
Definition: Taylor.hpp:203
Taylor< T > operator-(const Taylor< T > &, const Taylor< T > &)
Subtract.
Definition: Taylor.hpp:219
Taylor< T > operator*(const Taylor< T > &, double)
Multiply by scalar.
Definition: Taylor.hpp:235
One-dimensional array.
Definition: Array1D.h:36
A representation for a Taylor series in one variable,.
Definition: Taylor.h:36
T * end()
Get pointer to end of series (one beyond highest term).
Definition: Taylor.hpp:83
void clear()
Clear all coefficients.
Definition: Taylor.hpp:161
int getOrder() const
Return order of this series.
Definition: Taylor.hpp:193
Taylor operator-() const
Change sign of series.
Definition: Taylor.hpp:108
T * begin()
Get pointer to beginning of series (zero-order term).
Definition: Taylor.hpp:69
Taylor & operator/=(const T &)
Divide by scalar and assign.
Definition: Taylor.hpp:124
T sum() const
Return sum of series.
Definition: Taylor.hpp:186
Taylor()
Definition: Taylor.hpp:41
Taylor & operator-=(const Taylor &)
Subtract series and assign.
Definition: Taylor.hpp:146
~Taylor()
Definition: Taylor.hpp:55
T & operator[](int n)
Get coefficient.
Definition: Taylor.hpp:96
Taylor & operator+=(const Taylor &)
Add series and assign.
Definition: Taylor.hpp:132
const Taylor & operator=(const Taylor &)
Definition: Taylor.hpp:61
Taylor integrate() const
Integrate with respect to the variable.
Definition: Taylor.hpp:168
Taylor & operator*=(const T &)
Multiply by scalar and assign.
Definition: Taylor.hpp:116
Array1D< T > itsCoeffs
Definition: Taylor.h:108