aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
multiDimCombineAndProject.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 
28 #ifndef GUM_MULTI_DIM_COMBINE_AND_PROJECT_H
29 #define GUM_MULTI_DIM_COMBINE_AND_PROJECT_H
30 
31 #include <utility>
32 
33 #include <agrum/tools/core/sequence.h>
34 #include <agrum/tools/core/set.h>
35 #include <agrum/tools/variables/discreteVariable.h>
36 
37 namespace gum {
38 
39  // clang-format off
40  /**
41  * @class MultiDimCombineAndProject
42  * @headerfile multiDimCombineAndProject.h <agrum/tools/multidim/operators/multiDimCombineAndProject.h>
43  * @ingroup multidim_op_group
44  *
45  * @brief A generic interface to combine and project efficiently MultiDim tables.
46  */
47  // clang-format on
48  template < typename GUM_SCALAR, template < typename > class TABLE >
50  public:
51  // ========================================================================
52  /// @name Constructors / Destructors
53  // ========================================================================
54  /// @{
55 
56  /// default constructor
58 
59  /// copy constructor
62 
63  /// destructor
64  virtual ~MultiDimCombineAndProject();
65 
66  /**
67  * @brief virtual constructor
68  *
69  * @return a new fresh MultiDimCombineAndProject with the same combination
70  * and projection functions.
71  */
72  virtual MultiDimCombineAndProject< GUM_SCALAR, TABLE >* newFactory() const = 0;
73 
74  /// @}
75  // ========================================================================
76  /// @name Accessors/Modifiers
77  // ========================================================================
78  /// @{
79 
80  /**
81  * @brief creates and returns the result of the projection over the
82  * variables not in del_vars of the combination of the tables within set
83  *
84  * @return a new freshly created TABLE which is the result of the
85  * projection of the combination of all the TABLES passed in argument
86  *
87  * @throws InvalidArgumentsNumber exception is thrown if the set passed in
88  * argument contains less than two elements
89  */
90  virtual Set< const TABLE< GUM_SCALAR >* >
92  Set< const DiscreteVariable* > del_vars)
93  = 0;
94 
95  /// changes the function used for combining two TABLES
96  virtual void setCombineFunction(TABLE< GUM_SCALAR >* (
97  *combine)(const TABLE< GUM_SCALAR >&, const TABLE< GUM_SCALAR >&))
98  = 0;
99 
100  /// returns the current combination function
101  virtual TABLE< GUM_SCALAR >* (*combineFunction())(const TABLE< GUM_SCALAR >&,
102  const TABLE< GUM_SCALAR >&)
103  = 0;
104 
105  /// changes the function used for projecting TABLES
106  virtual void setProjectFunction(TABLE< GUM_SCALAR >* (
107  *proj)(const TABLE< GUM_SCALAR >&, const Set< const DiscreteVariable* >&))
108  = 0;
109 
110  /// returns the current projection function
111  virtual TABLE< GUM_SCALAR >* (*projectFunction())(
112  const TABLE< GUM_SCALAR >&,
113  const Set< const DiscreteVariable* >&)
114  = 0;
115 
116  /**
117  * @brief returns a rough estimate of the number of operations that will be
118  * performed to compute the combination.
119  */
120  virtual float
121  nbOperations(const Set< const TABLE< GUM_SCALAR >* >& set,
122  const Set< const DiscreteVariable* >& del_vars) const = 0;
123  virtual std::pair< long, long >
124  memoryUsage(const Set< const Sequence< const DiscreteVariable* >* >& set,
125  Set< const DiscreteVariable* > del_vars) const = 0;
126 
127  /// @}
128 
129  private:
130  /// forbid copy operators
133  };
134 
135 } /* namespace gum */
136 
137 // always include the template implementation
138 #include <agrum/tools/multidim/utils/operators/multiDimCombineAndProject_tpl.h>
139 
140 #endif /* GUM_MULTI_DIM_COMBINE_AND_PROJECT_H */
virtual std::pair< long, long > memoryUsage(const Set< const Sequence< const DiscreteVariable * > * > &set, Set< const DiscreteVariable * > del_vars) const =0
creates and returns the result of the projection over the variables not in del_vars of the combinatio...
virtual void setProjectFunction(TABLE< GUM_SCALAR > *(*proj)(const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable * > &))=0
changes the function used for projecting TABLES
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
A generic interface to combine and project efficiently MultiDim tables.
virtual void setCombineFunction(TABLE< GUM_SCALAR > *(*combine)(const TABLE< GUM_SCALAR > &, const TABLE< GUM_SCALAR > &))=0
changes the function used for combining two TABLES
MultiDimCombineAndProject(const MultiDimCombineAndProject< GUM_SCALAR, TABLE > &)
copy constructor
virtual Set< const TABLE< GUM_SCALAR > *> combineAndProject(Set< const TABLE< GUM_SCALAR > * > set, Set< const DiscreteVariable * > del_vars)=0
creates and returns the result of the projection over the variables not in del_vars of the combinatio...
MultiDimCombineAndProject< GUM_SCALAR, TABLE > & operator=(const MultiDimCombineAndProject< GUM_SCALAR, TABLE > &)
forbid copy operators
virtual ~MultiDimCombineAndProject()
destructor
virtual MultiDimCombineAndProject< GUM_SCALAR, TABLE > * newFactory() const =0
virtual constructor
MultiDimCombineAndProject()
default constructor
virtual float nbOperations(const Set< const TABLE< GUM_SCALAR > * > &set, const Set< const DiscreteVariable * > &del_vars) const =0
returns a rough estimate of the number of operations that will be performed to compute the combinatio...