aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
multiDimFunctionGraphProjector.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 Class used to compute the projection of a function graph
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
27  * GONZALES(@AMU)
28  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
29  */
30 
31 #ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_PROJECTOR_H
32 #define GUM_MULTI_DIM_FUNCTION_GRAPH_PROJECTOR_H
33 
34 #include <functional>
35 
36 #include <agrum/tools/multidim/implementations/multiDimFunctionGraph.h>
37 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/terminalNodePolicies/ExactTerminalNodePolicy.h>
38 
39 namespace gum {
40 
41  // clang-format off
42  /**
43  * @class MultiDimFunctionGraphProjector
44  * @headerfile multiDimFunctionGraphProjector.h <agrum/tools/multidim/patterns/multiDimFunctionGraphProjector.h>
45  * @ingroup multidim_group
46  *
47  * @brief Class used to perform Function Graph projections
48  */
49  // clang-format on
50  template < typename GUM_SCALAR,
51  template < typename >
52  class FUNCTOR,
53  template < typename > class TerminalNodePolicy = ExactTerminalNodePolicy >
55  public:
56  // ============================================================================
57  /// @name Constructors / Destructors
58  // ============================================================================
59  /// @{
60 
61  /**
62  * @brief Default constructor.
63  */
65  const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* src,
66  const Set< const DiscreteVariable* >& delVars,
67  const GUM_SCALAR neutral);
68 
69  /**
70  * @brief Default destructor.
71  */
73 
74  /// @}
75  // ============================================================================
76  /// @name Main Method
77  // ============================================================================
78  /// @{
79 
80  /**
81  * @brief Computes and builds the Function Graph that is the result of the
82  * Projection.
83  */
85 
86  /// @}
87 
88  private:
89  /// One of the two function graphs used for the Projection
91 
92  /// The list of variables on which the projection is performed
93  const Set< const DiscreteVariable* >& _delVars_;
94 
95  /// The resulting function graph
97 
98  /// The function to be performed on the leaves
99  const FUNCTOR< GUM_SCALAR > _function_;
100 
101  /// The function to be performed on the leaves
102  const GUM_SCALAR _neutral_;
103  };
104 
105 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
106  extern template class MultiDimFunctionGraphProjector< double, std::plus >;
107 #endif
108 
109 } // namespace gum
110 
111 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/operators/multiDimFunctionGraphProjector_tpl.h>
112 
113 #endif // GUM_MULTI_DIM_FUNCTION_GRAPH_PROJECTOR_H
const FUNCTOR< GUM_SCALAR > _function_
The function to be performed on the leaves.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * _src_
One of the two function graphs used for the Projection.
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * _rd_
The resulting function graph.
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * project()
Computes and builds the Function Graph that is the result of the Projection.
const GUM_SCALAR _neutral_
The function to be performed on the leaves.
const Set< const DiscreteVariable *> & _delVars_
The list of variables on which the projection is performed.
MultiDimFunctionGraphProjector(const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > *src, const Set< const DiscreteVariable * > &delVars, const GUM_SCALAR neutral)
Default constructor.
Class used to perform Function Graph projections.