29 #ifndef DOXYGEN_SHOULD_SKIP_THIS 38 template <
typename GUM_SCALAR >
40 const ScheduleMultiDim< GUM_SCALAR >& table1,
41 const ScheduleMultiDim< GUM_SCALAR >& table2,
42 MultiDimImplementation< GUM_SCALAR >* (*combine)(
43 const MultiDimImplementation< GUM_SCALAR >&,
44 const MultiDimImplementation< GUM_SCALAR >&)) :
45 ScheduleOperation< GUM_SCALAR >(
46 ScheduleOperation< GUM_SCALAR >::Type::COMBINE_MULTIDIM),
47 __table1(table1), __table2(table2), __args(0), __results(0),
53 Sequence< const DiscreteVariable* > vars =
__table1.variablesSequence();
54 const Sequence< const DiscreteVariable* >& vars2 =
59 iter != vars2.endSafe();
61 if (!vars.exists(*iter)) { vars.insert(*iter); }
66 __result =
new ScheduleMultiDim< GUM_SCALAR >(vars);
70 template <
typename GUM_SCALAR >
72 const ScheduleCombine< GUM_SCALAR >& from) :
82 template <
typename GUM_SCALAR >
83 ScheduleCombine< GUM_SCALAR >*
85 return new ScheduleCombine< GUM_SCALAR >(*this);
89 template <
typename GUM_SCALAR >
101 template <
typename GUM_SCALAR >
103 operator=(
const ScheduleCombine< GUM_SCALAR >& from) {
129 template <
typename GUM_SCALAR >
131 operator==(
const ScheduleOperation< GUM_SCALAR >& op)
const {
132 if (this->
type() != op.type())
return false;
134 const ScheduleCombine< GUM_SCALAR >& real_op =
135 static_cast< const ScheduleCombine< GUM_SCALAR >&
>(op);
142 template <
typename GUM_SCALAR >
144 operator!=(
const ScheduleOperation< GUM_SCALAR >& op)
const {
149 template <
typename GUM_SCALAR >
153 const MultiDimImplementation< GUM_SCALAR >& t1 =
__table1.multiDim();
154 const MultiDimImplementation< GUM_SCALAR >& t2 =
__table2.multiDim();
157 MultiDimImplementation< GUM_SCALAR >* res =
__combine(t1, t2);
164 template <
typename GUM_SCALAR >
166 const Sequence< const DiscreteVariable* >& seq1 =
__table1.variablesSequence();
167 const Sequence< const DiscreteVariable* >& seq2 =
__table2.variablesSequence();
169 if (seq1.empty() && seq2.empty())
return 0.0f;
173 for (
const auto var : seq1)
174 size *= var->domainSize();
176 for (
const auto var : seq2)
177 if (!seq1.exists(var)) size *= var->domainSize();
183 template <
typename GUM_SCALAR >
185 const Sequence< const DiscreteVariable* >& seq1 =
__table1.variablesSequence();
186 const Sequence< const DiscreteVariable* >& seq2 =
__table2.variablesSequence();
188 if (seq1.empty() && seq2.empty())
return std::pair< long, long >(0, 0);
192 for (
const auto var : seq1) {
193 if (std::numeric_limits< long >::max() / (long)var->domainSize() < size) {
194 GUM_ERROR(OutOfBounds,
"memory usage out of long int range");
197 size *= long(var->domainSize());
200 for (
const auto var : seq2)
201 if (!seq1.exists(var)) {
202 if (std::numeric_limits< long >::max() / (long)var->domainSize() < size) {
203 GUM_ERROR(OutOfBounds,
"memory usage out of long int range");
206 size *= long(var->domainSize());
209 return std::pair< long, long >(size, size);
213 template <
typename GUM_SCALAR >
214 INLINE
const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
217 __args =
new Sequence< const ScheduleMultiDim< GUM_SCALAR >* >;
226 template <
typename GUM_SCALAR >
227 INLINE
const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >&
230 __results =
new Sequence< const ScheduleMultiDim< GUM_SCALAR >* >;
238 template <
typename GUM_SCALAR >
245 template <
typename GUM_SCALAR >
246 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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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 !=