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