OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
FVps.h
Go to the documentation of this file.
1#ifndef CLASSIC_FVps_HH
2#define CLASSIC_FVps_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: FVps.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1.2.6 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Template Class: FVps<T,N>
13//
14// ------------------------------------------------------------------------
15// Class category: FixedAlgebra
16// ------------------------------------------------------------------------
17//
18// $Date: 2003/11/07 18:06:20 $
19// $Author: dbruhwil $
20//
21// ------------------------------------------------------------------------
22
23#include <algorithm>
24#include <iosfwd>
25
26template <class T> class Array1D;
27template <class T, int M, int N> class FMatrix;
28template <class T, int N> class FTps;
29template <class T, int N> class FVector;
30template <class T, int N> class LinearMap;
31template <class T, int N> class TransportMap;
32template <class T, int N> class FArray1D;
33
34// Template class FVps<T,N>
35// ------------------------------------------------------------------------
37
38template <class T, int N>
39class FVps {
40
41public:
42
44 // Construct zero map with given order [b]order[/b]
45 // and truncation [b]trunc[/b].
46 explicit FVps(int minOrder, int maxOrder, int trcOrder);
47
49 // The constant part is set to zero.
50 // The linear part is filled from [b]M[/b].
51 explicit FVps(const FMatrix<T, N, N> &M);
52
54 // The constant part is filled from [b]V[/b].
55 explicit FVps(const FVector<T, N> &V);
56
58 explicit FVps(const LinearMap<T, N> &rhs);
59
61 explicit FVps(const TransportMap<T, N> &rhs);
62
63 FVps();
64 FVps(const FVps &);
65 ~FVps();
66 const FVps &operator=(const FVps &);
67
69 void identity();
70
72 void zero();
73
75 // Return value of component [b]n[/b].
76 // Throw RangeError, if [b]n[/b] is out of range.
77 const FTps<T, N> &getComponent(int n) const;
78
80 // Assign value of component [b]n[/b].
81 // Throw RangeError, if [b]n[/b] is out of range.
82 void setComponent(int, const FTps<T, N> &);
83
85 // Return constant reference to component [b]n[/b].
86 // Result undefined for index out of range.
87 inline const FTps<T, N> &operator[](int) const;
88
90 // Return reference to component [b]n[/b].
91 // Result undefined for index out of range.
92 inline FTps<T, N> &operator[](int);
93
95 // Return the number of components.
96 inline int getDimension() const;
97
99 // This is the same in all components.
100 inline int getVariables() const;
101
103 int getMinOrder() const;
104
106 // If necessary, this function will insert zeroes or modify the
107 // maximum order. It will not modify the truncation order.
108 void setMinOrder(int order);
109
111 int getMaxOrder() const;
112
114 // If necessary, this function will insert zeroes or modify the minimum
115 // or maximum orders. It will not modify the truncation order.
116 void setMaxOrder(int order);
117
119 int getTopOrder() const;
120
122 int getTruncOrder() const;
123
125 void setTruncOrder(int order);
126
128 FVps filter(int minOrder, int maxOrder, int trcOrder = (FTps<T, N>::EXACT)) const;
129
131 // Limit truncation order to [b]trunc[/b].
132 FVps truncate(int trunc);
133
135 FVps operator+() const;
136
138 FVps operator-() const;
139
141 FVps &operator+=(const FVps &rhs);
142
144 FVps &operator-=(const FVps &rhs);
145
147 FVps &operator+=(const FVector<T, N> &);
148
150 FVps &operator-=(const FVector<T, N> &);
151
153 FVps &operator*=(const FTps<T, N> &rhs);
154
156 FVps operator*(const FVps<T, N>& rhs) const;
157
159 // Throw DivideError if constant part of [b]rhs[/b] is zero.
160 FVps &operator/=(const FTps<T, N> &rhs);
161
163 FVps &operator*=(const T &rhs);
164
166 // Throw DivideError if [b]rhs[/b] is zero.
167 FVps &operator/=(const T &rhs);
168
170 // Invert a map.
171 FVps inverse(int trunc = (FTps<T, N>::EXACT)) const;
172
174 // Invert a map.
175 FVps myInverse(int trunc = (FTps<T, N>::EXACT)) const;
176
178 // Return partial derivative with respect to variable [b]var[/b].
179 FVps derivative(int var) const;
180
182 // Return partial integral with respect to variable [b]var[/b].
183 // Throw LogicalError for a constant.
184 FVps integral(int var) const;
185
187 // This is equivalent to evaluating the map at the origin.
189
191 // This is equivalent to evaluating the map at point [b]P[/b].
193
196
198 // This is equivalent to the Jacobian matrix at point [b]P[/b].
200
202 // NB: This routine is NOT guaranteed to return min <= max <= trc.
203 // If min exceeds max, then f(rhs(z)) = 0 + O(z^{trc+1}).
204 // This possibility must be checked for.
205 Array1D<int> getSubstOrders(const FVps<T, N> &rhs, int trunc = (FTps<T, N>::EXACT)) const;
206
208 // Use the linear map with matrix representation [b]M[/b] to transform the
209 // order n part of an FVps; leave remaining parts unchanged. Return a new FVps.
210 // NB: This method uses static local memory.
211 FVps substitute(const FMatrix<T, N, N> &M, int n) const;
212
214 // Use the linear map with matrix representation [b]M[/b] to transform the
215 // order nl through nh parts of an FVps; leave remaining parts unchanged.
216 // Return a new FVps.
217 // NB: This method uses static local memory.
218 FVps substitute(const FMatrix<T, N, N> &M, int nl, int nh) const;
219
221 // Use the linear map with matrix representation [b]M[/b]
222 // to transform an FVps. Return a new FVps.
223 // NB: This method (indirectly) uses static local memory.
224 FVps substitute(const FMatrix<T, N, N> &M) const;
225
227 // Use the (nonlinear) map [b]m[/b] to transform an FVps. Return a new FVps.
228 // NB: This method uses static local memory.
229 FVps substitute(const FVps<T, N> &m, int trunc = (FTps<T, N>::EXACT)) const;
230
232 FVps substituteInto(const FMatrix<T, N, N> &lhs) const;
233
235 // Computes a FTps by multiplying the FTps of FVps using the powers specified by [b]power[/b].
236 FTps<T, N> getFTps(const FArray1D<int, N>& power) const;
237
239 std::istream &get(std::istream &is);
240
242 std::ostream &put(std::ostream &os) const;
243
244protected:
245
246 // Representation of the FVps.
248
249};
250
251
252// Global functions.
253// ------------------------------------------------------------------------
254
256template <class T, int N>
257FVps<T, N> operator+(const FVps<T, N> &lhs, const FVps<T, N> &rhs);
258
260template <class T, int N>
261FVps<T, N> operator-(const FVps<T, N> &lhs, const FVps<T, N> &rhs);
262
264template <class T, int N>
265FVps<T, N> operator+(const FVps<T, N> &lhs, const FVector<T, N> &rhs);
266
268template <class T, int N>
269FVps<T, N> operator-(const FVps<T, N> &lhs, const FVector<T, N> &rhs);
270
272template <class T, int N>
273FVps<T, N> operator+(const FVector<T, N> &lhs, const FVps<T, N> &rhs);
274
276template <class T, int N>
277FVps<T, N> operator-(const FVector<T, N> &lhs, const FVps<T, N> &rhs);
278
280template <class T, int N>
281FVector<T, N> operator*(const FVps<T, N> &lhs, const FVector<T, N>& rhs);
282
284template <class T, int N>
285FVps<T, N> operator*(const FVps<T, N> &lhs, const FTps<T, N> &rhs);
286
288template <class T, int N>
289FVps<T, N> operator*(const FTps<T, N> &lhs, const FVps<T, N> &rhs);
290
292template <class T, int N>
293FVps<T, N> operator*(const FVps<T, N> &lhs, const T &rhs);
294
296template <class T, int N>
297FVps<T, N> operator*(const T &lhs, const FVps<T, N> &rhs);
298
300template <class T, int N>
301FVps<T, N> operator*(const FMatrix<T, N, N> &lhs, const FVps<T, N> &rhs);
302
304// Throw DivideError, if constant part of [b]rhs[/b] is zero.
305template <class T, int N>
306FVps<T, N> operator/(const FVps<T, N> &lhs, const FTps<T, N> &rhs);
307
309// Throw DivideError, if [b]rhs[/b] is zero.
310template <class T, int N>
311FVps<T, N> operator/(const FVps<T, N> &lhs, const T &rhs);
312
314// Return the series exp(:H:) M,
315// the Lie transform exp(:H:) acting on the map [b]M[/b].
316template <class T, int N> FVps<T, N>
317ExpMap(const FTps<T, N> &H, const FVps<T, N> &M, int trunc = (FTps<T, N>::EXACT));
318
320template <class T, int N> FVps<T, N>
321PoissonBracket(const FTps<T, N> &x, const FVps<T, N> &y, int trunc = (FTps<T, N>::EXACT));
322
324template <class T, int N>
325std::istream &operator>>(std::istream &is, FVps<T, N> &);
326
328template <class T, int N>
329std::ostream &operator<<(std::ostream &os, const FVps<T, N> &vps);
330
331
332// Implementation.
333#include "FixedAlgebra/FVps.hpp"
334
335#endif // CLASSIC_FVps_HH
FVps< T, N > ExpMap(const FTps< T, N > &H, const FVps< T, N > &M, int trunc=(FTps< T, N >::EXACT))
Build the exponential series.
Definition: FVps.hpp:1201
FVps< T, N > operator/(const FVps< T, N > &lhs, const FTps< T, N > &rhs)
Divide.
Definition: FVps.hpp:1185
FVector< T, N > operator*(const FVps< T, N > &lhs, const FVector< T, N > &rhs)
Multiply.
Definition: FVps.hpp:1137
FVps< T, N > operator-(const FVps< T, N > &lhs, const FVps< T, N > &rhs)
Subtract.
Definition: FVps.hpp:1097
std::istream & operator>>(std::istream &is, FVps< T, N > &)
Extract FVps from stream [b]is[/b].
Definition: FVps.hpp:1275
FVps< T, N > operator+(const FVps< T, N > &lhs, const FVps< T, N > &rhs)
Add.
Definition: FVps.hpp:1089
FVps< T, N > PoissonBracket(const FTps< T, N > &x, const FVps< T, N > &y, int trunc=(FTps< T, N >::EXACT))
Poisson bracket.
Definition: FVps.hpp:1266
std::ostream & operator<<(std::ostream &os, const FVps< T, N > &vps)
Insert FVps to stream [b]os[/b].
Definition: FVps.hpp:1281
Vector truncated power series in n variables.
Definition: FVps.h:39
FVps integral(int var) const
Partial integral.
Definition: FVps.hpp:532
const FVps & operator=(const FVps &)
Definition: FVps.hpp:104
Array1D< int > getSubstOrders(const FVps< T, N > &rhs, int trunc=(FTps< T, N >::EXACT)) const
Return orders {min, max, trc} of f(rhs(z)).
Definition: FVps.hpp:594
FTps< T, N > data[N]
Definition: FVps.h:247
void setComponent(int, const FTps< T, N > &)
Set component.
Definition: FVps.hpp:132
FVps & operator*=(const FTps< T, N > &rhs)
Multiply and assign.
Definition: FVps.hpp:282
void setMinOrder(int order)
Set minimum order.
Definition: FVps.hpp:175
std::ostream & put(std::ostream &os) const
Put a FVps to stream [b]os[/b].
Definition: FVps.hpp:1078
void setTruncOrder(int order)
Set truncation order for all components.
Definition: FVps.hpp:217
FVector< T, N > constantTerm() const
Extract the constant part of the map.
Definition: FVps.hpp:540
int getTopOrder() const
Get highest order contained in any component.
Definition: FVps.hpp:197
FVps substituteInto(const FMatrix< T, N, N > &lhs) const
Substitute map into matrix.
Definition: FVps.hpp:1021
FVps substitute(const FMatrix< T, N, N > &M, int n) const
Substitute.
Definition: FVps.hpp:608
FTps< T, N > getFTps(const FArray1D< int, N > &power) const
Get a FTps that is a combination of the polynomials of FVps.
Definition: FVps.hpp:1034
void zero()
Set to zero.
Definition: FVps.hpp:117
int getMaxOrder() const
Get highest order contained in any component.
Definition: FVps.hpp:181
FVps operator+() const
Unary plus.
Definition: FVps.hpp:240
FVps myInverse(int trunc=(FTps< T, N >::EXACT)) const
Inverse.
Definition: FVps.hpp:441
int getVariables() const
Get number of variables.
Definition: FVps.hpp:159
FVps & operator+=(const FVps &rhs)
Add and assign.
Definition: FVps.hpp:254
FVps truncate(int trunc)
Truncate.
Definition: FVps.hpp:234
~FVps()
Definition: FVps.hpp:99
void setMaxOrder(int order)
Set maximum order.
Definition: FVps.hpp:191
FVps operator*(const FVps< T, N > &rhs) const
Multiply.
Definition: FVps.hpp:288
FVps derivative(int var) const
Partial derivative.
Definition: FVps.hpp:524
FVps & operator/=(const FTps< T, N > &rhs)
Divide and assign.
Definition: FVps.hpp:338
const FTps< T, N > & getComponent(int n) const
Get component.
Definition: FVps.hpp:123
FVps filter(int minOrder, int maxOrder, int trcOrder=(FTps< T, N >::EXACT)) const
Extract given range of orders, with truncation.
Definition: FVps.hpp:223
void identity()
Set to identity.
Definition: FVps.hpp:111
int getDimension() const
Get dimension.
Definition: FVps.hpp:153
std::istream & get(std::istream &is)
Get a FVps from stream [b]is[/b].
Definition: FVps.hpp:1057
FVps()
Definition: FVps.hpp:46
FVps & operator-=(const FVps &rhs)
Subtract and assign.
Definition: FVps.hpp:261
int getTruncOrder() const
Get lowest truncation order in any component.
Definition: FVps.hpp:207
FVps inverse(int trunc=(FTps< T, N >::EXACT)) const
Inverse.
Definition: FVps.hpp:360
int getMinOrder() const
Get lowest order contained in any component.
Definition: FVps.hpp:165
const FTps< T, N > & operator[](int) const
Get Component.
Definition: FVps.hpp:141
FMatrix< T, N, N > linearTerms() const
Extract the linear part of the map.
Definition: FVps.hpp:561
FVps operator-() const
Unary minus.
Definition: FVps.hpp:246
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 templated representation for vectors.
Definition: FVector.h:38
Linear map with values of type [b]T[/b] in [b]N[/b] variables.
Definition: LinearMap.h:38
Transport map with values of type [b]T[/b] in [b]N[/b] variables.
Definition: TransportMap.h:39