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