1#ifndef CLASSIC_LinearMap_CC
2#define CLASSIC_LinearMap_CC
37template <
class T,
int N>
39 for(
int i = 0; i < N; ++i) data[i][i+1] = 1.0;
43template <
class T,
int N>
45 for(
int i = 0; i < N; ++i) {
46 for(
int j = 0; j <= N; ++j) data[i][j] = rhs[i][j];
51template <
class T,
int N>
53 for(
int i = 0; i < N; ++i) {
54 for(
int j = 0; j < N; j++) data[i][j+1] = x[i][j];
59template <
class T,
int N>
61 for(
int i = 0; i < N; i++) data[i][0] = x[i];
65template <
class T,
int N>
68 throw CLRangeError(
"LinearMap::getComponent()",
"Index out of range.");
75template <
class T,
int N>
78 throw CLRangeError(
"LinearMap::setComponent()",
"Index out of range.");
85template <
class T,
int N>
inline
90template <
class T,
int N>
inline
96template <
class T,
int N>
102template <
class T,
int N>
105 for(
int i = 0; i < N; i++) z[i] = - data[i];
110template <
class T,
int N>
112 for(
int i = 0; i < N; i++) data[i] *= rhs;
117template <
class T,
int N>
120 for(
int i = 0; i < N; i++) data[i] *= t;
125template <
class T,
int N>
127 for(
int i = 0; i < N; i++) data[i] *= rhs;
132template <
class T,
int N>
134 for(
int i = 0; i < N; i++) data[i] /= rhs;
139template <
class T,
int N>
141 for(
int i = 0; i < N; i++) data[i] += rhs[i];
146template <
class T,
int N>
148 for(
int i = 0; i < N; i++) data[i] -= rhs[i];
153template <
class T,
int N>
155 for(
int i = 0; i < N; i++) data[i] += rhs[i];
160template <
class T,
int N>
162 for(
int i = 0; i < N; i++) data[i] -= rhs[i];
167template <
class T,
int N>
169 is.flags(std::ios::skipws);
171 (is >> std::ws).get(head, 4);
173 if(strcmp(head,
"LinearMap") != 0) {
174 throw FormatError(
"LinearMap::get()",
"Flag word \"LinearMap\" missing.");
181 throw FormatError(
"LinearMap::get()",
"Invalid LinearMap dimension");
186 for(
int i = 0; i < N; i++) is >> z.
data[i];
192template <
class T,
int N>
195 for(
int i = 0; i < N; i++) os << data[i];
200template <
class T,
int N>
213template <
class T,
int N>
215 for(
int i = 0; i < N; ++i) data[i] = LinearFun<T, N>::makeVariable(i);
219template <
class T,
int N>
223 for(
int i = 0; i < N; ++i) {
225 for(
int j = 0; j < N; ++j) {
226 z[i] += data[i][j+1] * rhs[j];
234template <
class T,
int N>
237 for(
int i = 0; i < N; i++) z[i] = data[i][0];
242template <
class T,
int N>
246 for(
int i = 0; i < N; i++) {
247 for(
int j = 0; j < N; j++) {
248 z(i, j) = data[i][j+1];
256template <
class T,
int N>
260 for(
int i = 0; i < N; ++i) {
261 z.
data[i][0] = data[i][0];
262 for(
int j = 0; j < N; ++j) {
263 for(
int k = 0; k <= N; ++k) {
264 z.
data[i][k] += data[i][j+1] * rhs.
data[j][k];
273template <
class T,
int N>
277 for(
int i = 0; i < N; ++i) {
278 z.
data[i][0] = data[i][0];
279 for(
int j = 0; j < N; ++j) {
280 for(
int k = 0; k < N; ++k) {
281 z.
data[i][k+1] += data[i][j+1] * rhs[j][k];
290template <
class T,
int N>
294 for(
int i = 0; i < N; ++i) {
295 for(
int j = 0; j < N; ++j) {
296 z[i] += lhs[i][j] * data[j];
307template <
class T,
int N>
310 for(
int i = 0; i < N; ++i) z[i] = lhs[i] * rhs;
315template <
class T,
int N>
318 for(
int i = 0; i < N; ++i) z[i] = lhs * rhs[i];
323template <
class T,
int N>
326 for(
int i = 0; i < N; ++i) z[i] = lhs[i] * rhs;
331template <
class T,
int N>
334 for(
int i = 0; i < N; ++i) z[i] = lhs * rhs[i];
338template <
class T,
int N>
344template <
class T,
int N>
347 for(
int i = 0; i < N; ++i) z[i] = lhs[i] / rhs;
352template <
class T,
int N>
355 for(
int i = 0; i < N; ++i) z[i] = lhs[i] / rhs;
360template <
class T,
int N>
363 for(
int i = 0; i < N; ++i) z[i] = lhs[i] + rhs[i];
368template <
class T,
int N>
371 for(
int i = 0; i < N; ++i) z[i] = lhs[i] - rhs[i];
376template <
class T,
int N>
379 for(
int i = 0; i < N; ++i) z[i] = lhs[i] + rhs[i];
384template <
class T,
int N>
387 for(
int i = 0; i < N; ++i) z[i] = lhs[i] - rhs[i];
392template <
class T,
int N>
395 for(
int i = 0; i < N; ++i) z[i] = lhs[i] + rhs[i];
400template <
class T,
int N>
403 for(
int i = 0; i < N; ++i) z[i] = lhs[i] - rhs[i];
408template <
class T,
int N>
414template <
class T,
int N>
LinearMap< T, N > operator+(const LinearMap< T, N > &lhs, const LinearMap< T, N > &rhs)
Add.
std::ostream & operator<<(std::ostream &os, const LinearMap< T, N > &vps)
Insert LinearMap to stream [b]os[/b].
LinearMap< T, N > operator/(const LinearMap< T, N > &lhs, const LinearFun< T, N > &rhs)
Divide.
LinearMap< T, N > operator-(const LinearMap< T, N > &lhs, const LinearMap< T, N > &rhs)
Subtract.
LinearMap< T, N > operator*(const LinearMap< T, N > &lhs, const LinearFun< T, N > &rhs)
Multiply.
std::istream & operator>>(std::istream &is, LinearMap< T, N > &vps)
Extract LinearMap from stream [b]is[/b].
Inform & endl(Inform &inf)
Vector truncated power series in n variables.
A templated representation of a LU-decomposition.
FMatrix< T, N, N > inverse() const
Get inverse.
A templated representation for vectors.
Linear map with values of type [b]T[/b] in [b]N[/b] variables.
LinearMap substitute(const FMatrix< T, N, N > &rhs) const
Substitute matrix into map.
FVector< T, N > constantTerm() const
std::istream & get(std::istream &is)
Get a LinearMap from stream [b]is[/b].
const LinearFun< T, N > & getComponent(int n) const
Get component.
LinearMap operator+() const
Unary plus.
void identity()
Set to identity.
FMatrix< T, N, N > linearTerms() const
Extract linear terms at origin.
LinearMap inverse() const
Inverse.
LinearFun< T, N > data[N]
LinearMap & operator*=(const LinearFun< T, N > &rhs)
Multiply and assign.
LinearMap substituteInto(const FMatrix< T, N, N > &lhs) const
Substitute map into matrix.
LinearMap()
Default constructor.
std::ostream & put(std::ostream &os) const
Put a LinearMap to stream [b]os[/b].
LinearMap operator-() const
Unary minus.
LinearMap & operator/=(const LinearFun< T, N > &rhs)
Divide and assign.
LinearFun< T, N > & operator[](int)
Get component.
LinearMap & operator+=(const LinearMap &rhs)
Add.
LinearMap & operator-=(const LinearMap &rhs)
Subtract.
void setComponent(int, const LinearFun< T, N > &)
Set component.
Linear function in N variables of type T.
LinearFun inverse() const
Approximate reciprocal value 1/(*this).