61 template <
typename GUM_ELEMENT >
70 template <
typename GUM_ELEMENT >
80 template <
typename GUM_ELEMENT >
90 template <
typename GUM_ELEMENT >
102 template <
typename GUM_ELEMENT >
106 if (lg > std::numeric_limits< Idx >::max() / v.
domainSize()) {
111 gaps_.insert(&v, lg);
116 template <
typename GUM_ELEMENT >
121 if (variables.
size() == 1) {
128 for (
Idx i =
pos + 1; i < variables.
size(); ++i) {
129 gaps_[variables[i]] /= v_size;
138 template <
typename GUM_ELEMENT >
148 if (newval >= oldval) {
159 template <
typename GUM_ELEMENT >
167 template <
typename GUM_ELEMENT >
175 template <
typename GUM_ELEMENT >
183 template <
typename GUM_ELEMENT >
192 template <
typename GUM_ELEMENT >
201 template <
typename GUM_ELEMENT >
214 template <
typename GUM_ELEMENT >
228 template <
typename GUM_ELEMENT >
232 for (
auto iter =
gaps_.begin(); iter !=
gaps_.end(); ++iter)
267 template <
typename GUM_ELEMENT >
270 for (
Idx i = 0; i < this->
nbrDim(); ++i) {
277 GUM_ASSERT(indice == 0);
281 template <
typename GUM_ELEMENT >
290 template <
typename GUM_ELEMENT >
297 template <
typename GUM_ELEMENT >
Base class for discrete random variable.
virtual Size domainSize() const =0
Class for assigning/browsing values to tuples of discrete variables.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
bool contains(const DiscreteVariable &v) const final
Indicates whether a given variable belongs to the Instantiation.
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
Exception: at least one argument passed to a function is not what was expected.
MultiDimAdressable & operator=(const MultiDimAdressable &from)
Default constructor.
virtual std::string toString() const
Returns a representation of this MultiDimContainer.
Idx pos(const DiscreteVariable &v) const override
Returns the index of a variable.
void erase(const DiscreteVariable &v) override
Removes a var from the variables of the multidimensional matrix.
Size domainSize() const override
Returns the product of the variables domain size.
const Sequence< const DiscreteVariable * > & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
const DiscreteVariable & variable(Idx i) const override
Returns a const ref to the ith var.
MultiDimImplementation()
Default constructor.
bool registerSlave(Instantiation &slave) override
Register i as a slave of this MultiDimAdressable.
bool unregisterSlave(Instantiation &slave) override
Unregister i as a slave of this MultiDimAdressable.
Idx nbrDim() const override
Returns the number of vars in the multidimensional container.
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() override
Class destrucor.
void setFirstNotification(const Instantiation &i) override
Listen to setFirst in a given Instantiation.
MultiDimWithOffset()
Class constructor.
void setLastNotification(const Instantiation &i) override
Listen to setLast in a given Instantiation.
bool registerSlave(Instantiation &i) override
Register i as a slave of this MultiDimAdressable.
void setIncNotification(const Instantiation &i) override
Listen to increment in a given Instantiation.
HashTable< const DiscreteVariable *, Size > gaps_
The gaps between consecutive values of a given variable.
void setDecNotification(const Instantiation &i) override
Listen to increment in each recorded Instantiation.
void setChangeNotification(const Instantiation &i) override
Listen to an assignment of a value in a Instantiation.
MultiDimWithOffset< GUM_ELEMENT > & operator=(const MultiDimWithOffset< GUM_ELEMENT > &from)
Copy operator.
bool unregisterSlave(Instantiation &i) override
Unregister i as a slave of this MultiDimAdressable.
void changeNotification(const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval) override
Listen to changes in a given Instantiation.
HashTable< const Instantiation *, Size > offsets_
The position in the array of each slave Instantiation.
Size toOffset(const Instantiation &i) const
Compute offset from an Instantiation (in this array).
void computeInstantiationValue_(Instantiation &result, Size indice) const
For a given index of a value in the vector values, this method computes the corresponding instantiati...
void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
Instantiation & fromOffset(Instantiation &i, Size offset) const
Set the Instantiation to the values corresponding to the offset (in this array).
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.
Headers of gum::MultiDimImplementation.
Headers of the MultiDimWithOffset class.
gum is the global namespace for all aGrUM entities