aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
gum::LinearApproximationPolicy< GUM_SCALAR > Class Template Reference

Class implementing linear approximation policy (meaning possible value are split out in interval). More...

#include <linearApproximationPolicy.h>

+ Inheritance diagram for gum::LinearApproximationPolicy< GUM_SCALAR >:
+ Collaboration diagram for gum::LinearApproximationPolicy< GUM_SCALAR >:

Public Member Functions

Constructors / Destructors
 LinearApproximationPolicy (GUM_SCALAR low=(GUM_SCALAR) 0.0, GUM_SCALAR high=(GUM_SCALAR) 1.0, GUM_SCALAR eps=(GUM_SCALAR) 0.1)
 Default constructor. More...
 
 LinearApproximationPolicy (const LinearApproximationPolicy< GUM_SCALAR > *md)
 Copy constructor. More...
 
Accessors/Modifiers
GUM_SCALAR fromExact (const GUM_SCALAR &value) const
 Convert value to his approximation. More...
 
void combineAdd (const ApproximationPolicy< GUM_SCALAR > *ap)
 Combine using addition with the given gum::ApproximationPolicy. More...
 
void combineSub (const ApproximationPolicy< GUM_SCALAR > *ap)
 Combine using substraction with the given gum::ApproximationPolicy. More...
 
void combineMult (const ApproximationPolicy< GUM_SCALAR > *ap)
 Combine using multiplication with the given gum::ApproximationPolicy. More...
 
void combineDiv (const ApproximationPolicy< GUM_SCALAR > *ap)
 Combine using division with the given gum::ApproximationPolicy. More...
 
void combineMax (const ApproximationPolicy< GUM_SCALAR > *ap)
 Combine using max with the given gum::ApproximationPolicy. More...
 
void combineMin (const ApproximationPolicy< GUM_SCALAR > *ap)
 Combine using min with the given gum::ApproximationPolicy. More...
 
GUM_SCALAR safeFromExact (const GUM_SCALAR &value)
 Convert value to his approximation. More...
 
Idx encode (const GUM_SCALAR &value) const
 Encode a given value into its approximation representation. More...
 
GUM_SCALAR decode (Idx representation) const
 Convert approximation representation to value. More...
 
virtual void setEpsilon (const GUM_SCALAR &e)
 Sets approximation factor. More...
 
virtual void setLimits (const GUM_SCALAR &newLowLimit, const GUM_SCALAR &newHighLimit)
 Set bounds in a whole. More...
 
virtual void setLowLimit (const GUM_SCALAR &newLowLimit)
 Sets lowest possible value. More...
 
const GUM_SCALAR & lowLimit () const
 Gets lowest possible value. More...
 
virtual void setHighLimit (const GUM_SCALAR &newHighLimit)
 Sets Highest possible value. More...
 
const GUM_SCALAR & highLimit () const
 Gets Highest possible value. More...
 

Protected Attributes

GUM_SCALAR lowLimit_
 Lowest value possible. More...
 
GUM_SCALAR highLimit_
 Highest value possible. More...
 
GUM_SCALAR epsilon_
 Approximation factor. More...
 
Idx nbInterval_
 The number of interval. More...
 

Protected Member Functions

Idx encode__ (const GUM_SCALAR &value) const
 Concretely computes the approximate representation. More...
 
GUM_SCALAR decode__ (const GUM_SCALAR &representation) const
 Concretely computes the approximate value from representation. More...
 
void computeNbInterval_ ()
 Get the number of interval. More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::LinearApproximationPolicy< GUM_SCALAR >

Class implementing linear approximation policy (meaning possible value are split out in interval).

Warning
Doxygen does not like spanning command on multiple line, so we could not configure it with the correct include directive. Use the following code snippet to include this file.
Template Parameters
GUM_SCALARThe type used for computations.

Definition at line 54 of file linearApproximationPolicy.h.

Constructor & Destructor Documentation

◆ LinearApproximationPolicy() [1/2]

template<typename GUM_SCALAR >
gum::LinearApproximationPolicy< GUM_SCALAR >::LinearApproximationPolicy ( GUM_SCALAR  low = (GUM_SCALAR)0.0,
GUM_SCALAR  high = (GUM_SCALAR)1.0,
GUM_SCALAR  eps = (GUM_SCALAR)0.1 
)

Default constructor.

Parameters
lowThe lower limit.
highThe higher limit.
epsThe epsilon.
Exceptions
OutOfBoundif out of bounds (low<high, eps>0)

Definition at line 37 of file linearApproximationPolicy_tpl.h.

40  :
41  ApproximationPolicy< GUM_SCALAR >(),
42  lowLimit_(low), highLimit_(high), epsilon_(eps) {
43  if (eps <= 0) { GUM_ERROR(OutOfBounds, "Epsilon must be >0"); }
44 
46  }
void computeNbInterval_()
Get the number of interval.
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
GUM_SCALAR epsilon_
Approximation factor.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ LinearApproximationPolicy() [2/2]

template<typename GUM_SCALAR >
gum::LinearApproximationPolicy< GUM_SCALAR >::LinearApproximationPolicy ( const LinearApproximationPolicy< GUM_SCALAR > *  md)

Copy constructor.

Parameters
mdThe gum::LinearApproximationPolicy to copy.

Definition at line 50 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

51  :
52  ApproximationPolicy< GUM_SCALAR >(md),
53  epsilon_(md->epsilon_), nbInterval_(md->nbInterval_) {}
Idx nbInterval_
The number of interval.
GUM_SCALAR epsilon_
Approximation factor.
+ Here is the call graph for this function:

Member Function Documentation

◆ combineAdd()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::combineAdd ( const ApproximationPolicy< GUM_SCALAR > *  ap)
virtual

Combine using addition with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 65 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

66  {
67  try {
68  const LinearApproximationPolicy< GUM_SCALAR >* lap
69  = dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
70 
71  GUM_SCALAR newHighLimit = lowLimit_ + lap->lowLimit();
72  GUM_SCALAR newLowLimit = lowLimit_ + lap->lowLimit();
73 
74  GUM_SCALAR newVal = lowLimit_ + lap->highLimit();
75 
76  if (newHighLimit < newVal) newHighLimit = newVal;
77 
78  if (newLowLimit > newVal) newLowLimit = newVal;
79 
80  newVal = highLimit_ + lap->lowLimit();
81 
82  if (newHighLimit < newVal) newHighLimit = newVal;
83 
84  if (newLowLimit > newVal) newLowLimit = newVal;
85 
86  newVal = highLimit_ + lap->highLimit();
87 
88  if (newHighLimit < newVal) newHighLimit = newVal;
89 
90  if (newLowLimit > newVal) newLowLimit = newVal;
91  } catch (const std::bad_cast&) {}
92  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
+ Here is the call graph for this function:

◆ combineDiv()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::combineDiv ( const ApproximationPolicy< GUM_SCALAR > *  ap)
virtual

Combine using division with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 155 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

156  {
157  try {
158  const LinearApproximationPolicy< GUM_SCALAR >* lap
159  = dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
160 
161  GUM_SCALAR newHighLimit = lowLimit_ / lap->lowLimit();
162  GUM_SCALAR newLowLimit = lowLimit_ / lap->lowLimit();
163 
164  GUM_SCALAR newVal = lowLimit_ / lap->highLimit();
165 
166  if (newHighLimit < newVal) newHighLimit = newVal;
167 
168  if (newLowLimit > newVal) newLowLimit = newVal;
169 
170  newVal = highLimit_ / lap->lowLimit();
171 
172  if (newHighLimit < newVal) newHighLimit = newVal;
173 
174  if (newLowLimit > newVal) newLowLimit = newVal;
175 
176  newVal = highLimit_ / lap->highLimit();
177 
178  if (newHighLimit < newVal) newHighLimit = newVal;
179 
180  if (newLowLimit > newVal) newLowLimit = newVal;
181  } catch (const std::bad_cast&) {}
182  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
+ Here is the call graph for this function:

◆ combineMax()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::combineMax ( const ApproximationPolicy< GUM_SCALAR > *  ap)
virtual

Combine using max with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 185 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

186  {
187  try {
188  const LinearApproximationPolicy< GUM_SCALAR >* lap
189  = dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
190 
191  GUM_SCALAR newHighLimit
192  = lowLimit_ > lap->lowLimit() ? lowLimit_ : lap->lowLimit();
193  GUM_SCALAR newLowLimit
194  = lowLimit_ > lap->lowLimit() ? lowLimit_ : lap->lowLimit();
195 
196  GUM_SCALAR newVal
197  = lowLimit_ > lap->highLimit() ? lowLimit_ : lap->highLimit();
198 
199  if (newHighLimit < newVal) newHighLimit = newVal;
200 
201  if (newLowLimit > newVal) newLowLimit = newVal;
202 
203  newVal = highLimit_ > lap->lowLimit() ? highLimit_ : lap->lowLimit();
204 
205  if (newHighLimit < newVal) newHighLimit = newVal;
206 
207  if (newLowLimit > newVal) newLowLimit = newVal;
208 
209  newVal = highLimit_ > lap->highLimit() ? highLimit_ : lap->highLimit();
210 
211  if (newHighLimit < newVal) newHighLimit = newVal;
212 
213  if (newLowLimit > newVal) newLowLimit = newVal;
214  } catch (const std::bad_cast&) {}
215  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
+ Here is the call graph for this function:

◆ combineMin()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::combineMin ( const ApproximationPolicy< GUM_SCALAR > *  ap)
virtual

Combine using min with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 218 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

219  {
220  try {
221  const LinearApproximationPolicy< GUM_SCALAR >* lap
222  = dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
223 
224  GUM_SCALAR newHighLimit
225  = lowLimit_ < lap->lowLimit() ? lowLimit_ : lap->lowLimit();
226  GUM_SCALAR newLowLimit
227  = lowLimit_ < lap->lowLimit() ? lowLimit_ : lap->lowLimit();
228 
229  GUM_SCALAR newVal
230  = lowLimit_ < lap->highLimit() ? lowLimit_ : lap->highLimit();
231 
232  if (newHighLimit < newVal) newHighLimit = newVal;
233 
234  if (newLowLimit > newVal) newLowLimit = newVal;
235 
236  newVal = highLimit_ < lap->lowLimit() ? highLimit_ : lap->lowLimit();
237 
238  if (newHighLimit < newVal) newHighLimit = newVal;
239 
240  if (newLowLimit > newVal) newLowLimit = newVal;
241 
242  newVal = highLimit_ < lap->highLimit() ? highLimit_ : lap->highLimit();
243 
244  if (newHighLimit < newVal) newHighLimit = newVal;
245 
246  if (newLowLimit > newVal) newLowLimit = newVal;
247  } catch (const std::bad_cast&) {}
248  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
+ Here is the call graph for this function:

◆ combineMult()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::combineMult ( const ApproximationPolicy< GUM_SCALAR > *  ap)
virtual

Combine using multiplication with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 125 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

126  {
127  try {
128  const LinearApproximationPolicy< GUM_SCALAR >* lap
129  = dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
130 
131  GUM_SCALAR newHighLimit = lowLimit_ * lap->lowLimit();
132  GUM_SCALAR newLowLimit = lowLimit_ * lap->lowLimit();
133 
134  GUM_SCALAR newVal = lowLimit_ * lap->highLimit();
135 
136  if (newHighLimit < newVal) newHighLimit = newVal;
137 
138  if (newLowLimit > newVal) newLowLimit = newVal;
139 
140  newVal = highLimit_ * lap->lowLimit();
141 
142  if (newHighLimit < newVal) newHighLimit = newVal;
143 
144  if (newLowLimit > newVal) newLowLimit = newVal;
145 
146  newVal = highLimit_ * lap->highLimit();
147 
148  if (newHighLimit < newVal) newHighLimit = newVal;
149 
150  if (newLowLimit > newVal) newLowLimit = newVal;
151  } catch (const std::bad_cast&) {}
152  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
+ Here is the call graph for this function:

◆ combineSub()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::combineSub ( const ApproximationPolicy< GUM_SCALAR > *  ap)
virtual

Combine using substraction with the given gum::ApproximationPolicy.

Parameters
apThe policy to combine with.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 95 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

96  {
97  try {
98  const LinearApproximationPolicy< GUM_SCALAR >* lap
99  = dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
100 
101  GUM_SCALAR newHighLimit = lowLimit_ - lap->lowLimit();
102  GUM_SCALAR newLowLimit = lowLimit_ - lap->lowLimit();
103 
104  GUM_SCALAR newVal = lowLimit_ - lap->highLimit();
105 
106  if (newHighLimit < newVal) newHighLimit = newVal;
107 
108  if (newLowLimit > newVal) newLowLimit = newVal;
109 
110  newVal = highLimit_ - lap->lowLimit();
111 
112  if (newHighLimit < newVal) newHighLimit = newVal;
113 
114  if (newLowLimit > newVal) newLowLimit = newVal;
115 
116  newVal = highLimit_ - lap->highLimit();
117 
118  if (newHighLimit < newVal) newHighLimit = newVal;
119 
120  if (newLowLimit > newVal) newLowLimit = newVal;
121  } catch (const std::bad_cast&) {}
122  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
+ Here is the call graph for this function:

◆ computeNbInterval_()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::computeNbInterval_ ( )
protected

Get the number of interval.

Definition at line 387 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

387  {
388  nbInterval_ = 1 + Idx((this->highLimit_ - this->lowLimit_) / this->epsilon_);
389  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
Idx nbInterval_
The number of interval.
Size Idx
Type for indexes.
Definition: types.h:52
GUM_SCALAR epsilon_
Approximation factor.
+ Here is the call graph for this function:

◆ decode()

template<typename GUM_SCALAR >
INLINE GUM_SCALAR gum::LinearApproximationPolicy< GUM_SCALAR >::decode ( Idx  representation) const

Convert approximation representation to value.

Parameters
representationThe approximation representation to decode.
Returns
Returns the value decoded from its approximation reprensentation.

Definition at line 291 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

291  {
292  if (representation > nbInterval_) {
293  GUM_ERROR(OutOfUpperBound,
294  "Interval Number asked is higher than total number of interval");
295  }
296 
297  return decode__(GUM_SCALAR(representation));
298  }
GUM_SCALAR decode__(const GUM_SCALAR &representation) const
Concretely computes the approximate value from representation.
Idx nbInterval_
The number of interval.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54
+ Here is the call graph for this function:

◆ decode__()

template<typename GUM_SCALAR >
INLINE GUM_SCALAR gum::LinearApproximationPolicy< GUM_SCALAR >::decode__ ( const GUM_SCALAR &  representation) const
protected

Concretely computes the approximate value from representation.

Parameters
representationThe approximate value to decode.
Returns
The decoded value.

Definition at line 375 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

376  {
377  if (representation == 0) return this->lowLimit_;
378 
379  if (representation == nbInterval_) return this->highLimit_;
380 
381  return (GUM_SCALAR)(((representation * this->epsilon_) - (this->epsilon_ / 2))
382  + this->lowLimit_);
383  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
Idx nbInterval_
The number of interval.
GUM_SCALAR epsilon_
Approximation factor.
+ Here is the call graph for this function:

◆ encode()

template<typename GUM_SCALAR >
INLINE Idx gum::LinearApproximationPolicy< GUM_SCALAR >::encode ( const GUM_SCALAR &  value) const

Encode a given value into its approximation representation.

Parameters
valueThe to encode.
Returns
Returns the encoded value.
Exceptions
OutOfLowerBoundRaised if value is out of bounds.
OutOfUpperBoundRaised if value is out of bounds.

Definition at line 268 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

269  {
270 // we keep the bounds checked in debug mode
271 #ifdef GUM_DEBUG_MODE
272  if (value > this->highLimit_) {
273  GUM_TRACE(value << " not in (" << this->lowLimit_ << "-" << this->highLimit_
274  << ")");
275  GUM_ERROR(OutOfUpperBound, "Value asked is higher than High limit");
276  }
277 
278  if (value < this->lowLimit_) {
279  GUM_TRACE(value << " not in (" << this->lowLimit_ << "-" << this->highLimit_
280  << ")");
281  GUM_ERROR(OutOfLowerBound, "Value asked is lower than low limit");
282  }
283 
284 #endif // GUM_DEBUG_MODE
285  return encode__(value);
286  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54
Idx encode__(const GUM_SCALAR &value) const
Concretely computes the approximate representation.
+ Here is the call graph for this function:

◆ encode__()

template<typename GUM_SCALAR >
INLINE Idx gum::LinearApproximationPolicy< GUM_SCALAR >::encode__ ( const GUM_SCALAR &  value) const
protected

Concretely computes the approximate representation.

Warning
We accept value smaller or higher than limits : please
See also
gum::ApproximationPolicy::safeFromExact(const GUM_SCALAR&).
Parameters
valueThe value to encode.
Returns
The encoded value.

Definition at line 364 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

365  {
366  if (value <= this->lowLimit_) return 0;
367 
368  if (value >= this->highLimit_) return nbInterval_;
369 
370  return 1 + Idx(((value - this->lowLimit_) / this->epsilon_));
371  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
Idx nbInterval_
The number of interval.
Size Idx
Type for indexes.
Definition: types.h:52
GUM_SCALAR epsilon_
Approximation factor.
+ Here is the call graph for this function:

◆ fromExact()

template<typename GUM_SCALAR >
INLINE GUM_SCALAR gum::LinearApproximationPolicy< GUM_SCALAR >::fromExact ( const GUM_SCALAR &  value) const
virtual

Convert value to his approximation.

Parameters
valueThe converted value.
Returns
The value approximation representation.

Implements gum::ApproximationPolicy< GUM_SCALAR >.

Definition at line 58 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

59  {
60  return decode__(GUM_SCALAR(encode(value)));
61  }
Idx encode(const GUM_SCALAR &value) const
Encode a given value into its approximation representation.
GUM_SCALAR decode__(const GUM_SCALAR &representation) const
Concretely computes the approximate value from representation.
+ Here is the call graph for this function:

◆ highLimit()

template<typename GUM_SCALAR >
INLINE const GUM_SCALAR & gum::LinearApproximationPolicy< GUM_SCALAR >::highLimit ( ) const

Gets Highest possible value.

Returns
Returns the highest possible value.

Definition at line 358 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

358  {
359  return highLimit_;
360  }
GUM_SCALAR highLimit_
Highest value possible.
+ Here is the call graph for this function:

◆ lowLimit()

template<typename GUM_SCALAR >
INLINE const GUM_SCALAR & gum::LinearApproximationPolicy< GUM_SCALAR >::lowLimit ( ) const

Gets lowest possible value.

Returns
Returns the lowest possible value.

Definition at line 338 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

338  {
339  return lowLimit_;
340  }
GUM_SCALAR lowLimit_
Lowest value possible.
+ Here is the call graph for this function:

◆ safeFromExact()

template<typename GUM_SCALAR >
INLINE GUM_SCALAR gum::LinearApproximationPolicy< GUM_SCALAR >::safeFromExact ( const GUM_SCALAR &  value)

Convert value to his approximation.

This method is slower than fromExact since it verifies the bounds.

Exceptions
OutOfLowerBoundRaised if value is out of bounds.
OutOfUpperBoundRaised if value is out of bounds.

Definition at line 253 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

254  {
255  if (value > this->highLimit_) {
256  GUM_ERROR(OutOfUpperBound, "Value asked is higher than high limit");
257  }
258 
259  if (value < this->lowLimit_) {
260  GUM_ERROR(OutOfLowerBound, "Value asked is lower than low limit");
261  }
262 
263  return fromExact(value);
264  }
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54
GUM_SCALAR fromExact(const GUM_SCALAR &value) const
Convert value to his approximation.
+ Here is the call graph for this function:

◆ setEpsilon()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::setEpsilon ( const GUM_SCALAR &  e)
virtual

Sets approximation factor.

Parameters
eThe new epsilon value.

Definition at line 303 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

303  {
304  epsilon_ = e;
306  }
void computeNbInterval_()
Get the number of interval.
GUM_SCALAR epsilon_
Approximation factor.
+ Here is the call graph for this function:

◆ setHighLimit()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::setHighLimit ( const GUM_SCALAR &  newHighLimit)
virtual

Sets Highest possible value.

Parameters
newHighLimitNew higher bound.
Exceptions
OutOfLowerBoundRaised if out of bound.

Definition at line 344 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

345  {
346  if (newHighLimit < this->lowLimit_) {
347  GUM_ERROR(OutOfLowerBound, "Value asked is lower than low limit");
348  }
349 
350  highLimit_ = newHighLimit;
351 
353  }
void computeNbInterval_()
Get the number of interval.
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54
+ Here is the call graph for this function:

◆ setLimits()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::setLimits ( const GUM_SCALAR &  newLowLimit,
const GUM_SCALAR &  newHighLimit 
)
virtual

Set bounds in a whole.

Parameters
newLowLimitNew lower bound.
newHighLimitNew higher bound.
Exceptions
OutOfBoundsRaised if new bounds are not legit.

Definition at line 310 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

312  {
313  if (newLowLimit > newHighLimit) {
314  GUM_ERROR(OutOfBounds, "Asked low value is higher than asked high value");
315  }
316 
317  lowLimit_ = newLowLimit;
318  highLimit_ = newHighLimit;
320  }
void computeNbInterval_()
Get the number of interval.
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54
+ Here is the call graph for this function:

◆ setLowLimit()

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::setLowLimit ( const GUM_SCALAR &  newLowLimit)
virtual

Sets lowest possible value.

Parameters
newLowLimitNew lower bound.
Exceptions
OutOfUpperBoundRaised if out of bound.

Definition at line 324 of file linearApproximationPolicy_tpl.h.

References gum::Set< Key, Alloc >::emplace().

325  {
326  if (newLowLimit > this->highLimit_) {
327  GUM_ERROR(OutOfUpperBound, "Value asked is higher than High limit");
328  }
329 
330  lowLimit_ = newLowLimit;
331 
333  }
void computeNbInterval_()
Get the number of interval.
GUM_SCALAR highLimit_
Highest value possible.
GUM_SCALAR lowLimit_
Lowest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54
+ Here is the call graph for this function:

Member Data Documentation

◆ epsilon_

template<typename GUM_SCALAR >
GUM_SCALAR gum::LinearApproximationPolicy< GUM_SCALAR >::epsilon_
protected

Approximation factor.

Definition at line 210 of file linearApproximationPolicy.h.

◆ highLimit_

template<typename GUM_SCALAR >
GUM_SCALAR gum::LinearApproximationPolicy< GUM_SCALAR >::highLimit_
protected

Highest value possible.

Definition at line 207 of file linearApproximationPolicy.h.

◆ lowLimit_

template<typename GUM_SCALAR >
GUM_SCALAR gum::LinearApproximationPolicy< GUM_SCALAR >::lowLimit_
protected

Lowest value possible.

Definition at line 204 of file linearApproximationPolicy.h.

◆ nbInterval_

template<typename GUM_SCALAR >
Idx gum::LinearApproximationPolicy< GUM_SCALAR >::nbInterval_
protected

The number of interval.

Definition at line 236 of file linearApproximationPolicy.h.


The documentation for this class was generated from the following files: