OPAL (Object Oriented Parallel Accelerator Library) 2022.1
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
25template <class T, int M, int N> class FMatrix;
26template <class T, int N> class LinearFun;
27template <class T, int N> class FVector;
28template <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
37template <class T, int N>
38class LinearMap {
39
40public:
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
125
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
143protected:
144
145 // Representation of the LinearMap.
147};
148
149
150// Global functions.
151// ------------------------------------------------------------------------
152
154template <class T, int N>
156
158template <class T, int N>
160
162template <class T, int N>
163LinearMap<T, N> operator*(const LinearMap<T, N> &lhs, const T &rhs);
164
166template <class T, int N>
167LinearMap<T, N> operator*(const T &lhs, const LinearMap<T, N> &rhs);
168
170template <class T, int N>
172
174// Throw DivideError, if constant part of [b]rhs[/b] is zero.
175template <class T, int N>
177
179// Throw DivideError, if [b]rhs[/b] is zero.
180template <class T, int N>
181LinearMap<T, N> operator/(const LinearMap<T, N> &lhs, const T &rhs);
182
184template <class T, int N>
186
188template <class T, int N>
190
192template <class T, int N>
194
196template <class T, int N>
198
200template <class T, int N>
202
204template <class T, int N>
206
208template <class T, int N>
209std::istream &operator>>(std::istream &is, LinearMap<T, N> &);
210
212template <class T, int N>
213std::ostream &operator<<(std::ostream &os, const LinearMap<T, N> &vps);
214
215
216// Implementation.
218
219#endif // CLASSIC_LinearMap_HH
LinearMap< T, N > operator+(const LinearMap< T, N > &lhs, const LinearMap< T, N > &rhs)
Add.
Definition: LinearMap.hpp:361
std::istream & operator>>(std::istream &is, LinearMap< T, N > &)
Extract LinearMap from stream [b]is[/b].
Definition: LinearMap.hpp:409
std::ostream & operator<<(std::ostream &os, const LinearMap< T, N > &vps)
Insert LinearMap to stream [b]os[/b].
Definition: LinearMap.hpp:415
LinearMap< T, N > operator/(const LinearMap< T, N > &lhs, const LinearFun< T, N > &rhs)
Divide.
Definition: LinearMap.hpp:345
LinearMap< T, N > operator-(const LinearMap< T, N > &lhs, const LinearMap< T, N > &rhs)
Subtract.
Definition: LinearMap.hpp:369
LinearMap< T, N > operator*(const LinearMap< T, N > &lhs, const LinearFun< T, N > &rhs)
Multiply.
Definition: LinearMap.hpp:308
Vector truncated power series in n variables.
Definition: FVps.h:39
A templated representation for matrices.
Definition: FMatrix.h:39
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
LinearMap substitute(const FMatrix< T, N, N > &rhs) const
Substitute matrix into map.
Definition: LinearMap.hpp:274
FVector< T, N > constantTerm() const
Definition: LinearMap.hpp:235
std::istream & get(std::istream &is)
Get a LinearMap from stream [b]is[/b].
Definition: LinearMap.hpp:168
const LinearFun< T, N > & getComponent(int n) const
Get component.
Definition: LinearMap.hpp:66
LinearMap operator+() const
Unary plus.
Definition: LinearMap.hpp:97
void identity()
Set to identity.
Definition: LinearMap.hpp:214
FMatrix< T, N, N > linearTerms() const
Extract linear terms at origin.
Definition: LinearMap.hpp:243
LinearMap inverse() const
Inverse.
Definition: LinearMap.hpp:201
LinearFun< T, N > data[N]
Definition: LinearMap.h:146
LinearMap & operator*=(const LinearFun< T, N > &rhs)
Multiply and assign.
Definition: LinearMap.hpp:111
LinearMap substituteInto(const FMatrix< T, N, N > &lhs) const
Substitute map into matrix.
Definition: LinearMap.hpp:291
LinearMap()
Default constructor.
Definition: LinearMap.hpp:38
std::ostream & put(std::ostream &os) const
Put a LinearMap to stream [b]os[/b].
Definition: LinearMap.hpp:193
LinearMap operator-() const
Unary minus.
Definition: LinearMap.hpp:103
LinearMap & operator/=(const LinearFun< T, N > &rhs)
Divide and assign.
Definition: LinearMap.hpp:118
LinearFun< T, N > & operator[](int)
Get component.
Definition: LinearMap.hpp:86
LinearMap & operator+=(const LinearMap &rhs)
Add.
Definition: LinearMap.hpp:140
LinearMap & operator-=(const LinearMap &rhs)
Subtract.
Definition: LinearMap.hpp:147
void setComponent(int, const LinearFun< T, N > &)
Set component.
Definition: LinearMap.hpp:76
Linear function in N variables of type T.
Definition: LinearFun.h:39