Go to the documentation of this file.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 _mapquadr_h_
00035 #define _mapquadr_h_
00036
00037 #include <string>
00038 #include <iostream>
00039 #include "maptype.h"
00040 #include "chomp/system/textfile.h"
00041
00042
00043 namespace unifexp {
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 template <class numType>
00056 class mapQuadr: public mapType<numType>
00057 {
00058 public:
00059
00060 mapQuadr ();
00061
00062
00063 std::string name () const;
00064
00065
00066 int countCritical () const;
00067
00068
00069 numType criticalPoint (int n) const;
00070
00071
00072 numType leftBound () const;
00073
00074
00075 numType rightBound () const;
00076
00077
00078 void image (const numType &x1, const numType &x2,
00079 numType &y1, numType &y2) const;
00080
00081
00082
00083 numType minLogDerivative (const numType &x1, const numType &x2,
00084 const numType &y1, const numType &y2) const;
00085
00086 };
00087
00088
00089
00090 template <class numType>
00091 inline mapQuadr<numType>::mapQuadr ()
00092 {
00093 return;
00094 }
00095
00096 template <class numType>
00097 inline std::string mapQuadr<numType>::name () const
00098 {
00099 return std::string ("quadratic");
00100 }
00101
00102 template <class numType>
00103 inline int mapQuadr<numType>::countCritical () const
00104 {
00105 return 1;
00106 }
00107
00108 template <class numType>
00109 inline numType mapQuadr<numType>::criticalPoint (int n) const
00110 {
00111 return 0.0;
00112 }
00113
00114 template <class numType>
00115 inline numType mapQuadr<numType>::leftBound () const
00116 {
00117 return -2;
00118
00119 }
00120
00121 template <class numType>
00122 inline numType mapQuadr<numType>::rightBound () const
00123 {
00124 return 2;
00125
00126 }
00127
00128 template <class numType>
00129 inline void mapQuadr<numType>::image (const numType &x1, const numType &x2,
00130 numType &y1, numType &y2) const
00131 {
00132 if (x2 < x1)
00133 throw "Image computation: Wrong interval for 'x'.";
00134 if (x1 > 0)
00135 {
00136 y1 = x1 * x1 - this -> paramMax;
00137 y2 = x2 * x2 - this -> paramMin;
00138 }
00139 else if (x2 < 0)
00140 {
00141 y1 = x2 * x2 - this -> paramMax;
00142 y2 = x1 * x1 - this -> paramMin;
00143 }
00144 else
00145 {
00146 y2 = ((-x1 < x2) ? (x2 * x2) : (x1 * x1)) - this -> paramMin;
00147 y1 = -this -> paramMax;
00148 }
00149 return;
00150 }
00151
00152 template <class numType>
00153 inline numType mapQuadr<numType>::minLogDerivative (const numType &x1,
00154 const numType &x2, const numType &y1, const numType &y2) const
00155 {
00156
00157 if (x2 < x1)
00158 throw "MinLogDerivative: Wrong interval for 'x'.";
00159 if (y2 < y1)
00160 throw "MinLogDerivative: Wrong interval for 'y'.";
00161
00162
00163
00164
00165 const numType sum1 = y1 + this -> paramMin;
00166 numType left = (0 < sum1) ? sqrt (sum1) : 0;
00167 if (0 < x1)
00168 {
00169 return log (2 * ((left > x1) ? left : x1));
00170 }
00171 else if (x2 < 0)
00172 {
00173 return log (2 * ((left > -x2) ? left : -x2));
00174 }
00175 else
00176 {
00177 chomp::homology::sbug << "x1 = " << x1 << ", x2 = " << x2 << "\n";
00178 throw "Log* of interval containing zero.";
00179 return 0;
00180 }
00181 }
00182
00183
00184 }
00185
00186 #endif // _mapquadr_h_
00187
00188
00189