26 #ifndef DOXYGEN_SHOULD_SKIP_THIS 35 template <
typename GUM_SCALAR >
37 const ScheduleMultiDim< GUM_SCALAR >& table1,
38 const ScheduleMultiDim< GUM_SCALAR >& table2,
39 MultiDimImplementation< GUM_SCALAR >* (*combine)(
40 const MultiDimImplementation< GUM_SCALAR >&,
41 const MultiDimImplementation< GUM_SCALAR >&)) :
42 ScheduleOperation< GUM_SCALAR >(
43 ScheduleOperation< GUM_SCALAR >::Type::COMBINE_MULTIDIM),
44 __table1(table1), __table2(table2), __args(0), __results(0),
50 Sequence< const DiscreteVariable* > vars =
__table1.variablesSequence();
51 const Sequence< const DiscreteVariable* >& vars2 =
56 iter != vars2.endSafe();
58 if (!vars.exists(*iter)) { vars.insert(*iter); }
63 __result =
new ScheduleMultiDim< GUM_SCALAR >(vars);
67 template <
typename GUM_SCALAR >
69 const ScheduleCombine< GUM_SCALAR >& from) :
79 template <
typename GUM_SCALAR >
80 ScheduleCombine< GUM_SCALAR >*
82 return new ScheduleCombine< GUM_SCALAR >(*this);
86 template <
typename GUM_SCALAR >
98 template <
typename GUM_SCALAR >
100 operator=(
const ScheduleCombine< GUM_SCALAR >& from) {
126 template <
typename GUM_SCALAR >
128 operator==(
const ScheduleOperation< GUM_SCALAR >& op)
const {
129 if (this->
type() != op.type())
return false;
131 const ScheduleCombine< GUM_SCALAR >& real_op =
132 static_cast< const ScheduleCombine< GUM_SCALAR >&
>(op);
139 template <
typename GUM_SCALAR >
141 operator!=(
const ScheduleOperation< GUM_SCALAR >& op)
const {
146 template <
typename GUM_SCALAR >
150 const MultiDimImplementation< GUM_SCALAR >& t1 =
__table1.multiDim();
151 const MultiDimImplementation< GUM_SCALAR >& t2 =
__table2.multiDim();
154 MultiDimImplementation< GUM_SCALAR >* res =
__combine(t1, t2);
161 template <
typename GUM_SCALAR >
163 const Sequence< const DiscreteVariable* >& seq1 =
__table1.variablesSequence();
164 const Sequence< const DiscreteVariable* >& seq2 =
__table2.variablesSequence();
166 if (seq1.empty() && seq2.empty())
return 0.0f;
170 for (
const auto var : seq1)
171 size *= var->domainSize();
173 for (
const auto var : seq2)
174 if (!seq1.exists(var)) size *= var->domainSize();
180 template <
typename GUM_SCALAR >
182 const Sequence< const DiscreteVariable* >& seq1 =
__table1.variablesSequence();
183 const Sequence< const DiscreteVariable* >& seq2 =
__table2.variablesSequence();
185 if (seq1.empty() && seq2.empty())
return std::pair< long, long >(0, 0);
189 for (
const auto var : seq1) {
190 if (std::numeric_limits< long >::max() / (long)var->domainSize() < size) {
191 GUM_ERROR(OutOfBounds,
"memory usage out of long int range");
194 size *= long(var->domainSize());
197 for (
const auto var : seq2)
198 if (!seq1.exists(var)) {
199 if (std::numeric_limits< long >::max() / (long)var->domainSize() < size) {
200 GUM_ERROR(OutOfBounds,
"memory usage out of long int range");
203 size *= long(var->domainSize());
206 return std::pair< long, long >(size, size);
210 template <
typename GUM_SCALAR >
211 INLINE
const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
214 __args =
new Sequence< const ScheduleMultiDim< GUM_SCALAR >* >;
223 template <
typename GUM_SCALAR >
224 INLINE
const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
227 __results =
new Sequence< const ScheduleMultiDim< GUM_SCALAR >* >;
235 template <
typename GUM_SCALAR >
242 template <
typename GUM_SCALAR >
243 INLINE
const ScheduleMultiDim< GUM_SCALAR >&
void execute()
executes the operation
INLINE bool operator==(const ScheduleOperation< GUM_SCALAR > &) const
operator ==
ScheduleMultiDim< GUM_SCALAR > __table1
the first table to combine
Type type() const
returns the name of the operation
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * __args
the set of ScheduleMultidims passed in arguments
a Combination operator class used for scheduling inferences
std::string toString() const
displays the content of the operation
virtual ScheduleCombine< GUM_SCALAR > * newFactory() const
virtual copy constructor: creates a clone of the operation
ScheduleCombine(const ScheduleMultiDim< GUM_SCALAR > &table1, const ScheduleMultiDim< GUM_SCALAR > &table2, MultiDimImplementation< GUM_SCALAR > *(*combine)(const MultiDimImplementation< GUM_SCALAR > &, const MultiDimImplementation< GUM_SCALAR > &))
default constructor
std::pair< long, long > memoryUsage() const
returns the memory consumption used during the operation
ScheduleCombine< GUM_SCALAR > & operator=(const ScheduleCombine< GUM_SCALAR > &)
copy operator
gum is the global namespace for all aGrUM entities
float nbOperations() const
returns an estimation of the number of elementary operations needed to perform the ScheduleOperation ...
MultiDimImplementation< GUM_SCALAR > *(* __combine)(const MultiDimImplementation< GUM_SCALAR > &, const MultiDimImplementation< GUM_SCALAR > &)
the function actually used to perform the combination
ScheduleOperation(Type t)
default constructor
~ScheduleCombine()
destructor
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * __results
the set of ScheduleMultidims resulting from the operation
ScheduleMultiDim< GUM_SCALAR > * __result
the result of the operation
ScheduleOperation< GUM_SCALAR > & operator=(const ScheduleOperation< GUM_SCALAR > &)
copy operator
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimResults() const
returns the set of multidims that should be the result of the operation
INLINE const ScheduleMultiDim< GUM_SCALAR > & result() const
returns the scheduleMultidim resulting from the execution of the operation
ScheduleMultiDim< GUM_SCALAR > __table2
the second table to combine with
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimArgs() const
returns the set of multidims passed in argument to the operation
#define GUM_ERROR(type, msg)
SequenceIteratorSafe< Key > const_iterator_safe
Types for STL compliance.
INLINE bool operator!=(const ScheduleOperation< GUM_SCALAR > &) const
operator !=