OPAL (Object Oriented Parallel Accelerator Library) 2022.1
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
23template <class T> class Matrix;
24template <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
37template <class T>
38class Vps {
39
40public:
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
140protected:
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
153template <class T> inline
155{ return data[index]; }
156
157template <class T> inline
158const Tps<T> &Vps<T>::operator[](int index) const
159{ return data[index]; }
160
161
162// Global Operators on Vps<T>
163// ------------------------------------------------------------------------
164
166template <class T> Vps<T> operator*(const Vps<T> &x, const Tps<T> &y);
167
169template <class T> Vps<T> operator*(const Tps<T> &x, const Vps<T> &y);
170
172template <class T> Vps<T> operator*(const Vps<T> &x, const T &y);
173
175template <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.
179template <class T> Vps<T> operator/(const Vps<T> &x, const Tps<T> &y);
180
182// Throw DivideError, if [b]y[/b] is zero.
183template <class T> Vps<T> operator/(const Vps<T> &x, const T &y);
184
186template <class T> Vps<T> operator+(const Vps<T> &x, const Vps<T> &y);
187
189template <class T> Vps<T> operator-(const Vps<T> &x, const Vps<T> &y);
190
192template <class T> Vps<T> operator+(const Vps<T> &x, const Vector<T> &y);
193
195template <class T> Vps<T> operator-(const Vps<T> &x, const Vector<T> &y);
196
198template <class T> Vps<T> operator+(const Vector<T> &x, const Vps<T> &y);
199
201template <class T> Vps<T> operator-(const Vector<T> &x, const Vps<T> &y);
202
204template <class T> std::istream &operator>>(std::istream &, Vps<T> &x);
205
207template <class T> std::ostream &operator<<(std::ostream &, const Vps<T> &x);
208
209
210// Implementation of global functions for class Vps<T>.
211// ------------------------------------------------------------------------
212
213template <class T> inline
214Vps<T> operator*(const Vps<T> &x, const Tps<T> &y)
215{ Vps<T> z(x); return z *= y; }
216
217template <class T> inline
218Vps<T> operator*(const Tps<T> &x, const Vps<T> &y)
219{ Vps<T> z(x); return z *= y; }
220
221template <class T> inline
222Vps<T> operator*(const Vps<T> &x, const T &y)
223{ Vps<T> z(x); return z *= y; }
224
225template <class T> inline
226Vps<T> operator*(const T &x, const Vps<T> &y)
227{ Vps<T> z(x); return z *= y; }
228
229template <class T> inline
230Vps<T> operator/(const Vps<T> &x, const Tps<T> &y)
231{ Vps<T> z(x); return z /= y; }
232
233template <class T> inline
234Vps<T> operator/(const Vps<T> &x, const T &y)
235{ Vps<T> z(x); return z /= y; }
236
237
238template <class T> inline
239Vps<T> operator+(const Vps<T> &x, const Vps<T> &y)
240{ Vps<T> z(x); return z += y; }
241
242template <class T> inline
243Vps<T> operator-(const Vps<T> &x, const Vps<T> &y)
244{ Vps<T> z(x); return z -= y; }
245
246template <class T> inline
247Vps<T> operator+(const Vps<T> &x, const Vector<T> &y)
248{ Vps<T> z(x); return z += y; }
249
250template <class T> inline
251Vps<T> operator-(const Vps<T> &x, const Vector<T> &y)
252{ Vps<T> z(x); return z -= y; }
253
254template <class T> inline
255Vps<T> operator+(const Vector<T> &x, const Vps<T> &y)
256{ Vps<T> z(y); return z += x; }
257
258template <class T> inline
259Vps<T> operator-(const Vector<T> &x, const Vps<T> &y)
260{ Vps<T> z(- y); return z += x; }
261
262template <class T> inline
263std::istream &operator>>(std::istream &is, Vps<T> &x)
264{ return x.get(is); }
265
266template <class T> inline
267std::ostream &operator<<(std::ostream &os, const Vps<T> &x)
268{ return x.put(os); }
269
270#endif // CLASSIC_Vps_HH
std::istream & operator>>(std::istream &, Vps< T > &x)
Extract from stream.
Definition: Vps.h:263
Vps< T > operator+(const Vps< T > &x, const Vps< T > &y)
Add.
Definition: Vps.h:239
Vps< T > operator/(const Vps< T > &x, const Tps< T > &y)
Divide.
Definition: Vps.h:230
Vps< T > operator*(const Vps< T > &x, const Tps< T > &y)
Multiply.
Definition: Vps.h:214
Vps< T > operator-(const Vps< T > &x, const Vps< T > &y)
Subtract.
Definition: Vps.h:243
std::ostream & operator<<(std::ostream &, const Vps< T > &x)
Insert to stream.
Definition: Vps.h:267
One-dimensional array.
Definition: Array1D.h:36
Matrix.
Definition: Matrix.h:39
Truncated power series.
Definition: Tps.h:46
Vector.
Definition: Vector.h:37
Vector truncated power series.
Definition: Vps.h:38
void setComponent(int index, const Tps< T > &value)
Set component.
Definition: Vps.hpp:98
int getTopOrder() const
Get highest order contained in any component.
Definition: Vps.hpp:253
Vps< T > & operator-=(const Vps< T > &y)
Subtraction.
Definition: Vps.hpp:180
std::ostream & put(std::ostream &os) const
Put a Vps<T> to stream os.
Definition: Vps.hpp:238
int variables
Definition: Vps.h:146
std::istream & get(std::istream &is)
Get a Vps<T> from stream is.
Definition: Vps.hpp:213
Array1D< Tps< T > > data
Definition: Vps.h:143
int getVariables() const
Get number of variables (the same in all components).
Definition: Vps.hpp:279
int getTruncOrder() const
Get lowest truncation order in any component.
Definition: Vps.hpp:266
~Vps()
Definition: Vps.hpp:79
Vps< T > operator+() const
Unary plus.
Definition: Vps.hpp:124
Vps< T > operator-() const
Unary minus.
Definition: Vps.hpp:130
Vps< T > truncate(int trunc)
Truncate, may also increase truncation order.
Definition: Vps.hpp:299
Tps< T > & operator[](int index)
Get component.
Definition: Vps.h:154
const Tps< T > & getComponent(int index) const
Get component.
Definition: Vps.hpp:92
int getDimension() const
Get dimension (number of Tps<T> components).
Definition: Vps.hpp:247
Vps< T > filter(int lowOrder, int highOrder) const
Extract range of orders, set others to zero.
Definition: Vps.hpp:286
Vps< T > & operator=(const Vps< T > &)
Definition: Vps.hpp:84
void check() const
Check consistency.
Definition: Vps.hpp:108
Vps< T > & operator*=(const Tps< T > &y)
Multiply by Tps<T> and assign.
Definition: Vps.hpp:138
Vps< T > & operator+=(const Vps< T > &y)
Addition.
Definition: Vps.hpp:169
Vps< T > & operator/=(const Tps< T > &y)
Divide by Tps<T> and assign.
Definition: Vps.hpp:145
Vps()
Definition: Vps.hpp:40