OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
LinearMap.h
Go to the documentation of this file.
1 #ifndef CLASSIC_LinearMap_HH
2 #define CLASSIC_LinearMap_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: LinearMap.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Template Class: LinearMap<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 M, int N> class FMatrix;
26 template <class T, int N> class LinearFun;
27 template <class T, int N> class FVector;
28 template <class T, int N> class FVps;
29 
30 
31 // Template class LinearMap<T,N>
32 // ------------------------------------------------------------------------
34 // The copy constructor, destructor, and assignment operator generated
35 // by the compiler do the correct thing, and are not defined for speed.
36 
37 template <class T, int N>
38 class LinearMap {
39 
40 public:
41 
43  // Construct identity map.
44  LinearMap();
45 
47  explicit LinearMap(const FVps<T, N> &rhs);
48 
50  // The constant part is set to zero.
51  // The linear part is filled from [b]M[/b].
52  explicit LinearMap(const FMatrix<T, N, N> &M);
53 
55  // The constant part is filled from [b]V[/b].
56  // The linear part is set to the identity.
57  explicit LinearMap(const FVector<T, N> &V);
58 
60  // Return value of component [b]n[/b].
61  // Throw RangeError, if [b]n[/b] is out of range.
62  const LinearFun<T, N> &getComponent(int n) const;
63 
65  // Assign value of component [b]n[/b].
66  // Throw RangeError, if [b]n[/b] is out of range.
67  void setComponent(int, const LinearFun<T, N> &);
68 
70  // Return reference to component [b]n[/b].
71  // Result is undefined, if index is out of range.
73 
75  // Return constant reference to component [b]n[/b].
76  // Result is undefined, if index is out of range.
77  const LinearFun<T, N> &operator[](int) const;
78 
80  LinearMap operator+() const;
81 
83  LinearMap operator-() const;
84 
87 
89  // Throw DivideError if constant part of [b]rhs[/b] is zero.
91 
93  LinearMap &operator*=(const T &rhs);
94 
96  // Throw DivideError if [b]rhs[/b] is zero.
97  LinearMap &operator/=(const T &rhs);
98 
100  LinearMap &operator+=(const LinearMap &rhs);
101 
103  LinearMap &operator-=(const LinearMap &rhs);
104 
107 
110 
112  std::istream &get(std::istream &is);
113 
115  std::ostream &put(std::ostream &os) const;
116 
118  LinearMap inverse() const;
119 
121  void identity();
122 
124  FVector<T, N> constantTerm(const FVector<T, N> &P) const;
125 
128  FVector<T, N> constantTerm() const;
129 
131  // This is equivalent to extracting linear part.
133 
135  LinearMap substitute(const FMatrix<T, N, N> &rhs) const;
136 
138  LinearMap substitute(const LinearMap &rhs) const;
139 
141  LinearMap substituteInto(const FMatrix<T, N, N> &lhs) const;
142 
143 protected:
144 
145  // Representation of the LinearMap.
147 };
148 
149 
150 // Global functions.
151 // ------------------------------------------------------------------------
152 
154 template <class T, int N>
156 
158 template <class T, int N>
160 
162 template <class T, int N>
163 LinearMap<T, N> operator*(const LinearMap<T, N> &lhs, const T &rhs);
164 
166 template <class T, int N>
167 LinearMap<T, N> operator*(const T &lhs, const LinearMap<T, N> &rhs);
168 
170 template <class T, int N>
172 
174 // Throw DivideError, if constant part of [b]rhs[/b] is zero.
175 template <class T, int N>
177 
179 // Throw DivideError, if [b]rhs[/b] is zero.
180 template <class T, int N>
181 LinearMap<T, N> operator/(const LinearMap<T, N> &lhs, const T &rhs);
182 
184 template <class T, int N>
186 
188 template <class T, int N>
190 
192 template <class T, int N>
194 
196 template <class T, int N>
198 
200 template <class T, int N>
202 
204 template <class T, int N>
206 
208 template <class T, int N>
209 std::istream &operator>>(std::istream &is, LinearMap<T, N> &);
210 
212 template <class T, int N>
213 std::ostream &operator<<(std::ostream &os, const LinearMap<T, N> &vps);
214 
215 
216 // Implementation.
218 
219 #endif // CLASSIC_LinearMap_HH
Matrix< T > operator+(const Matrix< T > &, const Matrix< T > &)
Matrix addition.
Definition: Matrix.h:275
LinearMap & operator-=(const LinearMap &rhs)
Subtract.
Definition: LinearMap.hpp:147
LinearFun< T, N > data[N]
Definition: LinearMap.h:146
Matrix< T > operator/(const Matrix< T > &, const T &)
Matrix divided by scalar.
Definition: Matrix.h:329
void setComponent(int, const LinearFun< T, N > &)
Set component.
Definition: LinearMap.hpp:76
Definition: rbendmap.h:8
A templated representation for matrices.
Definition: IdealMapper.h:26
A templated representation for vectors.
Definition: PartBunchBase.h:26
Matrix< T > operator*(const Matrix< T > &, const Matrix< T > &)
Matrix multiply.
Definition: Matrix.h:297
LinearMap substituteInto(const FMatrix< T, N, N > &lhs) const
Substitute map into matrix.
Definition: LinearMap.hpp:291
LinearMap()
Default constructor.
Definition: LinearMap.hpp:38
void identity()
Set to identity.
Definition: LinearMap.hpp:214
const LinearFun< T, N > & getComponent(int n) const
Get component.
Definition: LinearMap.hpp:66
Linear map with values of type [b]T[/b] in [b]N[/b] variables.
LinearMap operator+() const
Unary plus.
Definition: LinearMap.hpp:97
LinearMap substitute(const FMatrix< T, N, N > &rhs) const
Substitute matrix into map.
Definition: LinearMap.hpp:274
LinearMap & operator*=(const LinearFun< T, N > &rhs)
Multiply and assign.
Definition: LinearMap.hpp:111
LinearMap & operator+=(const LinearMap &rhs)
Add.
Definition: LinearMap.hpp:140
FVector< T, N > constantTerm() const
Definition: LinearMap.hpp:235
LinearMap inverse() const
Inverse.
Definition: LinearMap.hpp:201
FMatrix< T, N, N > linearTerms() const
Extract linear terms at origin.
Definition: LinearMap.hpp:243
LinearFun< T, N > & operator[](int)
Get component.
Definition: LinearMap.hpp:86
std::ostream & put(std::ostream &os) const
Put a LinearMap to stream [b]os[/b].
Definition: LinearMap.hpp:193
LinearMap & operator/=(const LinearFun< T, N > &rhs)
Divide and assign.
Definition: LinearMap.hpp:118
Linear function in N variables of type T.
Definition: LinearFun.h:39
Matrix< T > operator-(const Matrix< T > &, const Matrix< T > &)
Matrix subtraction.
Definition: Matrix.h:282
Vector truncated power series in n variables.
std::istream & operator>>(std::istream &, LieMap< T > &x)
Extract LieMap&lt;T&gt; from stream.
Definition: LieMap.h:231
LinearMap operator-() const
Unary minus.
Definition: LinearMap.hpp:103