37 template <
typename GUM_SCALAR >
39 GUM_SCALAR low, GUM_SCALAR high, GUM_SCALAR eps) :
41 _lowLimit(low), _highLimit(high), _epsilon(eps) {
48 template <
typename GUM_SCALAR >
56 template <
typename GUM_SCALAR >
58 const GUM_SCALAR& value)
const {
63 template <
typename GUM_SCALAR >
75 if (newHighLimit < newVal) newHighLimit = newVal;
77 if (newLowLimit > newVal) newLowLimit = newVal;
81 if (newHighLimit < newVal) newHighLimit = newVal;
83 if (newLowLimit > newVal) newLowLimit = newVal;
87 if (newHighLimit < newVal) newHighLimit = newVal;
89 if (newLowLimit > newVal) newLowLimit = newVal;
90 }
catch (
const std::bad_cast&) {}
93 template <
typename GUM_SCALAR >
105 if (newHighLimit < newVal) newHighLimit = newVal;
107 if (newLowLimit > newVal) newLowLimit = newVal;
111 if (newHighLimit < newVal) newHighLimit = newVal;
113 if (newLowLimit > newVal) newLowLimit = newVal;
117 if (newHighLimit < newVal) newHighLimit = newVal;
119 if (newLowLimit > newVal) newLowLimit = newVal;
120 }
catch (
const std::bad_cast&) {}
123 template <
typename GUM_SCALAR >
135 if (newHighLimit < newVal) newHighLimit = newVal;
137 if (newLowLimit > newVal) newLowLimit = newVal;
141 if (newHighLimit < newVal) newHighLimit = newVal;
143 if (newLowLimit > newVal) newLowLimit = newVal;
147 if (newHighLimit < newVal) newHighLimit = newVal;
149 if (newLowLimit > newVal) newLowLimit = newVal;
150 }
catch (
const std::bad_cast&) {}
153 template <
typename GUM_SCALAR >
165 if (newHighLimit < newVal) newHighLimit = newVal;
167 if (newLowLimit > newVal) newLowLimit = newVal;
171 if (newHighLimit < newVal) newHighLimit = newVal;
173 if (newLowLimit > newVal) newLowLimit = newVal;
177 if (newHighLimit < newVal) newHighLimit = newVal;
179 if (newLowLimit > newVal) newLowLimit = newVal;
180 }
catch (
const std::bad_cast&) {}
183 template <
typename GUM_SCALAR >
190 GUM_SCALAR newHighLimit =
192 GUM_SCALAR newLowLimit =
198 if (newHighLimit < newVal) newHighLimit = newVal;
200 if (newLowLimit > newVal) newLowLimit = newVal;
204 if (newHighLimit < newVal) newHighLimit = newVal;
206 if (newLowLimit > newVal) newLowLimit = newVal;
210 if (newHighLimit < newVal) newHighLimit = newVal;
212 if (newLowLimit > newVal) newLowLimit = newVal;
213 }
catch (
const std::bad_cast&) {}
216 template <
typename GUM_SCALAR >
223 GUM_SCALAR newHighLimit =
225 GUM_SCALAR newLowLimit =
231 if (newHighLimit < newVal) newHighLimit = newVal;
233 if (newLowLimit > newVal) newLowLimit = newVal;
237 if (newHighLimit < newVal) newHighLimit = newVal;
239 if (newLowLimit > newVal) newLowLimit = newVal;
243 if (newHighLimit < newVal) newHighLimit = newVal;
245 if (newLowLimit > newVal) newLowLimit = newVal;
246 }
catch (
const std::bad_cast&) {}
251 template <
typename GUM_SCALAR >
253 const GUM_SCALAR& value) {
266 template <
typename GUM_SCALAR >
268 const GUM_SCALAR& value)
const {
270 #ifdef GUM_DEBUG_MODE 278 GUM_TRACE(value <<
" not in (" << this->_lowLimit <<
"-" << this->
_highLimit 283 #endif // GUM_DEBUG_MODE 288 template <
typename GUM_SCALAR >
293 "Interval Number asked is higher than total number of interval");
296 return __decode(GUM_SCALAR(representation));
300 template <
typename GUM_SCALAR >
308 template <
typename GUM_SCALAR >
310 const GUM_SCALAR& newLowLimit,
const GUM_SCALAR& newHighLimit) {
311 if (newLowLimit > newHighLimit) {
321 template <
typename GUM_SCALAR >
323 const GUM_SCALAR& newLowLimit) {
334 template <
typename GUM_SCALAR >
335 INLINE
const GUM_SCALAR&
341 template <
typename GUM_SCALAR >
343 const GUM_SCALAR& newHighLimit) {
354 template <
typename GUM_SCALAR >
355 INLINE
const GUM_SCALAR&
361 template <
typename GUM_SCALAR >
363 const GUM_SCALAR& value)
const {
368 return 1 +
Idx(((value - this->_lowLimit) / this->
_epsilon));
372 template <
typename GUM_SCALAR >
374 const GUM_SCALAR& representation)
const {
375 if (representation == 0)
return this->
_lowLimit;
379 return (GUM_SCALAR)(((representation * this->
_epsilon) - (this->
_epsilon / 2))
384 template <
typename GUM_SCALAR >
void combineSub(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using substraction with the given gum::ApproximationPolicy.
virtual void setEpsilon(const GUM_SCALAR &e)
Sets approximation factor.
Idx __encode(const GUM_SCALAR &value) const
Concretely computes the approximate representation.
GUM_SCALAR _lowLimit
Lowest value possible.
void combineDiv(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using division with the given gum::ApproximationPolicy.
GUM_SCALAR _epsilon
Approximation factor.
void combineMin(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using min with the given gum::ApproximationPolicy.
virtual void setLimits(const GUM_SCALAR &newLowLimit, const GUM_SCALAR &newHighLimit)
Set bounds in a whole.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const GUM_SCALAR & highLimit() const
Gets Highest possible value.
GUM_SCALAR __decode(const GUM_SCALAR &representation) const
Concretely computes the approximate value from representation.
Idx encode(const GUM_SCALAR &value) const
Encode a given value into its approximation representation.
GUM_SCALAR _highLimit
Highest value possible.
Idx _nbInterval
The number of interval.
virtual void setHighLimit(const GUM_SCALAR &newHighLimit)
Sets Highest possible value.
const GUM_SCALAR & lowLimit() const
Gets lowest possible value.
LinearApproximationPolicy(GUM_SCALAR low=(GUM_SCALAR) 0.0, GUM_SCALAR high=(GUM_SCALAR) 1.0, GUM_SCALAR eps=(GUM_SCALAR) 0.1)
Default constructor.
void combineMult(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using multiplication with the given gum::ApproximationPolicy.
Size Idx
Type for indexes.
Class implementing linear approximation policy (meaning possible value are split out in interval)...
GUM_SCALAR decode(Idx representation) const
Convert approximation representation to value.
GUM_SCALAR safeFromExact(const GUM_SCALAR &value)
Convert value to his approximation.
void combineMax(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using max with the given gum::ApproximationPolicy.
#define GUM_ERROR(type, msg)
Mother class for all approximation policy classes.
virtual void setLowLimit(const GUM_SCALAR &newLowLimit)
Sets lowest possible value.
void combineAdd(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using addition with the given gum::ApproximationPolicy.
GUM_SCALAR fromExact(const GUM_SCALAR &value) const
Convert value to his approximation.
void _computeNbInterval()
Get the number of interval.