61 template <
typename GUM_ELEMENT >
70 template <
typename GUM_ELEMENT >
80 template <
typename GUM_ELEMENT >
90 template <
typename GUM_ELEMENT >
94 if (lg > std::numeric_limits< Idx >::max() / v.
domainSize()) {
104 template <
typename GUM_ELEMENT >
109 if (variables.
size() == 1) {
116 for (
Idx i =
pos + 1; i < variables.
size(); ++i) {
117 gaps_[variables[i]] /= v_size;
126 template <
typename GUM_ELEMENT >
136 if (newval >= oldval) {
147 template <
typename GUM_ELEMENT >
155 template <
typename GUM_ELEMENT >
163 template <
typename GUM_ELEMENT >
171 template <
typename GUM_ELEMENT >
180 template <
typename GUM_ELEMENT >
189 template <
typename GUM_ELEMENT >
202 template <
typename GUM_ELEMENT >
216 template <
typename GUM_ELEMENT >
220 for (
auto iter =
gaps_.begin(); iter !=
gaps_.end(); ++iter)
255 template <
typename GUM_ELEMENT >
258 for (
Idx i = 0; i < this->
nbrDim(); ++i) {
265 GUM_ASSERT(indice == 0);
269 template <
typename GUM_ELEMENT >
278 template <
typename GUM_ELEMENT >
285 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.
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.
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.
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