36 template <
typename GUM_SCALAR >
44 template <
typename GUM_SCALAR >
51 template <
typename GUM_SCALAR >
57 template <
typename GUM_SCALAR >
63 template <
typename GUM_SCALAR >
73 template <
typename GUM_SCALAR >
80 template <
typename GUM_SCALAR >
88 template <
typename GUM_SCALAR >
90 const GUM_SCALAR& value)
const {
96 template <
typename GUM_SCALAR >
104 template <
typename GUM_SCALAR >
108 if (this->
nbrDim() == 0) {
return "[]"; }
110 std::stringstream ss;
116 if (!first) { ss <<
" /"; }
119 ss << inst <<
" :: " <<
get(inst);
127 template <
typename GUM_SCALAR >
131 if (
nbrDim() == 0)
return true;
150 if (cmp(
get(i), p.
get(i))) {
return false; }
158 template <
typename GUM_SCALAR >
165 template <
typename GUM_SCALAR >
167 const std::vector< GUM_SCALAR >& v)
const {
180 template <
typename GUM_SCALAR >
182 std::initializer_list< GUM_SCALAR > l)
const {
189 for (
const auto& elt : l) {
195 template <
typename GUM_SCALAR >
197 std::function< GUM_SCALAR(GUM_SCALAR) > f)
const {
204 template <
typename GUM_SCALAR >
206 std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f,
207 GUM_SCALAR base)
const {
208 GUM_SCALAR tmp = base;
211 tmp = f(tmp,
get(i));
217 template <
typename GUM_SCALAR >
224 if (p_i ==
nullptr) {
233 i_dest.
incIn(*p_i), ++i_src) {
234 set(i_dest, src[i_src]);
239 template <
typename GUM_SCALAR >
246 for (
Idx i = 0; i < nbr; i++) {
261 set(inst, src[inst]);
264 template <
typename GUM_SCALAR >
275 set(i_dest, src[i_src]);
281 template <
typename GUM_SCALAR >
288 for (
Idx i = 0; i < nbr; i++) {
300 template <
typename GUM_SCALAR >
305 template <
typename GUM_SCALAR >
313 template <
typename GUM_SCALAR >
virtual void endMultipleChanges()=0
Call this method after doing important changes in this MultiDimContainer.
virtual void add(const DiscreteVariable &v)=0
Adds a new var to the variables of the multidimensional matrix.
Safe iterators for Sequence.
virtual ~MultiDimContainer()
Destructor.
virtual Idx nbrDim() const =0
Returns the number of vars in the multidimensional container.
virtual const DiscreteVariable & variable(Idx i) const =0
Returns a const ref to the ith var.
virtual GUM_SCALAR & _get(const Instantiation &i) const =0
Return a data, given a Instantiation.
virtual const std::string toString() const
Returns a representation of this MultiDimContainer.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Abstract base class for all multi dimensionnal containers.
Instantiation & setVals(const Instantiation &i)
Assign the values from i in the Instantiation.
Indicate whether two elements are (almost) different or not.
virtual void copy(const MultiDimContainer< GUM_SCALAR > &src)
Removes all variables in this MultiDimContainer and copy the content of src, variables included...
virtual void beginMultipleChanges()=0
Call this method before doing important changes in this MultiDimContainer.
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const
Changes the value pointed by i.
void incOut(const Instantiation &i)
Operator increment for the variables not in i.
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map's DAG in output using the Graphviz-dot format.
virtual GUM_SCALAR reduce(std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f, GUM_SCALAR base) const
compute lfold for this container
virtual Size domainSize() const =0
Returns the product of the variables domain size.
MultiDimAdressable & operator=(const MultiDimAdressable &from)
Default constructor.
bool operator!=(const MultiDimContainer< GUM_SCALAR > &p) const
Test if this MultiDimContainer is different of p.
virtual void copyFrom(const MultiDimContainer< GUM_SCALAR > &src) const
Basic copy of a MultiDimContainer.
void incIn(const Instantiation &i)
Operator increment for the variables in i.
virtual const MultiDimImplementation< GUM_SCALAR > * content() const =0
Returns the implementation for this object (may be *this).
Abstract base class for all multi dimensionnal addressable.
Class for assigning/browsing values to tuples of discrete variables.
GUM_SCALAR operator[](const Instantiation &i) const
An [] operator using a Instantiation as argument.
bool contains(const DiscreteVariable &v) const final
Indicates whether a given variable belongs to the Instantiation.
MultiDimContainer()
Default constructor.
void setFirst()
Assign the first values to the tuple of the Instantiation.
virtual void erase(const DiscreteVariable &v)=0
Removes a var from the variables of the multidimensional matrix.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.
Size Idx
Type for indexes.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
virtual void apply(std::function< GUM_SCALAR(GUM_SCALAR) > f) const
Apply a function on every element of the container.
virtual GUM_SCALAR get(const Instantiation &i) const
Returns the value pointed by i.
bool operator==(const MultiDimContainer< GUM_SCALAR > &p) const
Test if this MultiDimContainer is equal to p.
#define GUM_ERROR(type, msg)
virtual MultiDimAdressable & getMasterRef()
In order to insure the dereference for decorators, we need to virtualize the access to master pointer...
virtual void populate(const std::vector< GUM_SCALAR > &v) const
Automatically fills this MultiDimContainer with the values in v.
bool end() const
Returns true if the Instantiation reached the end.
virtual void extractFrom(const MultiDimContainer< GUM_SCALAR > &src, const Instantiation &mask)
Basic extraction of a MultiDimContainer.
void setFirstOut(const Instantiation &i)
Assign the first values in the Instantiation for the variables not in i.
MultiDimContainer & operator=(const MultiDimContainer< GUM_SCALAR > &src)
Default constructor.