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
00036 #ifndef _mapquadi_h_
00037 #define _mapquadi_h_
00038
00039 #include <string>
00040 #include <iostream>
00041 #include "maptype.h"
00042
00043
00044 #include "interval/doubleInterval.h"
00045
00046
00047 namespace unifexp {
00048
00049
00050
00051
00052
00053
00054
00055
00056 template <class numType>
00057 class mapQuadrIntv: public mapType<numType>
00058 {
00059 public:
00060
00061 mapQuadrIntv ();
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 mapQuadrIntv<numType>::mapQuadrIntv ()
00093 {
00094 return;
00095 }
00096
00097 template <class numType>
00098 std::string mapQuadrIntv<numType>::name () const
00099 {
00100 return std::string ("quadratic-intv");
00101 }
00102
00103 template <class numType>
00104 inline int mapQuadrIntv<numType>::countCritical () const
00105 {
00106 return 1;
00107 }
00108
00109 template <class numType>
00110 inline numType mapQuadrIntv<numType>::criticalPoint (int n) const
00111 {
00112 return 0.0;
00113 }
00114
00115 template <class numType>
00116 inline numType mapQuadrIntv<numType>::leftBound () const
00117 {
00118 return -2;
00119
00120 }
00121
00122 template <class numType>
00123 inline numType mapQuadrIntv<numType>::rightBound () const
00124 {
00125 return 2;
00126
00127
00128
00129
00130 }
00131
00132 template <class numType>
00133 void mapQuadrIntv<numType>::image (const numType &x1, const numType &x2,
00134 numType &y1, numType &y2) const
00135 {
00136 if (x2 < x1)
00137 throw "Image computation: Wrong interval for 'x'.";
00138 interval img = power (interval (x1, x2), 2) -
00139 interval (this -> paramMin, this -> paramMax);
00140 y1 = img. leftBound ();
00141 y2 = img. rightBound ();
00142 capd::rounding::DoubleRounding::roundNearest ();
00143 return;
00144 }
00145
00146 template <class numType>
00147 numType mapQuadrIntv<numType>::minLogDerivative (const numType &x1,
00148 const numType &x2, const numType &y1, const numType &y2) const
00149 {
00150
00151 if (x2 < x1)
00152 throw "MinLogDerivative: Wrong interval for 'x'.";
00153 if (y2 < y1)
00154 throw "MinLogDerivative: Wrong interval for 'y'.";
00155
00156
00157
00158
00159 const numType sum1 = (interval (y1, y1) + this -> paramMin).
00160 leftBound ();
00161 const numType left1 = (0 < sum1) ?
00162 (sqrt (interval (sum1, sum1))). leftBound () : 0;
00163 numType result;
00164 if (0 < x1)
00165 {
00166 const numType left = (left1 > x1) ? left1 : x1;
00167 result = (log (2 * interval (left, left))). leftBound ();
00168 }
00169 else if (x2 < 0)
00170 {
00171 const numType left = (left1 > -x2) ? left1 : -x2;
00172 result = (log (2 * interval (left, left))). leftBound ();
00173 }
00174 else
00175 {
00176 throw "Log of interval containing zero.";
00177 result = 0;
00178 }
00179 capd::rounding::DoubleRounding::roundNearest ();
00180 return result;
00181 }
00182
00183
00184 }
00185
00186 #endif // _mapquadi_h_
00187
00188
00189