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