48 template <
typename GUM_SCALAR >
51 const Tensor< GUM_SCALAR >& source) {
53 Tensor< GUM_SCALAR >* p = 0;
66 p =
new Tensor< GUM_SCALAR >(
70 p->add(*(bij.
second(var)));
84 return new Tensor< GUM_SCALAR >();
116 template <
typename GUM_SCALAR >
117 Tensor< GUM_SCALAR >
multTensor(
const Tensor< GUM_SCALAR >& t1,
118 const Tensor< GUM_SCALAR >& t2) {
122 template <
typename GUM_SCALAR >
124 Set< Tensor< GUM_SCALAR >* >& pool,
125 Set< Tensor< GUM_SCALAR >* >& trash) {
126 Tensor< GUM_SCALAR >* pot =
nullptr;
127 Tensor< GUM_SCALAR >* tmp =
nullptr;
133 for (
const auto p: pool)
134 if (p->contains(*var)) pots.
insert(p);
136 if (pots.
size() == 0) {
138 }
else if (pots.
size() == 1) {
139 tmp =
const_cast< Tensor< GUM_SCALAR >*
>(*pots.
begin());
140 pot =
new Tensor< GUM_SCALAR >(tmp->sumOut(var_set));
144 pot =
new Tensor< GUM_SCALAR >(tmp->sumOut(var_set));
148 for (
const auto p: pots) {
149 pool.erase(
const_cast< Tensor< GUM_SCALAR >*
>(p));
151 if (trash.exists(
const_cast< Tensor< GUM_SCALAR >*
>(p))) {
152 trash.erase(
const_cast< Tensor< GUM_SCALAR >*
>(p));
153 delete const_cast< Tensor< GUM_SCALAR >*
>(p);
161 template <
typename GUM_SCALAR >
163 Set< Tensor< GUM_SCALAR >* >& pool,
164 Set< Tensor< GUM_SCALAR >* >& trash) {
165 for (
auto var: elim_order) {
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
Set of pairs of elements with fast search for both elements.
Base class for discrete random variable.
Base class for all aGrUM's exceptions.
Exception : fatal (unknown ?) error.
Multidimensional matrix stored as an array in memory.
Decorator of a MultiDimArray, using a bijection over the variables.
A multidim implementation for buckets.
A class to combine efficiently several MultiDim tables.
TABLE * execute(const Set< const TABLE * > &set) const final
Creates and returns the result of the combination of the tables within set.
<agrum/base/multidim/multiDimImplementation.h>
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const override=0
Creates an empty clone of this MultiDimContainer.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
Abstract base class for all multi dimensionnal read only structure.
Multidimensional matrix stored as a sparse array in memory.
Exception : operation not allowed.
iterator begin() const
The usual unsafe begin iterator to parse the set.
Size size() const noexcept
Returns the number of elements in the set.
void insert(const Key &k)
Inserts a new element into the set.
<agrum/base/multidim/aggregators/multiDimAggregator.h>
#define GUM_ERROR(type, msg)
namespace for all probabilistic relational models entities
Tensor< GUM_SCALAR > multTensor(const Tensor< GUM_SCALAR > &t1, const Tensor< GUM_SCALAR > &t2)
void eliminateNode(const DiscreteVariable *var, Set< Tensor< GUM_SCALAR > * > &pool, Set< Tensor< GUM_SCALAR > * > &trash)
Proceeds with the elimination of var in pool.
void eliminateNodes(const std::vector< const DiscreteVariable * > &elim_order, Set< Tensor< GUM_SCALAR > * > &pool, Set< Tensor< GUM_SCALAR > * > &trash)
Tensor< GUM_SCALAR > * copyTensor(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const Tensor< GUM_SCALAR > &source)
Returns a copy of a Tensor after applying a bijection over the variables in source.
gum is the global namespace for all aGrUM entities
Set< const DiscreteVariable * > VariableSet