57 template <
typename GUM_SCALAR >
68 template <
typename GUM_SCALAR >
80 template <
typename GUM_SCALAR >
88 (*iter)->forgetMaster();
93 template <
typename GUM_SCALAR >
100 for (
const auto& w: _vars_) {
101 if (w->name() == v.
name())
103 "A var with name '" << v.
name() <<
"' already exists in this instantiation");
114 (*iter)->addWithMaster(
this, v);
117 if (isInMultipleChangeMethod_()) _setNotCommitedChange_();
122 template <
typename GUM_SCALAR >
136 (*iter)->eraseWithMaster(
this, v);
139 if (isInMultipleChangeMethod_()) _setNotCommitedChange_();
143 template <
typename GUM_SCALAR >
152 template <
typename GUM_SCALAR >
160 if (!slave.
contains(*iter))
return false;
171 template <
typename GUM_SCALAR >
177 template <
typename GUM_SCALAR >
182 template <
typename GUM_SCALAR >
187 template <
typename GUM_SCALAR >
189 return *(
_vars_.atPos(i));
192 template <
typename GUM_SCALAR >
195 for (
const auto& v:
_vars_) {
199 GUM_ERROR(
NotFound,
"'" << name <<
"' can not be found in the multidim structure.")
202 template <
typename GUM_SCALAR >
207 template <
typename GUM_SCALAR >
214 template <
typename GUM_SCALAR >
221 template <
typename GUM_SCALAR >
227 template <
typename GUM_SCALAR >
232 template <
typename GUM_SCALAR >
239 _internalChangeMethod_ = _InternalChangeMethod_::DIRECT_CHANGE;
242 template <
typename GUM_SCALAR >
252 template <
typename GUM_SCALAR >
257 template <
typename GUM_SCALAR >
263 template <
typename GUM_SCALAR >
269 template <
typename GUM_SCALAR >
275 template <
typename GUM_SCALAR >
281 template <
typename GUM_SCALAR >
287 template <
typename GUM_SCALAR >
293 template <
typename GUM_SCALAR >
295 static const std::string str =
"MultiDimImplementation";
299 template <
typename GUM_SCALAR >
307 (**iter).replace(*x, *y);
311 template <
typename GUM_SCALAR >
317 template <
typename GUM_SCALAR >
320 return out << static_cast< const MultiDimContainer< GUM_SCALAR >& >(array);
324 template <
typename GUM_SCALAR >
330 template <
typename GUM_SCALAR >
Base class for discrete random variable.
virtual Size domainSize() const =0
Exception : a similar element already exists.
Class for assigning/browsing values to tuples of discrete variables.
void synchronizeWithMaster(const MultiDimAdressable *m)
Force the variables sequence to be the same as the master one.
bool contains(const DiscreteVariable &v) const final
Indicates whether a given variable belongs to the Instantiation.
Idx nbrDim() const final
Returns the number of variables in the Instantiation.
Generic doubly linked lists.
ListIteratorSafe< Val > iterator_safe
Types for STL compliance.
MultiDimContainer()
Default constructor.
<agrum/base/multidim/multiDimImplementation.h>
virtual bool empty() const override
Returns true if no var is in *this.
virtual const std::string & name() const=0
void _setNotCommitedChange_()
Change the internalChangeState to NOT_COMMITTED_CHANGE.
virtual void invert_(Idx p1, Idx p2)
Inverts variables at position p1 and p2.
virtual ~MultiDimImplementation()
Class destructor.
const std::string & basename() const
Returns the base class name of this MultiDimImplementation.
virtual const MultiDimImplementation< GUM_SCALAR > * content() const final
Returns the implementation for this object (may be *this).
virtual Size realSize() const =0
Returns the real number of parameters used for this table.
MultiDimImplementation()
Default constructor.
Sequence< const DiscreteVariable * > _vars_
List of discrete variables (dimensions).
virtual Idx nbrDim() const override
Returns the number of vars in the multidimensional container.
_InternalChangeState_ _internalChangeState_
The current change state.
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.
float compressionRate() const
The compression ratio of the table (depending on the type of implementation).
const List< Instantiation * > & slaves_() const
Returns a constant reference over the list of slaved instantiations.
bool isCommitNeeded_() const
Get the actual state of *this.
virtual Size domainSize() const override
Returns the product of the variables domain size.
List< Instantiation * > _slaveInstantiations_
List of instantiations of the tuples (sequences) of variables.
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.
_InternalChangeMethod_ _internalChangeMethod_
The current change method.
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.
void endMultipleChanges() override
Call this method after doing important changes in this MultiDimContainer.
Size _domainSize_
This MultiDimImplementation domain size.
const DiscreteVariable & variable(Idx i) const override
Returns a const ref to the ith var.
virtual bool unregisterSlave(Instantiation &slave) override
Unregister i as a slave of this MultiDimAdressable.
virtual Idx pos(const DiscreteVariable &v) const override
Returns the index of a variable.
void beginMultipleChanges() override
Call this method before doing important changes in this MultiDimContainer.
bool isInMultipleChangeMethod_() const
Get the actual change method of this MultiDimImplementation.
Exception : the element we looked for cannot be found.
The generic class for storing (ordered) sequences of objects.
SequenceIteratorSafe< Key > iterator_safe
Types for STL compliance.
const std::string & name() const
returns the name of the variable
#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.
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree