55 template <
typename GUM_SCALAR >
62 template <
typename GUM_SCALAR >
70 template <
typename GUM_SCALAR >
89 template <
typename GUM_SCALAR >
94 template <
typename GUM_SCALAR >
107 template <
typename GUM_SCALAR >
112 template <
typename GUM_SCALAR >
130 template <
typename GUM_SCALAR >
136 template <
typename GUM_SCALAR >
141 template <
typename GUM_SCALAR >
146 template <
typename GUM_SCALAR >
151 template <
typename GUM_SCALAR >
156 template <
typename GUM_SCALAR >
161 template <
typename GUM_SCALAR >
172 template <
typename GUM_SCALAR >
188 template <
typename GUM_SCALAR >
193 template <
typename GUM_SCALAR >
207 template <
typename GUM_SCALAR >
221 template <
typename GUM_SCALAR >
226 template <
typename GUM_SCALAR >
231 template <
typename GUM_SCALAR >
248 template <
typename GUM_SCALAR >
267 template <
typename GUM_SCALAR >
281 template <
typename GUM_SCALAR >
294 template <
typename GUM_SCALAR >
307 template <
typename GUM_SCALAR >
320 template <
typename GUM_SCALAR >
334 template <
typename GUM_SCALAR >
345 template <
typename GUM_SCALAR >
354 }
catch (
NotFound const&) {
return false; }
365 template <
typename GUM_SCALAR >
374 template <
typename GUM_SCALAR >
383 template <
typename GUM_SCALAR >
385 std::stringstream sBuff;
386 sBuff << (*i) <<
" = " <<
get(*i);
390 template <
typename GUM_SCALAR >
409 for (
auto var: iter.key()->variablesSequence()) {
417 template <
typename GUM_SCALAR >
422 template <
typename GUM_SCALAR >
432 template <
typename GUM_SCALAR >
440 if (iter.key()->contains(*var)) {
453 template <
typename GUM_SCALAR >
457 delete iter.second();
474 iter != this->
slaves_().cendSafe();
483 template <
typename GUM_SCALAR >
487 delete iter.second();
496 template <
typename GUM_SCALAR >
499 GUM_SCALAR sum = (GUM_SCALAR)0;
504 current = (GUM_SCALAR)1;
511 current *= iter.key()->get(*(iter.val()));
519 std::cerr << std::endl << e.
errorContent() << std::endl;
525 template <
typename GUM_SCALAR >
530 template <
typename GUM_SCALAR >
539 template <
typename GUM_SCALAR >
544 iter.first()->replace(*x, *y);
545 iter.second()->replace(*x, *y);
555 template <
typename GUM_SCALAR >
Safe Iterators for hashtables.
BijectionIteratorSafe< T1, T2 > iterator_safe
types for STL compliance
Base class for discrete random variable.
Exception : a similar element already exists.
GUM_NODISCARD std::string errorContent() const
Returns the message content.
The class for generic Hash Tables.
Class for assigning/browsing values to tuples of discrete variables.
bool end() const
Returns true if the Instantiation reached the end.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
void inc()
Operator increment.
void setFirst()
Assign the first values to the tuple of the Instantiation.
ListConstIteratorSafe< Val > const_iterator_safe
Types for STL compliance.
Abstract base class for all multi dimensionnal addressable.
virtual bool unregisterSlave(Instantiation &i)=0
Unregister i as a slave of this MultiDimAdressable.
Multidimensional matrix stored as an array in memory.
HashTable< const Instantiation *, GUM_SCALAR > _slavesValue_
This table is used to keep the last value computed for an instantiation when the value are computed o...
bool bucketChanged() const
Returns true if the bucket need re-computation since the last computation.
bool isBucketEmpty() const
Returns true if this bucket is empty.
virtual void setChangeNotification(const Instantiation &i) override
Listen to an assignment of a value in a Instantiation.
virtual GUM_SCALAR get(const Instantiation &i) const override
Returns the value pointed by i.
Size bucketSize() const
Returns the number of MultiDimContainer in in this bukcet.
virtual void setDecNotification(const Instantiation &i) override
Listen to increment in each recorded Instantiation.
Instantiation _allVarsInst_
Instantiation over all variable in this.
MultiDimArray< GUM_SCALAR > * _bucket_
The result table of this bucket.
virtual Size realSize() const override
Returns the real number of parameters used for this table.
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const override
Default constructor.
virtual bool unregisterSlave(Instantiation &i) override
Unregister i as a slave of this MultiDimAdressable.
virtual void commitMultipleChanges_() override
Synchronize content after MultipleChanges.
const gum::VariableSet & allVariables() const
Returns the sequence of all the variables contained in the bucket.
void _initializeBuffer_()
Initialize the internal buffer.
Size _bufferSize_
The number of element allowed in bucket.
const MultiDimArray< GUM_SCALAR > & bucket() const
Returns the MultiDimArray used by this MultiDimBucket.
void setBufferSize(Size amount)
Changes the amount of memory allowed for this bucket.
Bijection< Instantiation *, Instantiation * > _instantiations_
Bijection between instantiations registered on this and their equivalent on bucket.
void _eraseVariable_(const DiscreteVariable *var)
Erase a variable from allVariables if no other multidimensional table uses it in this bucket.
GUM_SCALAR _computeValue_(const Instantiation &value) const
Compute the value of the final table of this bucket given i.
virtual MultiDimAdressable & getMasterRef() override
In order to insure the dereference for decorators, we need to virtualize the access to master pointer...
bool contains(const MultiDimContainer< GUM_SCALAR > &impl) const
Returns true if the MultiDimContainer is in this bucket.
void _eraseBuffer_()
Clean the buffer and switch it's instantiation to this bucket.
virtual ~MultiDimBucket()
Destructor.
bool _changed_
Flag used to know if changes has occurred in the bucket since last computation.
virtual bool registerSlave(Instantiation &i) override
Register i as a slave of this MultiDimAdressable.
void erase(const MultiDimContainer< GUM_SCALAR > &impl)
Remove a MultiDimContainer from this bucket.
const HashTable< const MultiDimContainer< GUM_SCALAR > *, Instantiation * > & multidims() const
Returns the MultiDimContainer and their respective Instantiation.
void add(const MultiDimContainer< GUM_SCALAR > &impl)
Add a MultiDimContainer in the bucket.
virtual void setLastNotification(const Instantiation &i) override
Listen to setLast in a given Instantiation.
const std::string & name() const override
Returns the real name of the multiDim implementation.
virtual void setFirstNotification(const Instantiation &i) override
Listen to setFirst in a given Instantiation.
std::string _name_
The class name.
virtual void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
Size bufferSize() const
Returns the amount of memory allowed for this bucket.
HashTable< const MultiDimContainer< GUM_SCALAR > *, Instantiation * > _multiDims_
The set of MultiDimContainer in this bucket.
void _addVariable_(const DiscreteVariable *var)
Add a variable to allVariables, and do nothing if var is already in the set.
void compute(bool force=false) const
This method computes the final table of this bucket.
virtual void changeNotification(const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval) override
Listen to changes in a given Instantiation.
MultiDimBucket(Size bufferSize=INT_MAX)
Default constructor.
virtual void setIncNotification(const Instantiation &i) override
Listen to increment in a given Instantiation.
virtual GUM_SCALAR & get_(const Instantiation &i) const override
gum::VariableSet _allVariables_
The set of all variables of the multidims in this bucket.
Abstract base class for all multi dimensionnal containers.
virtual std::string toString() const
Returns a representation of this MultiDimContainer.
virtual bool empty() const override
Returns true if no var is in *this.
virtual void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
virtual void commitMultipleChanges_()
Synchronize content after MultipleChanges.
const List< Instantiation * > & slaves_() const
Returns a constant reference over the list of slaved instantiations.
virtual Size domainSize() const override
Returns the product of the variables domain size.
virtual void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
virtual void erase(const DiscreteVariable &v) override
Removes a var from the variables of the multidimensional matrix.
virtual bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
virtual bool registerSlave(Instantiation &slave) override
Register i as a slave of this MultiDimAdressable.
bool isInMultipleChangeMethod_() const
Get the actual change method of this MultiDimImplementation.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.
MultiDimReadOnly()
Default constructor.
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
Exception : problem with size.
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Headers of the MultiDimBucket class.
gum is the global namespace for all aGrUM entities
Set< const DiscreteVariable * > VariableSet