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 _CMGRAPHS_MAPTYPE_H_
00037 #define _CMGRAPHS_MAPTYPE_H_
00038
00039
00040
00041
00042
00043
00044
00045
00046 class MapType
00047 {
00048 public:
00049
00050 MapType ();
00051
00052
00053 virtual ~MapType ();
00054
00055
00056
00057 void setParam (const double *left, const double *right, int n);
00058
00059
00060 const double &getLeftParam (int n) const;
00061
00062
00063 const double &getRightParam (int n) const;
00064
00065
00066
00067
00068 virtual void compute (const double *xleft, const double *xright,
00069 double *yleft, double *yright, int dim) const = 0;
00070
00071
00072 template <class IntervalType>
00073 void operator () (const IntervalType *x, IntervalType *y,
00074 int dim) const;
00075
00076 private:
00077
00078 double *leftParam;
00079
00080
00081 double *rightParam;
00082
00083
00084 int nParam;
00085
00086
00087 MapType (const MapType &);
00088
00089
00090 MapType &operator = (const MapType &);
00091
00092 };
00093
00094
00095
00096 inline MapType::MapType (): leftParam (0), rightParam (0), nParam (0)
00097 {
00098 return;
00099 }
00100
00101 inline MapType::~MapType ()
00102 {
00103 if (leftParam)
00104 delete [] leftParam;
00105 if (rightParam)
00106 delete [] rightParam;
00107 return;
00108 }
00109
00110 inline MapType::MapType (const MapType &)
00111 {
00112 return;
00113 }
00114
00115 inline MapType &MapType::operator = (const MapType &)
00116 {
00117 return *this;
00118 }
00119
00120 inline void MapType::setParam (const double *left, const double *right,
00121 int n)
00122 {
00123 if (n <= 0)
00124 return;
00125 if (n != nParam)
00126 {
00127 if (nParam)
00128 {
00129 delete [] leftParam;
00130 delete [] rightParam;
00131 }
00132 leftParam = new double [n];
00133 rightParam = new double [n];
00134 nParam = n;
00135 }
00136 for (int i = 0; i < nParam; ++ i)
00137 {
00138 leftParam [i] = left [i];
00139 rightParam [i] = right [i];
00140 }
00141 return;
00142 }
00143
00144 inline const double &MapType::getLeftParam (int n) const
00145 {
00146 if (!leftParam || (n >= nParam))
00147 throw "Requested left parameter not defined.";
00148 return leftParam [n];
00149 }
00150
00151 inline const double &MapType::getRightParam (int n) const
00152 {
00153 if (!rightParam || (n >= nParam))
00154 throw "Requested right parameter not defined.";
00155 return rightParam [n];
00156 }
00157
00158 template <class IntervalType>
00159 inline void MapType::operator () (const IntervalType *x, IntervalType *y,
00160 int dim) const
00161 {
00162 double *buffer = new double [4 * dim];
00163 double *xLeft = buffer;
00164 double *xRight = buffer + dim;
00165 for (int i = 0; i < dim; ++ i)
00166 {
00167 xLeft [i] = x [i]. leftBound ();
00168 xRight [i] = x [i]. rightBound ();
00169 }
00170 double *yLeft = buffer + 2 * dim;
00171 double *yRight = buffer + 3 * dim;
00172 this -> compute (xLeft, xRight, yLeft, yRight, dim);
00173 for (int i = 0; i < dim; ++ i)
00174 y [i] = IntervalType (yLeft [i], yRight [i]);
00175 delete [] buffer;
00176 return;
00177 }
00178
00179
00180 #endif // _CMGRAPHS_MAPTYPE_H_
00181