58 template <
typename GUM_ELEMENT >
69 template <
typename GUM_ELEMENT >
76 template <
typename GUM_ELEMENT >
82 template <
typename GUM_ELEMENT >
94 if (newHighLimit < newVal) newHighLimit = newVal;
96 if (newLowLimit > newVal) newLowLimit = newVal;
100 if (newHighLimit < newVal) newHighLimit = newVal;
102 if (newLowLimit > newVal) newLowLimit = newVal;
106 if (newHighLimit < newVal) newHighLimit = newVal;
108 if (newLowLimit > newVal) newLowLimit = newVal;
113 }
catch (
const std::bad_cast&) {}
116 template <
typename GUM_ELEMENT >
128 if (newHighLimit < newVal) newHighLimit = newVal;
130 if (newLowLimit > newVal) newLowLimit = newVal;
134 if (newHighLimit < newVal) newHighLimit = newVal;
136 if (newLowLimit > newVal) newLowLimit = newVal;
140 if (newHighLimit < newVal) newHighLimit = newVal;
142 if (newLowLimit > newVal) newLowLimit = newVal;
147 }
catch (
const std::bad_cast&) {}
150 template <
typename GUM_ELEMENT >
162 if (newHighLimit < newVal) newHighLimit = newVal;
164 if (newLowLimit > newVal) newLowLimit = newVal;
168 if (newHighLimit < newVal) newHighLimit = newVal;
170 if (newLowLimit > newVal) newLowLimit = newVal;
174 if (newHighLimit < newVal) newHighLimit = newVal;
176 if (newLowLimit > newVal) newLowLimit = newVal;
181 }
catch (
const std::bad_cast&) {}
184 template <
typename GUM_ELEMENT >
196 if (newHighLimit < newVal) newHighLimit = newVal;
198 if (newLowLimit > newVal) newLowLimit = newVal;
202 if (newHighLimit < newVal) newHighLimit = newVal;
204 if (newLowLimit > newVal) newLowLimit = newVal;
208 if (newHighLimit < newVal) newHighLimit = newVal;
210 if (newLowLimit > newVal) newLowLimit = newVal;
215 }
catch (
const std::bad_cast&) {}
218 template <
typename GUM_ELEMENT >
230 if (newHighLimit < newVal) newHighLimit = newVal;
232 if (newLowLimit > newVal) newLowLimit = newVal;
236 if (newHighLimit < newVal) newHighLimit = newVal;
238 if (newLowLimit > newVal) newLowLimit = newVal;
242 if (newHighLimit < newVal) newHighLimit = newVal;
244 if (newLowLimit > newVal) newLowLimit = newVal;
249 }
catch (
const std::bad_cast&) {}
252 template <
typename GUM_ELEMENT >
264 if (newHighLimit < newVal) newHighLimit = newVal;
266 if (newLowLimit > newVal) newLowLimit = newVal;
270 if (newHighLimit < newVal) newHighLimit = newVal;
272 if (newLowLimit > newVal) newLowLimit = newVal;
276 if (newHighLimit < newVal) newHighLimit = newVal;
278 if (newLowLimit > newVal) newLowLimit = newVal;
283 }
catch (
const std::bad_cast&) {}
288 template <
typename GUM_ELEMENT >
300 template <
typename GUM_ELEMENT >
306 "Value asked is higher than High limit : not in (" << this->
lowLimit_ <<
"-"
312 "Value asked is lower than low limit : not in (" << this->lowLimit_ <<
"-"
321 template <
typename GUM_ELEMENT >
327 return _decode_(GUM_ELEMENT(representation));
331 template <
typename GUM_ELEMENT >
339 template <
typename GUM_ELEMENT >
341 const GUM_ELEMENT& newHighLimit) {
342 if (newLowLimit > newHighLimit) {
352 template <
typename GUM_ELEMENT >
364 template <
typename GUM_ELEMENT >
370 template <
typename GUM_ELEMENT >
382 template <
typename GUM_ELEMENT >
388 template <
typename GUM_ELEMENT >
394 return 1 +
Idx(((value - this->lowLimit_) / this->
epsilon_));
398 template <
typename GUM_ELEMENT >
401 if (representation == 0)
return this->
lowLimit_;
405 return (GUM_ELEMENT)(((representation * this->
epsilon_) - (this->
epsilon_ / 2))
410 template <
typename GUM_ELEMENT >
void combineMin(const ApproximationPolicy< GUM_ELEMENT > *ap) override
Combine using min with the given gum::ApproximationPolicy.
GUM_ELEMENT fromExact(const GUM_ELEMENT &value) const override
Convert value to his approximation.
GUM_ELEMENT _decode_(const GUM_ELEMENT &representation) const
Concretely computes the approximate value from representation.
void combineAdd(const ApproximationPolicy< GUM_ELEMENT > *ap) override
Combine using addition with the given gum::ApproximationPolicy.
void combineMax(const ApproximationPolicy< GUM_ELEMENT > *ap) override
Combine using max with the given gum::ApproximationPolicy.
virtual void setLowLimit(const GUM_ELEMENT &newLowLimit)
Sets lowest possible value.
void combineDiv(const ApproximationPolicy< GUM_ELEMENT > *ap) override
Combine using division with the given gum::ApproximationPolicy.
GUM_ELEMENT safeFromExact(const GUM_ELEMENT &value)
Convert value to his approximation.
Idx encode(const GUM_ELEMENT &value) const
Encode a given value into its approximation representation.
void computeNbInterval_()
Get the number of interval.
virtual void setLimits(const GUM_ELEMENT &newLowLimit, const GUM_ELEMENT &newHighLimit)
Set bounds in a whole.
void combineMult(const ApproximationPolicy< GUM_ELEMENT > *ap) override
Combine using multiplication with the given gum::ApproximationPolicy.
Idx _encode_(const GUM_ELEMENT &value) const
Concretely computes the approximate representation.
virtual void setEpsilon(const GUM_ELEMENT &e)
Sets approximation factor.
LinearApproximationPolicy(GUM_ELEMENT low=(GUM_ELEMENT) 0.0, GUM_ELEMENT high=(GUM_ELEMENT) 1.0, GUM_ELEMENT eps=(GUM_ELEMENT) 0.1)
Default constructor.
GUM_ELEMENT decode(Idx representation) const
Convert approximation representation to value.
const GUM_ELEMENT & highLimit() const
Gets Highest possible value.
GUM_ELEMENT lowLimit_
Lowest value possible.
virtual void setHighLimit(const GUM_ELEMENT &newHighLimit)
Sets Highest possible value.
Idx nbInterval_
The number of interval.
const GUM_ELEMENT & lowLimit() const
Gets lowest possible value.
GUM_ELEMENT epsilon_
Approximation factor.
GUM_ELEMENT highLimit_
Highest value possible.
void combineSub(const ApproximationPolicy< GUM_ELEMENT > *ap) override
Combine using subtraction with the given gum::ApproximationPolicy.
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