57 template <
typename GUM_SCALAR >
64 template <
typename GUM_SCALAR >
72 template <
typename GUM_SCALAR >
79 template <
typename GUM_SCALAR >
88 template <
typename GUM_SCALAR >
93 template <
typename GUM_SCALAR >
96 GUM_SCALAR base)
const {
101 template <
typename GUM_SCALAR >
111 template <
typename GUM_SCALAR >
120 template <
typename GUM_SCALAR >
125 if (variables.
size() == 1) {
139 if (
pos != variables.
size() - 1) {
143 for (
Idx i = 0, j = 0; i < size; i += gap_w) {
144 Idx last = i + gap_v;
146 for (
Idx k = i; k < last; ++k, ++j)
159 template <
typename GUM_SCALAR >
165 template <
typename GUM_SCALAR >
173 template <
typename GUM_SCALAR >
181 template <
typename GUM_SCALAR >
187 template <
typename GUM_SCALAR >
193 template <
typename GUM_SCALAR >
198 template <
typename GUM_SCALAR >
204 template <
typename GUM_SCALAR >
211 template <
typename GUM_SCALAR >
219 template <
typename GUM_SCALAR >
222 static const std::string str(
"MultiDimArray");
226 template <
typename GUM_SCALAR >
231 template <
typename GUM_SCALAR >
236 template <
typename GUM_SCALAR >
Base class for discrete random variable.
virtual Size domainSize() const =0
Class for assigning/browsing values to tuples of discrete variables.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
Multidimensional matrix stored as an array in memory.
void commitMultipleChanges_() final
Synchronize content after MultipleChanges.
void add(const DiscreteVariable &v) override
Adds a variable.
const GUM_ELEMENT & unsafeGet(Idx offset) const
Returns the element stored in the multidimArray at a given offset.
GUM_ELEMENT reduce(std::function< GUM_ELEMENT(GUM_ELEMENT, GUM_ELEMENT) > f, GUM_ELEMENT base) const override
compute lfold for this container
void erase(const DiscreteVariable &v) override
Removes a variable.
void setByOffset(Idx offset, const GUM_ELEMENT &val)
Modifies the element stored in the multidimArray at a given offset.
const GUM_ELEMENT * data() const noexcept override
Returns a pointer to the contiguous data buffer.
const std::string & name() const override
Returns the MultiDimArray name.
MultiDimContainer< GUM_ELEMENT > * newFactory() const override
Default constructor.
const GUM_ELEMENT & getByOffset(Idx offset) const
Returns the element stored in the multidimArray at a given offset.
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) final
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.
std::vector< GUM_ELEMENT > values_
The true data : the values is mutable since we can change the value / in a const multiDimArray.
MultiDimArray()
Default constructor.
GUM_ELEMENT & get_(const Instantiation &i) const final
Return a data, given a Instantiation.
void fill(const GUM_ELEMENT &d) const override
Fills the MultiDimArray with the given value.
void copyFrom(const MultiDimContainer< GUM_ELEMENT > &src) const override
Copy from a other MultiDimContainer.
void unsafeSet(Idx offset, const GUM_ELEMENT &val)
Modifies the element stored in the multidimArray at a given offset.
void apply(std::function< GUM_ELEMENT(GUM_ELEMENT) > f) const override
Apply a function on every element of the container.
~MultiDimArray() override
Copy operator.
Size realSize() const override
Returns the real size of this MultiDimArray.
virtual void copyFrom(const MultiDimContainer< GUM_ELEMENT > &src) const
Basic copy of a MultiDimContainer.
Idx pos(const DiscreteVariable &v) const override
Returns the index of a variable.
Size domainSize() const override
Returns the product of the variables domain size.
bool isInMultipleChangeMethod_() const
Get the actual change method of this MultiDimImplementation.
const Sequence< const DiscreteVariable * > & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
bool empty() const override
Returns true if no var is in *this.
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
Abstract class for Multidimensional matrix stored as an array in memory and with an offset associated...
Size getOffs_(const Instantiation &i) const
Compute the offset of a Instantiation.
void erase(const DiscreteVariable &v) override
Removes a var from the variables of the multidimensional matrix.
MultiDimWithOffset()
Class constructor.
HashTable< const DiscreteVariable *, Size > gaps_
The gaps between consecutive values of a given variable.
HashTable< const Instantiation *, Size > offsets_
The position in the array of each slave Instantiation.
void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
Exception : out of bound.
Idx pos(const Key &key) const
Returns the position of the object passed in argument (if it exists).
Size size() const noexcept
Returns the size of the sequence.
The generic class for storing (ordered) sequences of objects.
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Header of the MultiDimArray class.
Headers of the MultiDimWithOffset class.
gum is the global namespace for all aGrUM entities