aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
approximationPolicy.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Classes used to practice approximation on value
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) & Jean-Christophe Magnan
27  *
28  */
29 #ifndef GUM_APPROXIMATION_POLICY_H
30 #define GUM_APPROXIMATION_POLICY_H
31 #include <agrum/agrum.h>
32 
33 namespace gum {
34 
35  /**
36  * @class ApproximationPolicy
37  * @brief Mother class for all approximation policy classes.
38  * @ingroup approximationpolicy_group
39  *
40  * @warning Doxygen does not like spanning command on multiple line, so we
41  * could not configure it with the correct include directive. Use the
42  * following code snippet to include this file.
43  * @code
44  * #include <agrum/tools/core/approximations/approximationPolicy.h>
45  * @endcode
46  */
47  template < typename GUM_SCALAR >
49  public:
50  // ===========================================================================
51  /// @name Constructors / Destructors
52  // ===========================================================================
53  /// @{
54 
55  /**
56  * @brief Default constructor.
57  */
59 
60  /**
61  * @brief Copy constructor.
62  */
63  ApproximationPolicy(const ApproximationPolicy< GUM_SCALAR >* md){};
64 
65  /// @}
66  // ===========================================================================
67  /// @name Accessors / Modifiers
68  // ===========================================================================
69  /// @{
70 
71  /**
72  * Convert value to his approximation. This method, at least in release
73  * mode, should not verify the limits
74  * @param value The converted value.
75  * @return The value approximation representation.
76  */
77  virtual GUM_SCALAR fromExact(const GUM_SCALAR& value) const = 0;
78 
79  /**
80  * @brief Combine using addition with the given gum::ApproximationPolicy.
81  * @param ap The policy to combine with.
82  */
83  virtual void combineAdd(const ApproximationPolicy< GUM_SCALAR >* ap) = 0;
84 
85  /**
86  * @brief Combine using substraction with the given
87  * gum::ApproximationPolicy.
88  * @param ap The policy to combine with.
89  */
90  virtual void combineSub(const ApproximationPolicy< GUM_SCALAR >* ap) = 0;
91 
92  /**
93  * @brief Combine using multiplication with the given
94  * gum::ApproximationPolicy.
95  * @param ap The policy to combine with.
96  */
97  virtual void combineMult(const ApproximationPolicy< GUM_SCALAR >* ap) = 0;
98 
99  /**
100  * @brief Combine using division with the given gum::ApproximationPolicy.
101  * @param ap The policy to combine with.
102  */
103  virtual void combineDiv(const ApproximationPolicy< GUM_SCALAR >* ap) = 0;
104 
105  /**
106  * @brief Combine using max with the given gum::ApproximationPolicy.
107  * @param ap The policy to combine with.
108  */
109  virtual void combineMax(const ApproximationPolicy< GUM_SCALAR >* ap) = 0;
110 
111  /**
112  * @brief Combine using min with the given gum::ApproximationPolicy.
113  * @param ap The policy to combine with.
114  */
115  virtual void combineMin(const ApproximationPolicy< GUM_SCALAR >* ap) = 0;
116 
117  /// @}
118  };
119 } // namespace gum
120 
121 #endif /* GUM_APPROXIMATION_POLICY_H */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual void combineMin(const ApproximationPolicy< GUM_SCALAR > *ap)=0
Combine using min with the given gum::ApproximationPolicy.
virtual void combineAdd(const ApproximationPolicy< GUM_SCALAR > *ap)=0
Combine using addition with the given gum::ApproximationPolicy.
ApproximationPolicy()
Default constructor.
virtual void combineMax(const ApproximationPolicy< GUM_SCALAR > *ap)=0
Combine using max with the given gum::ApproximationPolicy.
virtual GUM_SCALAR fromExact(const GUM_SCALAR &value) const =0
Convert value to his approximation.
virtual void combineMult(const ApproximationPolicy< GUM_SCALAR > *ap)=0
Combine using multiplication with the given gum::ApproximationPolicy.
virtual void combineDiv(const ApproximationPolicy< GUM_SCALAR > *ap)=0
Combine using division with the given gum::ApproximationPolicy.
ApproximationPolicy(const ApproximationPolicy< GUM_SCALAR > *md)
Copy constructor.
virtual void combineSub(const ApproximationPolicy< GUM_SCALAR > *ap)=0
Combine using substraction with the given gum::ApproximationPolicy.
Mother class for all approximation policy classes.