57 template <
typename GUM_SCALAR >
68 template <
typename GUM_SCALAR >
74 template <
typename GUM_SCALAR >
81 template <
typename GUM_SCALAR >
93 if (newHighLimit < newVal) newHighLimit = newVal;
95 if (newLowLimit > newVal) newLowLimit = newVal;
99 if (newHighLimit < newVal) newHighLimit = newVal;
101 if (newLowLimit > newVal) newLowLimit = newVal;
105 if (newHighLimit < newVal) newHighLimit = newVal;
107 if (newLowLimit > newVal) newLowLimit = newVal;
108 }
catch (
const std::bad_cast&) {}
111 template <
typename GUM_SCALAR >
123 if (newHighLimit < newVal) newHighLimit = newVal;
125 if (newLowLimit > newVal) newLowLimit = newVal;
129 if (newHighLimit < newVal) newHighLimit = newVal;
131 if (newLowLimit > newVal) newLowLimit = newVal;
135 if (newHighLimit < newVal) newHighLimit = newVal;
137 if (newLowLimit > newVal) newLowLimit = newVal;
138 }
catch (
const std::bad_cast&) {}
141 template <
typename GUM_SCALAR >
153 if (newHighLimit < newVal) newHighLimit = newVal;
155 if (newLowLimit > newVal) newLowLimit = newVal;
159 if (newHighLimit < newVal) newHighLimit = newVal;
161 if (newLowLimit > newVal) newLowLimit = newVal;
165 if (newHighLimit < newVal) newHighLimit = newVal;
167 if (newLowLimit > newVal) newLowLimit = newVal;
168 }
catch (
const std::bad_cast&) {}
171 template <
typename GUM_SCALAR >
183 if (newHighLimit < newVal) newHighLimit = newVal;
185 if (newLowLimit > newVal) newLowLimit = newVal;
189 if (newHighLimit < newVal) newHighLimit = newVal;
191 if (newLowLimit > newVal) newLowLimit = newVal;
195 if (newHighLimit < newVal) newHighLimit = newVal;
197 if (newLowLimit > newVal) newLowLimit = newVal;
198 }
catch (
const std::bad_cast&) {}
201 template <
typename GUM_SCALAR >
213 if (newHighLimit < newVal) newHighLimit = newVal;
215 if (newLowLimit > newVal) newLowLimit = newVal;
219 if (newHighLimit < newVal) newHighLimit = newVal;
221 if (newLowLimit > newVal) newLowLimit = newVal;
225 if (newHighLimit < newVal) newHighLimit = newVal;
227 if (newLowLimit > newVal) newLowLimit = newVal;
228 }
catch (
const std::bad_cast&) {}
231 template <
typename GUM_SCALAR >
243 if (newHighLimit < newVal) newHighLimit = newVal;
245 if (newLowLimit > newVal) newLowLimit = newVal;
249 if (newHighLimit < newVal) newHighLimit = newVal;
251 if (newLowLimit > newVal) newLowLimit = newVal;
255 if (newHighLimit < newVal) newHighLimit = newVal;
257 if (newLowLimit > newVal) newLowLimit = newVal;
258 }
catch (
const std::bad_cast&) {}
263 template <
typename GUM_SCALAR >
276 template <
typename GUM_SCALAR >
282 "Value asked is higher than High limit : not in (" << this->
lowLimit_ <<
"-"
288 "Value asked is lower than low limit : not in (" << this->lowLimit_ <<
"-"
297 template <
typename GUM_SCALAR >
303 return _decode_(GUM_SCALAR(representation));
307 template <
typename GUM_SCALAR >
314 template <
typename GUM_SCALAR >
316 const GUM_SCALAR& newHighLimit) {
317 if (newLowLimit > newHighLimit) {
327 template <
typename GUM_SCALAR >
339 template <
typename GUM_SCALAR >
345 template <
typename GUM_SCALAR >
358 template <
typename GUM_SCALAR >
364 template <
typename GUM_SCALAR >
370 return 1 +
Idx(((value - this->lowLimit_) / this->
epsilon_));
374 template <
typename GUM_SCALAR >
377 if (representation == 0)
return this->
lowLimit_;
381 return (GUM_SCALAR)(((representation * this->
epsilon_) - (this->
epsilon_ / 2))
386 template <
typename GUM_SCALAR >
ApproximationPolicy()
Default constructor.
GUM_SCALAR _decode_(const GUM_SCALAR &representation) const
Concretely computes the approximate value from representation.
GUM_SCALAR highLimit_
Highest value possible.
void computeNbInterval_()
Get the number of interval.
virtual void setLowLimit(const GUM_SCALAR &newLowLimit)
Sets lowest possible value.
const GUM_SCALAR & highLimit() const
Gets Highest possible value.
void combineSub(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using substraction with the given gum::ApproximationPolicy.
GUM_SCALAR safeFromExact(const GUM_SCALAR &value)
Convert value to his approximation.
const GUM_SCALAR & lowLimit() const
Gets lowest possible value.
Idx nbInterval_
The number of interval.
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 combineDiv(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using division with the given gum::ApproximationPolicy.
Idx _encode_(const GUM_SCALAR &value) const
Concretely computes the approximate representation.
GUM_SCALAR fromExact(const GUM_SCALAR &value) const
Convert value to his approximation.
GUM_SCALAR decode(Idx representation) const
Convert approximation representation to value.
GUM_SCALAR lowLimit_
Lowest value possible.
virtual void setEpsilon(const GUM_SCALAR &e)
Sets approximation factor.
void combineAdd(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using addition with the given gum::ApproximationPolicy.
void combineMult(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using multiplication with the given gum::ApproximationPolicy.
virtual void setHighLimit(const GUM_SCALAR &newHighLimit)
Sets Highest possible value.
Idx encode(const GUM_SCALAR &value) const
Encode a given value into its approximation representation.
GUM_SCALAR epsilon_
Approximation factor.
void combineMin(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using min with the given gum::ApproximationPolicy.
void combineMax(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using max with the given gum::ApproximationPolicy.
virtual void setLimits(const GUM_SCALAR &newLowLimit, const GUM_SCALAR &newHighLimit)
Set bounds in a whole.
Exception : out of bound.
#define GUM_ERROR(type, msg)
Size Idx
Type for indexes.
Classes used to practice approximation on value.
gum is the global namespace for all aGrUM entities