51#ifndef DOXYGEN_SHOULD_SKIP_THIS
60 template <
class TABLE >
65 GUM_CONSTRUCTOR(MultiDimProjection);
69 template <
class TABLE >
70 MultiDimProjection< TABLE >::MultiDimProjection(
const MultiDimProjection< TABLE >& from) :
73 GUM_CONS_CPY(MultiDimProjection);
77 template <
class TABLE >
78 MultiDimProjection< TABLE >::~MultiDimProjection() {
80 GUM_DESTRUCTOR(MultiDimProjection);
84 template <
class TABLE >
85 MultiDimProjection< TABLE >* MultiDimProjection< TABLE >::clone()
const {
86 return new MultiDimProjection< TABLE >(*
this);
90 template <
class TABLE >
91 INLINE TABLE* MultiDimProjection< TABLE >::execute(
const TABLE& table,
94 if (table.variablesSequence().empty())
return new TABLE(table);
95 else return new TABLE(proj_(table, del_vars));
99 template <
class TABLE >
100 INLINE
void MultiDimProjection< TABLE >::execute(TABLE& container,
103 if (table.variablesSequence().empty()) container = table;
104 else container = proj_(table, del_vars);
108 template <
class TABLE >
109 std::pair< ScheduleOperator*, const IScheduleMultiDim* >
110 MultiDimProjection< TABLE >::operations(
const IScheduleMultiDim* table,
112 const bool is_result_persistent)
const {
114 =
new ScheduleProjection< TABLE >(
dynamic_cast< const ScheduleMultiDim< TABLE >&
>(*table),
117 is_result_persistent);
118 return {op, &op->result()};
122 template <
class TABLE >
123 INLINE
const IScheduleMultiDim*
124 MultiDimProjection< TABLE >::schedule(Schedule& schedule,
125 const IScheduleMultiDim* table,
127 const bool is_result_persistent)
const {
128 const auto& xtable =
dynamic_cast< const ScheduleMultiDim< TABLE >&
>(*table);
129 const auto& op = schedule.emplaceProjection(xtable, del_vars, proj_, is_result_persistent);
130 return op.results()[0];
134 template <
class TABLE >
135 void MultiDimProjection< TABLE >::setProjectionFunction(TABLE (*proj)(
const TABLE&,
141 template <
class TABLE >
142 INLINE TABLE (*MultiDimProjection< TABLE >::projectionFunction())(
const TABLE&,
149 template <
class TABLE >
150 INLINE
double MultiDimProjection< TABLE >::nbOperations(
const TABLE& table,
152 return double(table.domainSize());
157 template <
class TABLE >
159 MultiDimProjection< TABLE >::nbOperations(
const Sequence< const DiscreteVariable* >& vars,
162 for (
const auto var: vars) {
163 res *=
double(var->domainSize());
169 template <
class TABLE >
170 INLINE std::pair< double, double >
171 MultiDimProjection< TABLE >::memoryUsage(
const Sequence< const DiscreteVariable* >& vars,
173 auto res =
double(
sizeof(value_type));
175 for (
const auto var: vars) {
179 res +=
double(
sizeof(TABLE));
184 template <
class TABLE >
185 INLINE std::pair< double, double >
186 MultiDimProjection< TABLE >::memoryUsage(
const TABLE& table,
188 return memoryUsage(table.variablesSequence(), del_vars);
MultiDimProjection(TABLE(*proj)(const TABLE &, const gum::VariableSet &))
Default constructor.
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
gum is the global namespace for all aGrUM entities
Set< const DiscreteVariable * > VariableSet