33 template <
typename GUM_SCALAR >
41 template <
typename GUM_SCALAR >
51 template <
typename GUM_SCALAR >
58 template <
typename GUM_SCALAR >
70 template <
typename GUM_SCALAR >
72 std::function< GUM_SCALAR(GUM_SCALAR) > f)
const {
76 template <
typename GUM_SCALAR >
78 std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f,
79 GUM_SCALAR base)
const {
85 template <
typename GUM_SCALAR >
96 template <
typename GUM_SCALAR >
107 template <
typename GUM_SCALAR >
112 if (variables.
size() == 1) {
126 if (pos != variables.
size() - 1) {
128 Size gap_w = this->
_gaps[variables[pos + 1]];
130 for (
Idx i = 0, j = 0; i < size; i += gap_w) {
131 Idx last = i + gap_v;
133 for (
Idx k = i; k < last; ++k, ++j)
146 template <
typename GUM_SCALAR >
152 template <
typename GUM_SCALAR >
160 template <
typename GUM_SCALAR >
169 template <
typename GUM_SCALAR >
175 template <
typename GUM_SCALAR >
182 template <
typename GUM_SCALAR >
183 INLINE
const GUM_SCALAR&
188 template <
typename GUM_SCALAR >
190 const GUM_SCALAR& data) {
195 template <
typename GUM_SCALAR >
196 INLINE
const GUM_SCALAR&
203 template <
typename GUM_SCALAR >
205 const GUM_SCALAR& data) {
212 template <
typename GUM_SCALAR >
214 static const std::string str =
"MultiDimArray";
218 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.
Headers of the MultiDimWithOffset class.
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.
gum is the global namespace for all aGrUM entities
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.
Header of the MultiDimArray class.
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.