OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
FDynamicFP.h
Go to the documentation of this file.
1 #ifndef MAD_FDynamicFP_HH
2 #define MAD_FDynamicFP_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: FDynamicFP.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1.2.2 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: FDynamicFP
13 //
14 // ------------------------------------------------------------------------
15 // Class category: FixedAlgebra
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2004/11/18 22:50:59 $
19 // $Author: jsberg $
20 //
21 // ------------------------------------------------------------------------
22 
23 #include "FixedAlgebra/FVps.h"
24 
25 template <class T, int N> class FVector;
26 
27 
28 // Class FDynamicFP
29 // ------------------------------------------------------------------------
31 
32 template <int N>
33 class FDynamicFP {
34 
35 public:
36 
38  // Find fixed point of [b]map[/b].
39  FDynamicFP(const FVps<double, N> &map);
40 
41  FDynamicFP();
42  FDynamicFP(const FDynamicFP &);
43  ~FDynamicFP();
44 
46  const FVector<double, N> &getFixedPoint() const;
47 
49  const FVps<double, N> &getFixedPointMap() const;
50 
51 private:
52 
53  // Not implemented.
54  void operator=(const FDynamicFP &);
55 
56  // Fixed point position.
58 
59  // Map around the fixed point.
61 };
62 
63 
64 #include "FixedAlgebra/FMatrix.h"
65 #include "FixedAlgebra/FLUMatrix.h"
66 #include "FixedAlgebra/FVector.h"
67 #include "FixedAlgebra/FVps.h"
68 
69 
70 // Class FDynamicFP
71 // ------------------------------------------------------------------------
72 
73 template <int N>
75  fixedPoint(), fixedPointMap()
76 {}
77 
78 
79 template <int N>
81  fixedPoint(rhs.fixedPoint), fixedPointMap(rhs.fixedPointMap)
82 {}
83 
84 
85 template <int N>
87  fixedPoint(), fixedPointMap(map) {
88  FVps<double, N> identity;
89 
90  // Determine fixPoint of map T by iterating the contraction map
91  // z_{n+1} = z_n - (M(z_n) - I)^{-1} . (T(z_n) - z_n)
92  // Here M(z_n) is the linear part of T(z_n + z), and z_0 = 0.
93  if(map.minOrder() == 0) {
94  while(true) {
95  // Get system of equations for fixed point.
98  double error = 0.0;
99 
100  for(int i = 0; i < N; i++) {
101  A(i, i) -= 1.0;
102  if(std::abs(Error(i)) > error) error = std::abs(Error(i));
103  }
104 
105  // Test for convergence.
106  static const double tol = 1.0e-10;
107  if(error < tol) break;
108 
109  // Correction for fixed point.
110  FLUMatrix<double, N> lu(A);
111  lu.backSubstitute(Error);
112  fixedPoint -= Error;
113 
114  // Build map around fixed point found so far.
115  fixedPointMap = map.substitute(identity + fixedPoint) - fixedPoint;
116  }
117  }
118 }
119 
120 
121 template <int N>
123 {}
124 
125 
126 template <int N>
128  return fixedPoint;
129 }
130 
131 
132 template <int N>
134  return fixedPointMap;
135 }
136 
137 #endif // MAD_FDynamicFP_HH
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
const FVector< double, N > & getFixedPoint() const
Get the transformation to the fixed point.
Definition: FDynamicFP.h:127
const FVps< double, N > & getFixedPointMap() const
Get the map around the fixed point.
Definition: FDynamicFP.h:133
A templated representation for vectors.
Definition: PartBunchBase.h:26
A templated representation of a LU-decomposition.
Definition: FLUMatrix.h:42
FVector< T, N > constantTerm() const
Extract the constant part of the map.
Definition: FVps.hpp:540
FVector< double, N > fixedPoint
Definition: FDynamicFP.h:57
void backSubstitute(FVector< T, N > &B) const
Back substitution.
Definition: FLUMatrix.h:222
FVps< double, N > fixedPointMap
Definition: FDynamicFP.h:60
FMatrix< T, N, N > linearTerms() const
Extract the linear part of the map.
Definition: FVps.hpp:561
Dynamic fixed point of a Truncated power series map.
Definition: FDynamicFP.h:33
FVps substitute(const FMatrix< T, N, N > &M, int n) const
Substitute.
Definition: FVps.hpp:608
void operator=(const FDynamicFP &)