OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
TransportFun.h
Go to the documentation of this file.
1 #ifndef CLASSIC_TransportFun_HH
2 #define CLASSIC_TransportFun_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: TransportFun.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Template class: TransportFun<T,N>
13 //
14 // ------------------------------------------------------------------------
15 // Class category: FixedAlgebra
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/03/27 09:32:36 $
19 // $Author: fci $
20 //
21 // ------------------------------------------------------------------------
22 
23 #include <iosfwd>
24 
25 template <class T, int N> class FVector;
26 template <class T, int N> class TransportMap;
27 template <class T, int M, int N> class FMatrix;
28 
29 
30 // Template class TransportFun<T,N>.
31 // ------------------------------------------------------------------------
33 // All divide operations throw DivideError,
34 // if the constant part of the divisor is zero.
35 // The copy constructor, destructor, and assignment operator generated
36 // by the compiler perform the correct operation. For speed reasons
37 // they are not implemented.
38 
39 template <class T, int N>
40 class TransportFun {
41 
42 public:
43 
45  // Construct zero value.
46  TransportFun();
47 
49  TransportFun(const T &);
50 
52  TransportFun(int);
53 
55  TransportFun &operator=(const T &y);
56 
58  // Return value of the coefficient denoted by the index.
59  // The index zero stands for the constant term,
60  // any other value selects the derivative by the variable index+1.
61  // Return zero, if index is out of range.
62  const T getCoefficient(int index) const;
63 
65  // Return value of the second-order coefficient denoted by indices.
66  // Return zero, if indices are out of range.
67  const T getCoefficient(int index1, int index2) const;
68 
70  // Assign value of the coefficient denoted by the index.
71  // The index zero stands for the constant term,
72  // any other value selects the derivative by the variable index+1.
73  // Ignore, if index is out of range.
74  void setCoefficient(int index, const T &value);
75 
77  // Assign value of the second-order coefficient denoted by indices.
78  // Ignore, if indices are out of range.
79  void setCoefficient(int index1, int index2, const T &value);
80 
82  // Return value of the coefficient denoted by the index.
83  // The index zero stands for the constant term,
84  // any other value selects the derivative by the variable index+1.
85  // Result is undefined, if index is out of range.
86  inline const T operator[](int) const;
87 
89  // Return a reference to the coefficient denoted by the index.
90  // Result is undefined, if index is out of range.
91  // The index zero stands for the constant term,
92  // any other value selects the derivative by the variable index+1.
93  inline T &operator[](int);
94 
96  // Return value of the second-order coefficient denoted by indices.
97  // NOTE: i1 <= i2.
98  // Result is undefined, if indices are out of range.
99  inline const T operator()(int i1, int i2) const;
100 
102  // Return a reference to the second-order coefficient denoted by indices.
103  // NOTE: i1 <= i2.
104  // Result is undefined, if indices are out of range.
105  inline T &operator()(int i1, int i2);
106 
108  // Construct the variable identified by the index [b]var[/b],
109  // with total of [b]nVar[/b] variables.
110  static TransportFun makeVariable(int var);
111 
113  TransportFun operator+() const;
114 
116  TransportFun operator-() const;
117 
120 
123 
126 
129 
131  TransportFun &operator+=(const T &y);
132 
134  TransportFun &operator-=(const T &y);
135 
137  TransportFun &operator*=(const T &y);
138 
140  TransportFun &operator/=(const T &y);
141 
143  bool operator==(const TransportFun &y) const;
144 
146  bool operator==(const T &y) const;
147 
149  bool operator!=(const TransportFun &y) const;
150 
152  bool operator!=(const T &y) const;
153 
155  TransportFun inverse() const;
156 
158  TransportFun multiply(const TransportFun &y) const;
159 
161  TransportFun<T, N> multiplyVariable(int var) const;
162 
164  T evaluate(const FVector<T, N> &) const;
165 
167  // Substitute map [b]m[/b] in TransportFun, giving new TransportFun.
169 
171  // Substitute matrix [b]M[/b] in TransportFun, giving new TransportFun.
173 
175  // Expand Taylor series with coefficiens [b]series[/b] and order one.
176  TransportFun taylor(const T series[2]) const;
177 
179  std::istream &get(std::istream &is);
180 
182  std::ostream &put(std::ostream &os) const;
183 
184 private:
185 
187  static const int SIZE = (N + 1) *(N + 2) / 2;
188 
190  // data[0] is the constant term,
191  // data[v+1] is the coefficient of variable [b]v[/b].
193 };
194 
195 
196 // Global functions.
197 // ------------------------------------------------------------------------
198 
200 template <class T, int N>
202 
204 template <class T, int N>
206 
208 template <class T, int N>
210 
212 template <class T, int N>
214 
216 template <class T, int N>
218 
220 template <class T, int N>
222 
224 template <class T, int N>
226 
228 template <class T, int N>
230 
232 template <class T, int N>
234 
236 template <class T, int N>
238 
240 template <class T, int N>
242 
244 template <class T, int N>
246 
248 template <class T, int N>
249 bool operator==(const T &, const TransportFun<T, N> &);
250 
252 template <class T, int N>
253 bool operator!=(const T &, const TransportFun<T, N> &);
254 
256 template <class T, int N>
257 std::istream &operator>>(std::istream &is, TransportFun<T, N> &);
258 
260 template <class T, int N>
261 std::ostream &operator<<(std::ostream &os, const TransportFun<T, N> &);
262 
263 
264 // Implementation.
267 
268 #endif // CLASSIC_TransportFun_HH
Matrix< T > operator+(const Matrix< T > &, const Matrix< T > &)
Matrix addition.
Definition: Matrix.h:275
Matrix< T > operator/(const Matrix< T > &, const T &)
Matrix divided by scalar.
Definition: Matrix.h:329
TransportFun< T, N > multiplyVariable(int var) const
Multiply by variable var.
std::ostream & put(std::ostream &os) const
Write TransportFun on the stream [b]os[/b].
TransportFun()
Default constructor.
Definition: rbendmap.h:8
Transport map with values of type [b]T[/b] in [b]N[/b] variables.
Definition: Mapper.h:33
A templated representation for matrices.
Definition: IdealMapper.h:26
A templated representation for vectors.
Definition: PartBunchBase.h:26
static TransportFun makeVariable(int var)
Make variable.
Matrix< T > operator*(const Matrix< T > &, const Matrix< T > &)
Matrix multiply.
Definition: Matrix.h:297
const T getCoefficient(int index) const
Get coefficient.
const T operator()(int i1, int i2) const
Get coefficient.
TransportFun & operator+=(const TransportFun &y)
Add and assign.
static const int SIZE
Size of representation.
Definition: TransportFun.h:187
TransportFun & operator-=(const TransportFun &y)
Subtract and assign.
T data[SIZE]
Representation.
Definition: TransportFun.h:192
TransportFun taylor(const T series[2]) const
Taylor series.
Transport function in N variables of type T.
Definition: TransportFun.h:40
const T operator[](int) const
Get coefficient.
void setCoefficient(int index, const T &value)
Set coefficient.
TransportFun & operator=(const T &y)
Convert and assign.
TransportFun & operator*=(const TransportFun &y)
Multiply and assign.
TransportFun & operator/=(const TransportFun &y)
Approximate division and assignation.
TransportFun multiply(const TransportFun &y) const
Multiplication truncated to order one.
bool operator!=(const Offset &off1, const Offset &off2)
Definition: Offset.cpp:225
TransportFun operator+() const
Unary plus.
bool operator==(const TransportFun &y) const
Equality operator.
TransportFun operator-() const
Unary minus.
T evaluate(const FVector< T, N > &) const
Evaluate TransportFun at point.
TransportFun< T, N > substitute(const TransportMap< T, N > &m) const
Substitute.
Matrix< T > operator-(const Matrix< T > &, const Matrix< T > &)
Matrix subtraction.
Definition: Matrix.h:282
bool operator!=(const TransportFun &y) const
Inequality operator.
std::istream & operator>>(std::istream &, LieMap< T > &x)
Extract LieMap&lt;T&gt; from stream.
Definition: LieMap.h:231
bool operator==(const TwoPolynomial &left, const TwoPolynomial &right)
TransportFun inverse() const
Approximate reciprocal value 1/(*this).