aGrUM  0.21.0
a C++ library for (probabilistic) graphical models
scheduleCombination_tpl.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 /** @file
23  * @brief A generic class to combine efficiently several ScheduleMultiDims
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 
30 # include <agrum/agrum.h>
31 
32 namespace gum {
33 
34  /// constructor
35  template < typename GUM_SCALAR >
36  ScheduleCombination< GUM_SCALAR >::ScheduleCombination() {
37  /// for debugging purposes
38  GUM_CONSTRUCTOR(ScheduleCombination);
39  }
40 
41  /// copy constructor
42  template < typename GUM_SCALAR >
45  /// for debugging purposes
47  }
48 
49  /// destructor
50  template < typename GUM_SCALAR >
52  /// for debugging purposes
54  }
55 
56  // adds to a given schedule the operations necessary to perform a combination
57  template < typename GUM_SCALAR >
59  const Set< const MultiDimImplementation< GUM_SCALAR >* >& set,
61  // first wrap the multidimimplementations into ScheduleMultiDims
63 
64  for (const auto pot: set)
66 
67  // perform the combination
69 
70  // deallocate the wrappers we just constructed
71  for (const auto sched: sched_set)
72  delete sched;
73 
74  return res;
75  }
76 
77  // adds to a given schedule the operations necessary to perform a combination
78  template < typename GUM_SCALAR >
79  template < template < typename > class TABLE >
83  // first wrap the TABLES into ScheduleMultiDims
85 
86  for (const auto tab: set)
88 
89  // perform the combination
91 
92  // deallocate the wrappers we just constructed
93  for (const auto sched: sched_set)
94  delete sched;
95 
96  return res;
97  }
98 
99  /** @brief returns a rough estimate of the number of operations that will be
100  * performed to compute the combination */
101  template < typename GUM_SCALAR >
103  const Set< const MultiDimImplementation< GUM_SCALAR >* >& set,
104  const Schedule< GUM_SCALAR >& schedule) {
105  // first wrap the multidimimplementations into ScheduleMultiDims
107 
108  for (const auto pot: set)
110 
111  // perform the combination
113 
114  // deallocate the wrappers we just constructed
115  for (const auto sched: sched_set)
116  delete sched;
117 
118  return res;
119  }
120 
121  /** @brief returns a rough estimate of the number of operations that will be
122  * performed to compute the combination */
123  template < typename GUM_SCALAR >
124  template < template < typename > class TABLE >
125  float
127  const Schedule< GUM_SCALAR >& schedule) {
128  // first wrap the TABLES into ScheduleMultiDims
130 
131  for (const auto tab: set)
133 
134  // perform the combination
136 
137  // deallocate the wrappers we just constructed
138  for (const auto sched: sched_set)
139  delete sched;
140 
141  return res;
142  }
143 
144  /// returns the memory consumption used during the combination
145  template < typename GUM_SCALAR >
147  const Set< const MultiDimImplementation< GUM_SCALAR >* >& set,
148  const Schedule< GUM_SCALAR >& schedule) {
149  // first wrap the multidimimplementations into ScheduleMultiDims
151 
152  for (const auto pot: set)
154 
155  // compute the memory consumption of the combination
156  std::pair< long, long > res = memoryUsage(sched_set, schedule);
157 
158  // deallocate the wrappers we just constructed
159  for (const auto sched: sched_set)
160  delete sched;
161 
162  return res;
163  }
164 
165  /** @brief returns a rough estimate of the number of operations that will be
166  * performed to compute the combination */
167  template < typename GUM_SCALAR >
168  template < template < typename > class TABLE >
169  std::pair< long, long >
171  const Schedule< GUM_SCALAR >& schedule) {
172  // first wrap the TABLES into ScheduleMultiDims
174 
175  for (const auto tab: set)
177 
178  // compute the memory consumption of the combination
179  std::pair< long, long > res = memoryUsage(sched_set, schedule);
180 
181  // deallocate the wrappers we just constructed
182  for (const auto sched: sched_set)
183  delete sched;
184 
185  return res;
186  }
187 
188 } /* namespace gum */
189 
190 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643