56 template <
typename GUM_SCALAR >
64 template <
typename GUM_SCALAR >
70 template <
typename GUM_SCALAR >
76 template <
typename GUM_SCALAR >
83 template <
typename GUM_SCALAR >
93 template <
typename GUM_SCALAR >
100 template <
typename GUM_SCALAR >
107 template <
typename GUM_SCALAR >
109 const GUM_SCALAR& value)
const {
115 template <
typename GUM_SCALAR >
122 template <
typename GUM_SCALAR >
126 if (this->
nbrDim() == 0) {
return "[]"; }
128 std::stringstream ss;
134 if (!first) { ss <<
" /"; }
137 ss << inst <<
" :: " <<
get(inst);
145 template <
typename GUM_SCALAR >
148 if (
nbrDim() == 0)
return true;
161 if (cmp(
get(i), p.
get(i))) {
return false; }
169 template <
typename GUM_SCALAR >
176 template <
typename GUM_SCALAR >
190 template <
typename GUM_SCALAR >
198 for (
const auto& elt: l) {
204 template <
typename GUM_SCALAR >
212 template <
typename GUM_SCALAR >
215 GUM_SCALAR base)
const {
216 GUM_SCALAR tmp = base;
219 tmp = f(tmp,
get(i));
224 template <
typename GUM_SCALAR >
232 if (p_i ==
nullptr) {
240 for (i_dest.setFirst(), i_src.setFirst(); !i_dest.end(); i_dest.incIn(*p_i), ++i_src) {
241 set(i_dest, src[i_src]);
246 template <
typename GUM_SCALAR >
252 for (
Idx i = 0; i < nbr; i++) {
260 this->endMultipleChanges();
267 set(inst, src[inst]);
270 template <
typename GUM_SCALAR >
281 set(i_dest, src[i_src]);
287 template <
typename GUM_SCALAR >
293 for (
Idx i = 0; i < nbr; i++) {
301 this->endMultipleChanges();
305 template <
typename GUM_SCALAR >
310 template <
typename GUM_SCALAR >
317 template <
typename GUM_SCALAR >
Exception : fatal (unknown ?) error.
Class for assigning/browsing values to tuples of discrete variables.
bool end() const
Returns true if the Instantiation reached the end.
void incOut(const Instantiation &i)
Operator increment for the variables not in i.
Instantiation & setVals(const Instantiation &i)
Assign the values from i in the Instantiation.
bool contains(const DiscreteVariable &v) const final
Indicates whether a given variable belongs to the Instantiation.
void setFirst()
Assign the first values to the tuple of the Instantiation.
void setFirstOut(const Instantiation &i)
Assign the first values in the Instantiation for the variables not in i.
MultiDimAdressable()
Default constructor.
MultiDimAdressable & operator=(const MultiDimAdressable &from)
Default constructor.
Abstract base class for all multi dimensionnal containers.
virtual void copy(const MultiDimContainer< GUM_SCALAR > &src)
Removes all variables in this MultiDimContainer and copy the content of src, variables included.
virtual void extractFrom(const MultiDimContainer< GUM_SCALAR > &src, const Instantiation &mask)
Basic extraction of a MultiDimContainer.
MultiDimContainer & operator=(const MultiDimContainer< GUM_SCALAR > &src)
Default constructor.
virtual const MultiDimImplementation< GUM_SCALAR > * content() const =0
Returns the implementation for this object (may be *this).
virtual ~MultiDimContainer()
Destructor.
virtual MultiDimAdressable & getMasterRef()
In order to insure the dereference for decorators, we need to virtualize the access to master pointer...
bool operator!=(const MultiDimContainer< GUM_SCALAR > &p) const
Test if this MultiDimContainer is different of p.
virtual void beginMultipleChanges()=0
Call this method before doing important changes in this MultiDimContainer.
virtual GUM_SCALAR & get_(const Instantiation &i) const =0
Return a data, given a Instantiation.
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const
Changes the value pointed by i.
MultiDimContainer()
Default constructor.
virtual GUM_SCALAR reduce(std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f, GUM_SCALAR base) const
compute lfold for this container
virtual GUM_SCALAR get(const Instantiation &i) const
Returns the value pointed by i.
virtual void populate(const std::vector< GUM_SCALAR > &v) const
Automatically fills this MultiDimContainer with the values in v.
GUM_SCALAR operator[](const Instantiation &i) const
An [] operator using a Instantiation as argument.
virtual void copyFrom(const MultiDimContainer< GUM_SCALAR > &src) const
Basic copy of a MultiDimContainer.
virtual void apply(std::function< GUM_SCALAR(GUM_SCALAR) > f) const
Apply a function on every element of the container.
virtual std::string toString() const
Returns a representation of this MultiDimContainer.
bool operator==(const MultiDimContainer< GUM_SCALAR > &p) const
Test if this MultiDimContainer is equal to p.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.
virtual Size domainSize() const =0
Returns the product of the variables domain size.
virtual void add(const DiscreteVariable &v)=0
virtual Idx nbrDim() const=0
virtual const DiscreteVariable & variable(Idx i) const=0
virtual void erase(const DiscreteVariable &v)=0
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.
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
bool operator==(const HashTableIteratorSafe< Key, Val > &from) const noexcept
Checks whether two iterators are pointing toward equal elements.
Indicate whether two elements are (almost) different or not.