36 template <
typename GUM_SCALAR >
44 template <
typename GUM_SCALAR >
54 template <
typename GUM_SCALAR >
61 template <
typename GUM_SCALAR >
73 template <
typename GUM_SCALAR >
75 std::function< GUM_SCALAR(GUM_SCALAR) > f)
const {
79 template <
typename GUM_SCALAR >
81 std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f,
82 GUM_SCALAR base)
const {
88 template <
typename GUM_SCALAR >
99 template <
typename GUM_SCALAR >
110 template <
typename GUM_SCALAR >
115 if (variables.
size() == 1) {
129 if (pos != variables.
size() - 1) {
131 Size gap_w = this->
_gaps[variables[pos + 1]];
133 for (
Idx i = 0, j = 0; i < size; i += gap_w) {
134 Idx last = i + gap_v;
136 for (
Idx k = i; k < last; ++k, ++j)
149 template <
typename GUM_SCALAR >
155 template <
typename GUM_SCALAR >
163 template <
typename GUM_SCALAR >
172 template <
typename GUM_SCALAR >
178 template <
typename GUM_SCALAR >
185 template <
typename GUM_SCALAR >
186 INLINE
const GUM_SCALAR&
191 template <
typename GUM_SCALAR >
193 const GUM_SCALAR& data) {
198 template <
typename GUM_SCALAR >
199 INLINE
const GUM_SCALAR&
206 template <
typename GUM_SCALAR >
208 const GUM_SCALAR& data) {
215 template <
typename GUM_SCALAR >
217 static const std::string str =
"MultiDimArray";
221 template <
typename GUM_SCALAR >
std::vector< GUM_SCALAR > _values
The true data : the values is mutable since we can change the value / in a const multiDimArray.
virtual Size realSize() const
Returns the real size of this MultiDimArray.
Idx pos(const Key &key) const
Returns the position of the object passed in argument (if it exists).
virtual void erase(const DiscreteVariable &v)
Removes a variable.
HashTable< const Instantiation *, Size > _offsets
The position in the array of each slave Instantiation.
virtual GUM_SCALAR & _get(const Instantiation &i) const
Return a data, given a Instantiation.
Size size() const noexcept
Returns the size of the sequence.
The generic class for storing (ordered) sequences of objects.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void copyFrom(const MultiDimContainer< GUM_SCALAR > &src) const
Copy from a other MultiDimContainer.
HashTable< const DiscreteVariable *, Size > _gaps
The gaps between consecutive values of a given variable.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Abstract base class for all multi dimensionnal containers.
virtual bool empty() const override
Returns true if no var is in *this.
virtual void apply(std::function< GUM_SCALAR(GUM_SCALAR) > f) const
Apply a function on every element of the container.
void unsafeSet(Idx offset, const GUM_SCALAR &val)
Modifies the element stored in the multidimArray at a given offset.
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
virtual ~MultiDimArray()
Copy operator.
virtual void _commitMultipleChanges()
Synchronize content after MultipleChanges.
bool _isInMultipleChangeMethod() const
Get the actual change method of this MultiDimImplementation.
void setByOffset(Idx offset, const GUM_SCALAR &val)
Modifies the element stored in the multidimArray at a given offset.
virtual Size domainSize() const =0
Abstract class for Multidimensional matrix stored as an array in memory and with an offset associated...
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
virtual GUM_SCALAR reduce(std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f, GUM_SCALAR base) const
compute lfold for this container
virtual void fill(const GUM_SCALAR &d) const
Fills the MultiDimArray with the given value.
Multidimensional matrix stored as an array in memory.
virtual void erase(const DiscreteVariable &v)
Removes a var from the variables of the multidimensional matrix.
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const
Default constructor.
Size _getOffs(const Instantiation &i) const
Compute the offset of a Instantiation.
virtual void copyFrom(const MultiDimContainer< GUM_SCALAR > &src) const
Basic copy of a MultiDimContainer.
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y)
Replace variable x by y.
virtual const std::string & name() const
Returns the MultiDimArray name.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
const GUM_SCALAR & getByOffset(Idx offset) const
Returns the element stored in the multidimArray at a given offset.
Class for assigning/browsing values to tuples of discrete variables.
virtual Size domainSize() const override
Returns the product of the variables domain size.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
MultiDimArray()
Default constructor.
Size Idx
Type for indexes.
virtual Idx pos(const DiscreteVariable &v) const override
Returns the index of a variable.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const GUM_SCALAR & unsafeGet(Idx offset) const
Returns the element stored in the multidimArray at a given offset.
#define GUM_ERROR(type, msg)
virtual void add(const DiscreteVariable &v)
Adds a variable.