aGrUM  0.13.2
linearApproximationPolicy.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #ifndef GUM_LINEAR_APPROXIMATION_POLICY_H
28 #define GUM_LINEAR_APPROXIMATION_POLICY_H
29 
30 #include <agrum/agrum.h>
32 #include <typeinfo>
33 
34 namespace gum {
35 
51  template < typename GUM_SCALAR >
53  : public virtual ApproximationPolicy< GUM_SCALAR > {
54  public:
55  // ===========================================================================
57  // ===========================================================================
59 
68  LinearApproximationPolicy(GUM_SCALAR low = (GUM_SCALAR)0.0,
69  GUM_SCALAR high = (GUM_SCALAR)1.0,
70  GUM_SCALAR eps = (GUM_SCALAR)0.1);
71 
77 
79 
80  // ===========================================================================
82  // ===========================================================================
84 
90  GUM_SCALAR fromExact(const GUM_SCALAR& value) const;
91 
97 
104 
111 
117 
123 
129 
139  GUM_SCALAR safeFromExact(const GUM_SCALAR& value);
140 
148  Idx encode(const GUM_SCALAR& value) const;
149 
156  GUM_SCALAR decode(Idx representation) const;
157 
162  virtual void setEpsilon(const GUM_SCALAR& e);
163 
170  virtual void setLimits(const GUM_SCALAR& newLowLimit,
171  const GUM_SCALAR& newHighLimit);
172 
178  virtual void setLowLimit(const GUM_SCALAR& newLowLimit);
179 
184  const GUM_SCALAR& lowLimit() const;
185 
191  virtual void setHighLimit(const GUM_SCALAR& newHighLimit);
192 
197  const GUM_SCALAR& highLimit() const;
199 
200  protected:
202  GUM_SCALAR _lowLimit;
203 
205  GUM_SCALAR _highLimit;
206 
208  GUM_SCALAR _epsilon;
209 
219  Idx __encode(const GUM_SCALAR& value) const;
220 
226  GUM_SCALAR __decode(const GUM_SCALAR& representation) const;
227 
231  void _computeNbInterval();
232 
235  };
236 } // namespace gum
237 
238 
239 extern template class gum::LinearApproximationPolicy< float >;
240 extern template class gum::LinearApproximationPolicy< double >;
241 
242 
243 // Always inline template classes implementation.
245 
246 #endif /* GUM_LINEAR_APPROXIMATION_POLICY_H */
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.
const GUM_SCALAR & highLimit() const
Gets Highest possible value.
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.
Idx __encode(const GUM_SCALAR &value) const
Concretely computes the approximate representation.
void combineMin(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using min with the given gum::ApproximationPolicy.
GUM_SCALAR decode(Idx representation) const
Convert approximation representation to value.
virtual void setLimits(const GUM_SCALAR &newLowLimit, const GUM_SCALAR &newHighLimit)
Set bounds in a whole.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
GUM_SCALAR __decode(const GUM_SCALAR &representation) const
Concretely computes the approximate value from representation.
GUM_SCALAR fromExact(const GUM_SCALAR &value) const
Convert value to his approximation.
GUM_SCALAR _highLimit
Highest value possible.
Idx _nbInterval
The number of interval.
virtual void setHighLimit(const GUM_SCALAR &newHighLimit)
Sets Highest 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.
Idx encode(const GUM_SCALAR &value) const
Encode a given value into its approximation representation.
const GUM_SCALAR & lowLimit() const
Gets lowest possible value.
Classes used to practice approximation on value.
Inlined implementation of gum::LienarApproxiationPolicy.
Class implementing linear approximation policy (meaning possible value are split out in interval)...
unsigned long Idx
Type for indexes.
Definition: types.h:43
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.
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.
void _computeNbInterval()
Get the number of interval.