00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _FINRESDYN_MAPHENON_H_
00035 #define _FINRESDYN_MAPHENON_H_
00036
00037
00038
00039 #include <iostream>
00040
00041
00042 #include "rounding.h"
00043 #include "opensqr.h"
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 template <class NumType>
00054 class tMapHenon
00055 {
00056 public:
00057
00058 typedef NumType NumberType;
00059
00060
00061 tMapHenon (const NumType &aNumerator = 14,
00062 const NumType &aDenominator = 10,
00063 const NumType &bNumerator = 3,
00064 const NumType &bDenominator = 10);
00065
00066
00067 static int dim ();
00068
00069
00070
00071
00072
00073 void initialPoint (NumType *x, int iterCount) const;
00074
00075
00076
00077 template <class InputType, class ResultType>
00078 void image (const InputType *xMin, const InputType *xMax,
00079 ResultType *yMin, ResultType *yMax) const;
00080
00081 private:
00082
00083 const NumType aMin;
00084
00085
00086 const NumType aMax;
00087
00088
00089 const NumType bMin;
00090
00091
00092 const NumType bMax;
00093
00094 };
00095
00096
00097
00098 template <class NumType>
00099 inline tMapHenon<NumType>::tMapHenon
00100 (const NumType &aNumerator, const NumType &aDenominator,
00101 const NumType &bNumerator, const NumType &bDenominator):
00102 aMin (tRounding<NumType>::div_down (aNumerator, aDenominator)),
00103 aMax (tRounding<NumType>::div_up (aNumerator, aDenominator)),
00104 bMin (tRounding<NumType>::div_down (bNumerator, bDenominator)),
00105 bMax (tRounding<NumType>::div_up (bNumerator, bDenominator))
00106 {
00107 if ((aMin < 0) || (bMin < 0))
00108 throw "Trying to use negative parameters of the Henon map.";
00109 return;
00110 }
00111
00112 template <class NumType>
00113 inline int tMapHenon<NumType>::dim ()
00114 {
00115 return 2;
00116 }
00117
00118 template <class NumType>
00119 inline void tMapHenon<NumType>::initialPoint (NumType *x, int iterCount)
00120 const
00121 {
00122
00123 for (int i = 0; i < iterCount; ++ i)
00124 {
00125 NumType tmp = 1 + x [1] - aMin * x [0] * x [0];
00126 x [1] = bMin * x [0];
00127 x [0] = tmp;
00128 }
00129 return;
00130 }
00131
00132 template <class NumType>
00133 template <class InputType, class ResultType>
00134 void tMapHenon<NumType>::image
00135 (const InputType *xMin, const InputType *xMax,
00136 ResultType *yMin, ResultType *yMax) const
00137 {
00138
00139 typedef tRounding<ResultType> rnd;
00140
00141
00142 ResultType x2Min, x2Max;
00143 openSqr (xMin [0], xMax [0], x2Min, x2Max);
00144 ResultType ax2Min = rnd::mul_down (aMin, x2Min);
00145 ResultType ax2Max = rnd::mul_up (aMax, x2Max);
00146 ResultType y1Min = rnd::add_down (1, xMin [1]);
00147 ResultType y1Max = rnd::add_up (1, xMax [1]);
00148 ResultType bxMin = rnd::mul_down (bMin, xMin [0]);
00149 ResultType bxMax = rnd::mul_up (bMax, xMax [0]);
00150
00151
00152 yMin [0] = rnd::sub_down (y1Min, ax2Max);
00153 yMax [0] = rnd::sub_up (y1Max, ax2Min);
00154 yMin [1] = bxMin;
00155 yMax [1] = bxMax;
00156
00157 return;
00158 }
00159
00160
00161 #endif // _FINRESDYN_MAPHENON_H_
00162