53#ifndef DOXYGEN_SHOULD_SKIP_THIS
62 template <
class TABLE >
67 GUM_CONSTRUCTOR(MultiDimProjection);
71 template <
class TABLE >
72 MultiDimProjection< TABLE >::MultiDimProjection(
const MultiDimProjection< TABLE >& from) :
75 GUM_CONS_CPY(MultiDimProjection);
79 template <
class TABLE >
80 MultiDimProjection< TABLE >::~MultiDimProjection() {
82 GUM_DESTRUCTOR(MultiDimProjection);
86 template <
class TABLE >
87 MultiDimProjection< TABLE >* MultiDimProjection< TABLE >::clone()
const {
88 return new MultiDimProjection< TABLE >(*
this);
92 template <
class TABLE >
93 TABLE* MultiDimProjection< TABLE >::execute(
const TABLE& table,
96 if (table.variablesSequence().empty())
return new TABLE(table);
97 else return new TABLE(proj_(table, del_vars));
101 template <
class TABLE >
102 void MultiDimProjection< TABLE >::execute(TABLE& container,
105 if (table.variablesSequence().empty()) container = table;
106 else container = proj_(table, del_vars);
110 template <
class TABLE >
111 std::pair< ScheduleOperator*, const IScheduleMultiDim* >
112 MultiDimProjection< TABLE >::operations(
const IScheduleMultiDim* table,
114 const bool is_result_persistent)
const {
116 =
new ScheduleProjection< TABLE >(
dynamic_cast< const ScheduleMultiDim< TABLE >&
>(*table),
119 is_result_persistent);
120 return {op, &op->result()};
124 template <
class TABLE >
125 const IScheduleMultiDim*
126 MultiDimProjection< TABLE >::schedule(Schedule& schedule,
127 const IScheduleMultiDim* table,
129 const bool is_result_persistent)
const {
130 const auto& xtable =
dynamic_cast< const ScheduleMultiDim< TABLE >&
>(*table);
131 const auto& op = schedule.emplaceProjection(xtable, del_vars, proj_, is_result_persistent);
132 return op.results()[0];
136 template <
class TABLE >
137 void MultiDimProjection< TABLE >::setProjectionFunction(TABLE (*proj)(
const TABLE&,
143 template <
class TABLE >
144 TABLE (*MultiDimProjection< TABLE >::projectionFunction())(
const TABLE&,
151 template <
class TABLE >
152 double MultiDimProjection< TABLE >::nbOperations(
const TABLE& table,
154 return double(table.domainSize());
159 template <
class TABLE >
160 double MultiDimProjection< TABLE >::nbOperations(
const Sequence< const DiscreteVariable* >& vars,
163 for (
const auto var: vars) {
164 res *=
double(var->domainSize());
170 template <
class TABLE >
171 std::pair< double, double >
172 MultiDimProjection< TABLE >::memoryUsage(
const Sequence< const DiscreteVariable* >& vars,
174 auto res =
double(
sizeof(value_type));
176 for (
const auto var: vars) {
180 res +=
double(
sizeof(TABLE));
185 template <
class TABLE >
186 std::pair< double, double >
187 MultiDimProjection< TABLE >::memoryUsage(
const TABLE& table,
189 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