OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
FLieGenerator.h
Go to the documentation of this file.
1 #ifndef CLASSIC_FLieGenerator_HH
2 #define CLASSIC_FLieGenerator_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: FLieGenerator.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.3.2.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Template class: FLieGenerator<T,N>
13 //
14 // ------------------------------------------------------------------------
15 // Class category: FixedAlgebra
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2002/03/25 20:44:16 $
19 // $Author: dbruhwil $
20 //
21 // ------------------------------------------------------------------------
22 
23 #include "Algebra/Array1D.h"
24 #include <complex>
25 
26 // template <class T> class complex;
27 template <class T, int N> class FArray1D;
28 template <class T, int N, int M> class FMatrix;
29 template <class T, int N> class FTps;
30 
31 
32 // Template class FLieGenerator<T,N>.
33 // ------------------------------------------------------------------------
35 // The number of variables must be even, it is equal to 2*N, where N is
36 // a template parameter. The indices have the same range as the
37 // coefficients of the same order in an FTps<double,2*N> object.
38 
39 template <class T, int N>
41 
42 public:
43 
45  explicit FLieGenerator(int);
46 
48  // from an FTps<T,2*N> object.
49  FLieGenerator(const FTps<T, 2 * N> &, int);
50 
51  FLieGenerator();
54  const FLieGenerator &operator=(const FLieGenerator &);
55  bool operator==(const FLieGenerator &) const;
56 
57 
59  // Version for non-constant generator.
60  inline T *begin();
61 
63  // Version for non-constant generator.
64  inline T *end();
65 
67  // Version for constant generator.
68  inline const T *begin() const;
69 
71  // Version for constant generator.
72  inline const T *end() const;
73 
75  // Return a reference to element [b]n[/b].
76  // Result is undefined, if [b]n[/b] is out of range.
77  T &operator[](int n);
78 
80  // Return a reference to element [b]n[/b].
81  // Result is undefined, if [b]n[/b] is out of range.
82  const T &operator[](int n) const;
83 
84 
86  FLieGenerator operator-() const;
87 
89  FLieGenerator &operator*=(const T &);
90 
92  FLieGenerator &operator/=(const T &);
93 
96 
99 
100 
102  void clear();
103 
105  // Return partial derivative with respect to variable [b]var[/b].
106  FLieGenerator derivative(int var) const;
107 
109  bool isZero() const;
110 
112  FLieGenerator scale(const FLieGenerator &) const;
113 
115  // The coefficients of the source generator have type T, the
116  // elements of the matrix have type U, and the result of multiplying
117  // a T by a U must return a U.
118  template <class U>
120 
121 
123  inline int getOrder() const;
124 
126  inline int getBottomIndex() const;
127 
129  inline int getTopIndex() const;
130 
131 private:
132 
133  // Return size of the generator.
134  static inline int getSize(int order);
135 
136  // Return bottom index for given order.
137  static inline int getBottomIndex(int order);
138 
139  // Return top index for given order.
140  static inline int getTopIndex(int order);
141 
142  // The order of the generator, defines its size.
143  int itsOrder;
144 
145  // The bottom Index.
147 
148  // The top index.
149  int topIndex;
150 
151  // The representation of the coefficients.
153 };
154 
155 
156 // Global functions.
157 // ------------------------------------------------------------------------
158 
160 template <class T, int N>
163 
165 template <class T, int N>
168 
170 template <class T, int N>
172 operator*(const FLieGenerator<T, N> &, const T &);
173 
175 template <class T, int N>
177 operator*(const T &, const FLieGenerator<T, N> &);
178 
180 template <class T, int N>
183 
185 template <class T, int N>
187 operator/(const FLieGenerator<T, N> &, const T &);
188 
190 template <class T, int N>
192 real(const FLieGenerator<std::complex<T>, N> &);
193 
195 template <class T, int N>
197 imag(const FLieGenerator<std::complex<T>, N> &);
198 
200 template <class T, int N>
203 
205 template <class T, int N> FLieGenerator<T, N>
207 
209 template <class T, int N>
210 std::ostream &operator<<(std::ostream &, const FLieGenerator<T, N> &);
211 
213 
214 #endif // CLASSIC_FLieGenerator_HH
FLieGenerator< T, N > operator+(const FLieGenerator< T, N > &, const FLieGenerator< T, N > &)
Add.
FLieGenerator< T, N > operator*(const FLieGenerator< T, N > &, const T &)
Multiply by scalar.
FLieGenerator< T, N > operator-(const FLieGenerator< T, N > &, const FLieGenerator< T, N > &)
Subtract.
FLieGenerator< std::complex< T >, N > toComplex(const FLieGenerator< T, N > &)
Convert real generator to complex.
FLieGenerator< T, N > imag(const FLieGenerator< std::complex< T >, N > &)
Take imaginary part of a complex generator.
FLieGenerator< T, N > operator/(const FLieGenerator< T, N > &, const T &)
Divide by scalar.
FLieGenerator< T, N > PoissonBracket(const FLieGenerator< T, N > &, const FLieGenerator< T, N > &)
Poisson bracket of two Lie generators.
std::ostream & operator<<(std::ostream &, const FLieGenerator< T, N > &)
Output.
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
One-dimensional array.
Definition: Array1D.h:36
A templated representation for one-dimensional arrays.
Definition: FArray1D.h:39
A templated representation for matrices.
Definition: FMatrix.h:39
Truncated power series in N variables of type T.
Definition: FTps.h:45
A representation for a homogeneous polynomial, used as a Lie generator.
Definition: FLieGenerator.h:40
void clear()
Clear all coefficients.
int getBottomIndex() const
Return bottom index of this generator.
FLieGenerator & operator*=(const T &)
Multiply by scalar and assign.
const FLieGenerator & operator=(const FLieGenerator &)
FLieGenerator & operator-=(const FLieGenerator &)
Subtract vector and assign.
T * begin()
Get pointer to beginning of generator.
FLieGenerator & operator+=(const FLieGenerator &)
Add vector and assign.
static int getSize(int order)
T & operator[](int n)
Get element.
FLieGenerator & operator/=(const T &)
Divide by scalar and assign.
FLieGenerator derivative(int var) const
Partial derivative.
int getOrder() const
Return order of this generator.
bool isZero() const
Test for zero.
FLieGenerator scale(const FLieGenerator &) const
Scale monomial-wise.
FLieGenerator operator-() const
Change sign of generator.
T * end()
Get pointer past end of generator.
Array1D< T > itsCoeffs
FLieGenerator< U, N > transform(const FMatrix< U, 2 *N, 2 *N > &) const
Substitute matrix in Lie generator.
int getTopIndex() const
Return top index of this generator.
bool operator==(const FLieGenerator &) const