OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Vps.h
Go to the documentation of this file.
1 #ifndef CLASSIC_Vps_HH
2 #define CLASSIC_Vps_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Vps.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: Vps
13 //
14 // ------------------------------------------------------------------------
15 // Class category: Algebra
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/03/27 09:32:32 $
19 // $Author: fci $
20 //
21 // ------------------------------------------------------------------------
22 
23 template <class T> class Matrix;
24 template <class T> class Vps;
25 
26 #include "Algebra/Tps.h"
27 #include "Algebra/Vector.h"
28 #include <iosfwd>
29 
30 
31 // Template class Vps<T>
32 // ------------------------------------------------------------------------
34 // A vector of truncated power series with coefficients of type [b]T[/b]
35 // in [b]n[/b] variables. This class serves as the base class for maps.
36 
37 template <class T>
38 class Vps {
39 
40 public:
41 
43  // Construct [b]nDim[/b] series in [b]nVar[/b] variables each.
44  Vps(int nDim, int nVar = 0);
45 
47  // The constant part is zero.
48  // The linear part is set to the contents of [b]M[/b].
49  Vps(const Matrix<T> &M);
50 
52  // The constant part is set to the contents of [b]V[/b].
53  // The linear part is zero.
54  Vps(const Vector<T> &V);
55 
56  Vps();
57  Vps(const Vps<T> &rhs);
58  ~Vps();
59  Vps<T> &operator=(const Vps<T> &);
60 
62  // Return the component [b]index[/b].
63  // Throw RangeError, if [b]index[/b] is out of range.
64  const Tps<T> &getComponent(int index) const;
65 
67  // Set the component [b]index[/b].
68  // Throw RangeError, if [b]index[/b] is out of range.
69  void setComponent(int index, const Tps<T> &value);
70 
72  // Return the component [b]index[/b].
73  // Result is undefined, if [b]index[/b] is out of range.
74  Tps<T> &operator[](int index);
75 
77  // Set the component [b]index[/b].
78  // Result is undefined, if [b]index[/b] is out of range.
79  const Tps<T> &operator[](int index) const;
80 
82  void check() const;
83 
85  Vps<T> operator+() const;
86 
88  Vps<T> operator-() const;
89 
91  Vps<T> &operator*=(const Tps<T> &y);
92 
94  // Throw DivideError if constant part of [b]y[/b] is zero.
95  Vps<T> &operator/=(const Tps<T> &y);
96 
98  Vps<T> &operator*=(const T &y);
99 
101  // Throw DivideError if [b]y[/b] is zero.
102  Vps<T> &operator/=(const T &y);
103 
105  Vps<T> &operator+=(const Vps<T> &y);
106 
108  Vps<T> &operator-=(const Vps<T> &y);
109 
111  Vps<T> &operator+=(const Vector<T> &y);
112 
114  Vps<T> &operator-=(const Vector<T> &y);
115 
117  std::istream &get(std::istream &is);
118 
120  std::ostream &put(std::ostream &os) const;
121 
123  int getDimension() const;
124 
126  int getTopOrder() const;
127 
129  int getTruncOrder() const;
130 
132  int getVariables() const;
133 
135  Vps<T> filter(int lowOrder, int highOrder) const;
136 
138  Vps<T> truncate(int trunc);
139 
140 protected:
141 
142  // Representation of the Vps<T>.
144 
145  // The number of variables.
146  mutable int variables;
147 };
148 
149 
150 // Unchecked inline access to components.
151 // ------------------------------------------------------------------------
152 
153 template <class T> inline
155 { return data[index]; }
156 
157 template <class T> inline
158 const Tps<T> &Vps<T>::operator[](int index) const
159 { return data[index]; }
160 
161 
162 // Global Operators on Vps<T>
163 // ------------------------------------------------------------------------
164 
166 template <class T> Vps<T> operator*(const Vps<T> &x, const Tps<T> &y);
167 
169 template <class T> Vps<T> operator*(const Tps<T> &x, const Vps<T> &y);
170 
172 template <class T> Vps<T> operator*(const Vps<T> &x, const T &y);
173 
175 template <class T> Vps<T> operator*(const T &x, const Vps<T> &y);
176 
178 // Throw DivideError, if constant part of [b]y[/b] is zero.
179 template <class T> Vps<T> operator/(const Vps<T> &x, const Tps<T> &y);
180 
182 // Throw DivideError, if [b]y[/b] is zero.
183 template <class T> Vps<T> operator/(const Vps<T> &x, const T &y);
184 
186 template <class T> Vps<T> operator+(const Vps<T> &x, const Vps<T> &y);
187 
189 template <class T> Vps<T> operator-(const Vps<T> &x, const Vps<T> &y);
190 
192 template <class T> Vps<T> operator+(const Vps<T> &x, const Vector<T> &y);
193 
195 template <class T> Vps<T> operator-(const Vps<T> &x, const Vector<T> &y);
196 
198 template <class T> Vps<T> operator+(const Vector<T> &x, const Vps<T> &y);
199 
201 template <class T> Vps<T> operator-(const Vector<T> &x, const Vps<T> &y);
202 
204 template <class T> std::istream &operator>>(std::istream &, Vps<T> &x);
205 
207 template <class T> std::ostream &operator<<(std::ostream &, const Vps<T> &x);
208 
209 
210 // Implementation of global functions for class Vps<T>.
211 // ------------------------------------------------------------------------
212 
213 template <class T> inline
214 Vps<T> operator*(const Vps<T> &x, const Tps<T> &y)
215 { Vps<T> z(x); return z *= y; }
216 
217 template <class T> inline
218 Vps<T> operator*(const Tps<T> &x, const Vps<T> &y)
219 { Vps<T> z(x); return z *= y; }
220 
221 template <class T> inline
222 Vps<T> operator*(const Vps<T> &x, const T &y)
223 { Vps<T> z(x); return z *= y; }
224 
225 template <class T> inline
226 Vps<T> operator*(const T &x, const Vps<T> &y)
227 { Vps<T> z(x); return z *= y; }
228 
229 template <class T> inline
230 Vps<T> operator/(const Vps<T> &x, const Tps<T> &y)
231 { Vps<T> z(x); return z /= y; }
232 
233 template <class T> inline
234 Vps<T> operator/(const Vps<T> &x, const T &y)
235 { Vps<T> z(x); return z /= y; }
236 
237 
238 template <class T> inline
239 Vps<T> operator+(const Vps<T> &x, const Vps<T> &y)
240 { Vps<T> z(x); return z += y; }
241 
242 template <class T> inline
243 Vps<T> operator-(const Vps<T> &x, const Vps<T> &y)
244 { Vps<T> z(x); return z -= y; }
245 
246 template <class T> inline
247 Vps<T> operator+(const Vps<T> &x, const Vector<T> &y)
248 { Vps<T> z(x); return z += y; }
249 
250 template <class T> inline
251 Vps<T> operator-(const Vps<T> &x, const Vector<T> &y)
252 { Vps<T> z(x); return z -= y; }
253 
254 template <class T> inline
255 Vps<T> operator+(const Vector<T> &x, const Vps<T> &y)
256 { Vps<T> z(y); return z += x; }
257 
258 template <class T> inline
259 Vps<T> operator-(const Vector<T> &x, const Vps<T> &y)
260 { Vps<T> z(- y); return z += x; }
261 
262 template <class T> inline
263 std::istream &operator>>(std::istream &is, Vps<T> &x)
264 { return x.get(is); }
265 
266 template <class T> inline
267 std::ostream &operator<<(std::ostream &os, const Vps<T> &x)
268 { return x.put(os); }
269 
270 #endif // CLASSIC_Vps_HH
Matrix< T > operator+(const Matrix< T > &, const Matrix< T > &)
Matrix addition.
Definition: Matrix.h:275
Vps< T > & operator+=(const Vps< T > &y)
Addition.
Definition: Vps.hpp:169
Matrix< T > operator/(const Matrix< T > &, const T &)
Matrix divided by scalar.
Definition: Matrix.h:329
int variables
Definition: Vps.h:146
void setComponent(int index, const Tps< T > &value)
Set component.
Definition: Vps.hpp:98
Vps< T > operator+() const
Unary plus.
Definition: Vps.hpp:124
Vps< T > truncate(int trunc)
Truncate, may also increase truncation order.
Definition: Vps.hpp:299
std::ostream & put(std::ostream &os) const
Put a Vps&lt;T&gt; to stream os.
Definition: Vps.hpp:238
Definition: rbendmap.h:8
Vps< T > operator-() const
Unary minus.
Definition: Vps.hpp:130
int getDimension() const
Get dimension (number of Tps&lt;T&gt; components).
Definition: Vps.hpp:247
Vps()
Definition: Vps.hpp:40
Matrix< T > operator*(const Matrix< T > &, const Matrix< T > &)
Matrix multiply.
Definition: Matrix.h:297
int getTopOrder() const
Get highest order contained in any component.
Definition: Vps.hpp:253
Vps< T > & operator*=(const Tps< T > &y)
Multiply by Tps&lt;T&gt; and assign.
Definition: Vps.hpp:138
Vps< T > & operator=(const Vps< T > &)
Definition: Vps.hpp:84
std::istream & get(std::istream &is)
Get a Vps&lt;T&gt; from stream is.
Definition: Vps.hpp:213
int getTruncOrder() const
Get lowest truncation order in any component.
Definition: Vps.hpp:266
const Tps< T > & getComponent(int index) const
Get component.
Definition: Vps.hpp:92
int getVariables() const
Get number of variables (the same in all components).
Definition: Vps.hpp:279
Vps< T > filter(int lowOrder, int highOrder) const
Extract range of orders, set others to zero.
Definition: Vps.hpp:286
Truncated power series.
Definition: Tps.h:27
Vps< T > & operator/=(const Tps< T > &y)
Divide by Tps&lt;T&gt; and assign.
Definition: Vps.hpp:145
Vector truncated power series.
Definition: Vps.h:24
~Vps()
Definition: Vps.hpp:79
Matrix.
Definition: Matrix.h:38
void check() const
Check consistency.
Definition: Vps.hpp:108
One-dimensional array.
Definition: Array1D.h:36
Matrix< T > operator-(const Matrix< T > &, const Matrix< T > &)
Matrix subtraction.
Definition: Matrix.h:282
Vector.
Tps< T > & operator[](int index)
Get component.
Definition: Vps.h:154
std::istream & operator>>(std::istream &, LieMap< T > &x)
Extract LieMap&lt;T&gt; from stream.
Definition: LieMap.h:231
Array1D< Tps< T > > data
Definition: Vps.h:143
Vps< T > & operator-=(const Vps< T > &y)
Subtraction.
Definition: Vps.hpp:180