aGrUM  0.13.2
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 52 of file linearApproximationPolicy.h.

Constructor & Destructor Documentation

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 35 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_computeNbInterval(), and GUM_ERROR.

36  :
37  ApproximationPolicy< GUM_SCALAR >(),
38  _lowLimit(low), _highLimit(high), _epsilon(eps) {
39  if (eps <= 0) { GUM_ERROR(OutOfBounds, "Epsilon must be >0"); }
40 
42  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _epsilon
Approximation factor.
GUM_SCALAR _highLimit
Highest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
void _computeNbInterval()
Get the number of interval.

+ Here is the call graph for this function:

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 46 of file linearApproximationPolicy_tpl.h.

47  :
48  ApproximationPolicy< GUM_SCALAR >(md),
49  _epsilon(md->_epsilon), _nbInterval(md->_nbInterval) {}
GUM_SCALAR _epsilon
Approximation factor.
Idx _nbInterval
The number of interval.

Member Function Documentation

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 370 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_epsilon, gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, and gum::LinearApproximationPolicy< GUM_SCALAR >::_nbInterval.

Referenced by gum::LinearApproximationPolicy< GUM_SCALAR >::decode(), and gum::LinearApproximationPolicy< GUM_SCALAR >::fromExact().

371  {
372  if (representation == 0) return this->_lowLimit;
373 
374  if (representation == _nbInterval) return this->_highLimit;
375 
376  return (GUM_SCALAR)(((representation * this->_epsilon) - (this->_epsilon / 2))
377  + this->_lowLimit);
378  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _epsilon
Approximation factor.
GUM_SCALAR _highLimit
Highest value possible.
Idx _nbInterval
The number of interval.

+ Here is the caller graph for this function:

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 359 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_epsilon, gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, and gum::LinearApproximationPolicy< GUM_SCALAR >::_nbInterval.

Referenced by gum::LinearApproximationPolicy< GUM_SCALAR >::encode().

360  {
361  if (value <= this->_lowLimit) return 0;
362 
363  if (value >= this->_highLimit) return _nbInterval;
364 
365  return 1 + Idx(((value - this->_lowLimit) / this->_epsilon));
366  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _epsilon
Approximation factor.
GUM_SCALAR _highLimit
Highest value possible.
Idx _nbInterval
The number of interval.
unsigned long Idx
Type for indexes.
Definition: types.h:43

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE void gum::LinearApproximationPolicy< GUM_SCALAR >::_computeNbInterval ( )
protected
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 61 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::highLimit(), and gum::LinearApproximationPolicy< GUM_SCALAR >::lowLimit().

62  {
63  try {
64  const LinearApproximationPolicy< GUM_SCALAR >* lap =
65  dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
66 
67  GUM_SCALAR newHighLimit = _lowLimit + lap->lowLimit();
68  GUM_SCALAR newLowLimit = _lowLimit + lap->lowLimit();
69 
70  GUM_SCALAR newVal = _lowLimit + lap->highLimit();
71 
72  if (newHighLimit < newVal) newHighLimit = newVal;
73 
74  if (newLowLimit > newVal) newLowLimit = newVal;
75 
76  newVal = _highLimit + lap->lowLimit();
77 
78  if (newHighLimit < newVal) newHighLimit = newVal;
79 
80  if (newLowLimit > newVal) newLowLimit = newVal;
81 
82  newVal = _highLimit + lap->highLimit();
83 
84  if (newHighLimit < newVal) newHighLimit = newVal;
85 
86  if (newLowLimit > newVal) newLowLimit = newVal;
87  } catch (const std::bad_cast&) {}
88  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.

+ Here is the call graph for this function:

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 151 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::highLimit(), and gum::LinearApproximationPolicy< GUM_SCALAR >::lowLimit().

152  {
153  try {
154  const LinearApproximationPolicy< GUM_SCALAR >* lap =
155  dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
156 
157  GUM_SCALAR newHighLimit = _lowLimit / lap->lowLimit();
158  GUM_SCALAR newLowLimit = _lowLimit / lap->lowLimit();
159 
160  GUM_SCALAR newVal = _lowLimit / lap->highLimit();
161 
162  if (newHighLimit < newVal) newHighLimit = newVal;
163 
164  if (newLowLimit > newVal) newLowLimit = newVal;
165 
166  newVal = _highLimit / lap->lowLimit();
167 
168  if (newHighLimit < newVal) newHighLimit = newVal;
169 
170  if (newLowLimit > newVal) newLowLimit = newVal;
171 
172  newVal = _highLimit / lap->highLimit();
173 
174  if (newHighLimit < newVal) newHighLimit = newVal;
175 
176  if (newLowLimit > newVal) newLowLimit = newVal;
177  } catch (const std::bad_cast&) {}
178  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.

+ Here is the call graph for this function:

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 181 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::highLimit(), and gum::LinearApproximationPolicy< GUM_SCALAR >::lowLimit().

182  {
183  try {
184  const LinearApproximationPolicy< GUM_SCALAR >* lap =
185  dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
186 
187  GUM_SCALAR newHighLimit =
188  _lowLimit > lap->lowLimit() ? _lowLimit : lap->lowLimit();
189  GUM_SCALAR newLowLimit =
190  _lowLimit > lap->lowLimit() ? _lowLimit : lap->lowLimit();
191 
192  GUM_SCALAR newVal =
193  _lowLimit > lap->highLimit() ? _lowLimit : lap->highLimit();
194 
195  if (newHighLimit < newVal) newHighLimit = newVal;
196 
197  if (newLowLimit > newVal) newLowLimit = newVal;
198 
199  newVal = _highLimit > lap->lowLimit() ? _highLimit : lap->lowLimit();
200 
201  if (newHighLimit < newVal) newHighLimit = newVal;
202 
203  if (newLowLimit > newVal) newLowLimit = newVal;
204 
205  newVal = _highLimit > lap->highLimit() ? _highLimit : lap->highLimit();
206 
207  if (newHighLimit < newVal) newHighLimit = newVal;
208 
209  if (newLowLimit > newVal) newLowLimit = newVal;
210  } catch (const std::bad_cast&) {}
211  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.

+ Here is the call graph for this function:

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 214 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::highLimit(), and gum::LinearApproximationPolicy< GUM_SCALAR >::lowLimit().

215  {
216  try {
217  const LinearApproximationPolicy< GUM_SCALAR >* lap =
218  dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
219 
220  GUM_SCALAR newHighLimit =
221  _lowLimit < lap->lowLimit() ? _lowLimit : lap->lowLimit();
222  GUM_SCALAR newLowLimit =
223  _lowLimit < lap->lowLimit() ? _lowLimit : lap->lowLimit();
224 
225  GUM_SCALAR newVal =
226  _lowLimit < lap->highLimit() ? _lowLimit : lap->highLimit();
227 
228  if (newHighLimit < newVal) newHighLimit = newVal;
229 
230  if (newLowLimit > newVal) newLowLimit = newVal;
231 
232  newVal = _highLimit < lap->lowLimit() ? _highLimit : lap->lowLimit();
233 
234  if (newHighLimit < newVal) newHighLimit = newVal;
235 
236  if (newLowLimit > newVal) newLowLimit = newVal;
237 
238  newVal = _highLimit < lap->highLimit() ? _highLimit : lap->highLimit();
239 
240  if (newHighLimit < newVal) newHighLimit = newVal;
241 
242  if (newLowLimit > newVal) newLowLimit = newVal;
243  } catch (const std::bad_cast&) {}
244  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.

+ Here is the call graph for this function:

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 121 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::highLimit(), and gum::LinearApproximationPolicy< GUM_SCALAR >::lowLimit().

122  {
123  try {
124  const LinearApproximationPolicy< GUM_SCALAR >* lap =
125  dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
126 
127  GUM_SCALAR newHighLimit = _lowLimit * lap->lowLimit();
128  GUM_SCALAR newLowLimit = _lowLimit * lap->lowLimit();
129 
130  GUM_SCALAR newVal = _lowLimit * lap->highLimit();
131 
132  if (newHighLimit < newVal) newHighLimit = newVal;
133 
134  if (newLowLimit > newVal) newLowLimit = newVal;
135 
136  newVal = _highLimit * lap->lowLimit();
137 
138  if (newHighLimit < newVal) newHighLimit = newVal;
139 
140  if (newLowLimit > newVal) newLowLimit = newVal;
141 
142  newVal = _highLimit * lap->highLimit();
143 
144  if (newHighLimit < newVal) newHighLimit = newVal;
145 
146  if (newLowLimit > newVal) newLowLimit = newVal;
147  } catch (const std::bad_cast&) {}
148  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.

+ Here is the call graph for this function:

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 91 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::highLimit(), and gum::LinearApproximationPolicy< GUM_SCALAR >::lowLimit().

92  {
93  try {
94  const LinearApproximationPolicy< GUM_SCALAR >* lap =
95  dynamic_cast< const LinearApproximationPolicy< GUM_SCALAR >* >(ap);
96 
97  GUM_SCALAR newHighLimit = _lowLimit - lap->lowLimit();
98  GUM_SCALAR newLowLimit = _lowLimit - lap->lowLimit();
99 
100  GUM_SCALAR newVal = _lowLimit - lap->highLimit();
101 
102  if (newHighLimit < newVal) newHighLimit = newVal;
103 
104  if (newLowLimit > newVal) newLowLimit = newVal;
105 
106  newVal = _highLimit - lap->lowLimit();
107 
108  if (newHighLimit < newVal) newHighLimit = newVal;
109 
110  if (newLowLimit > newVal) newLowLimit = newVal;
111 
112  newVal = _highLimit - lap->highLimit();
113 
114  if (newHighLimit < newVal) newHighLimit = newVal;
115 
116  if (newLowLimit > newVal) newLowLimit = newVal;
117  } catch (const std::bad_cast&) {}
118  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.

+ Here is the call graph for this function:

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 287 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::__decode(), gum::LinearApproximationPolicy< GUM_SCALAR >::_nbInterval, and GUM_ERROR.

287  {
288  if (representation > _nbInterval) {
289  GUM_ERROR(OutOfUpperBound,
290  "Interval Number asked is higher than total number of interval");
291  }
292 
293  return __decode(GUM_SCALAR(representation));
294  }
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:66

+ Here is the call graph for this function:

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 264 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::__encode(), gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, and GUM_ERROR.

Referenced by gum::LinearApproximationPolicy< GUM_SCALAR >::fromExact().

265  {
266 // we keep the bounds checked in debug mode
267 #ifndef NDEBUG
268  if (value > this->_highLimit) {
269  GUM_TRACE(value << " not in (" << this->_lowLimit << "-" << this->_highLimit
270  << ")");
271  GUM_ERROR(OutOfUpperBound, "Value asked is higher than High limit");
272  }
273 
274  if (value < this->_lowLimit) {
275  GUM_TRACE(value << " not in (" << this->_lowLimit << "-" << this->_highLimit
276  << ")");
277  GUM_ERROR(OutOfLowerBound, "Value asked is lower than low limit");
278  }
279 
280 #endif // NDEBUG
281  return __encode(value);
282  }
GUM_SCALAR _lowLimit
Lowest value possible.
Idx __encode(const GUM_SCALAR &value) const
Concretely computes the approximate representation.
GUM_SCALAR _highLimit
Highest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 54 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::__decode(), and gum::LinearApproximationPolicy< GUM_SCALAR >::encode().

Referenced by gum::LinearApproximationPolicy< GUM_SCALAR >::safeFromExact().

55  {
56  return __decode(GUM_SCALAR(encode(value)));
57  }
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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 353 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit.

Referenced by gum::LinearApproximationPolicy< GUM_SCALAR >::combineAdd(), gum::LinearApproximationPolicy< GUM_SCALAR >::combineDiv(), gum::LinearApproximationPolicy< GUM_SCALAR >::combineMax(), gum::LinearApproximationPolicy< GUM_SCALAR >::combineMin(), gum::LinearApproximationPolicy< GUM_SCALAR >::combineMult(), and gum::LinearApproximationPolicy< GUM_SCALAR >::combineSub().

353  {
354  return _highLimit;
355  }
GUM_SCALAR _highLimit
Highest value possible.

+ Here is the caller graph for this function:

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 333 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit.

Referenced by gum::LinearApproximationPolicy< GUM_SCALAR >::combineAdd(), gum::LinearApproximationPolicy< GUM_SCALAR >::combineDiv(), gum::LinearApproximationPolicy< GUM_SCALAR >::combineMax(), gum::LinearApproximationPolicy< GUM_SCALAR >::combineMin(), gum::LinearApproximationPolicy< GUM_SCALAR >::combineMult(), and gum::LinearApproximationPolicy< GUM_SCALAR >::combineSub().

333  {
334  return _lowLimit;
335  }
GUM_SCALAR _lowLimit
Lowest value possible.

+ Here is the caller graph for this function:

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 249 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::fromExact(), and GUM_ERROR.

250  {
251  if (value > this->_highLimit) {
252  GUM_ERROR(OutOfUpperBound, "Value asked is higher than high limit");
253  }
254 
255  if (value < this->_lowLimit) {
256  GUM_ERROR(OutOfLowerBound, "Value asked is lower than low limit");
257  }
258 
259  return fromExact(value);
260  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR fromExact(const GUM_SCALAR &value) const
Convert value to his approximation.
GUM_SCALAR _highLimit
Highest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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 299 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_computeNbInterval(), and gum::LinearApproximationPolicy< GUM_SCALAR >::_epsilon.

299  {
300  _epsilon = e;
302  }
GUM_SCALAR _epsilon
Approximation factor.
void _computeNbInterval()
Get the number of interval.

+ Here is the call graph for this function:

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 339 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_computeNbInterval(), gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, and GUM_ERROR.

340  {
341  if (newHighLimit < this->_lowLimit) {
342  GUM_ERROR(OutOfLowerBound, "Value asked is lower than low limit");
343  }
344 
345  _highLimit = newHighLimit;
346 
348  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
void _computeNbInterval()
Get the number of interval.

+ Here is the call graph for this function:

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 306 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_computeNbInterval(), gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, and GUM_ERROR.

307  {
308  if (newLowLimit > newHighLimit) {
309  GUM_ERROR(OutOfBounds, "Asked low value is higher than asked high value");
310  }
311 
312  _lowLimit = newLowLimit;
313  _highLimit = newHighLimit;
315  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
void _computeNbInterval()
Get the number of interval.

+ Here is the call graph for this function:

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 319 of file linearApproximationPolicy_tpl.h.

References gum::LinearApproximationPolicy< GUM_SCALAR >::_computeNbInterval(), gum::LinearApproximationPolicy< GUM_SCALAR >::_highLimit, gum::LinearApproximationPolicy< GUM_SCALAR >::_lowLimit, and GUM_ERROR.

320  {
321  if (newLowLimit > this->_highLimit) {
322  GUM_ERROR(OutOfUpperBound, "Value asked is higher than High limit");
323  }
324 
325  _lowLimit = newLowLimit;
326 
328  }
GUM_SCALAR _lowLimit
Lowest value possible.
GUM_SCALAR _highLimit
Highest value possible.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
void _computeNbInterval()
Get the number of interval.

+ Here is the call graph for this function:

Member Data Documentation


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