33 template <
typename GUM_SCALAR >
41 template <
typename GUM_SCALAR >
48 template <
typename GUM_SCALAR >
54 template <
typename GUM_SCALAR >
60 template <
typename GUM_SCALAR >
70 template <
typename GUM_SCALAR >
77 template <
typename GUM_SCALAR >
85 template <
typename GUM_SCALAR >
87 const GUM_SCALAR& value)
const {
93 template <
typename GUM_SCALAR >
101 template <
typename GUM_SCALAR >
105 if (this->
nbrDim() == 0) {
return "[]"; }
107 std::stringstream ss;
113 if (!first) { ss <<
" /"; }
116 ss << inst <<
" :: " <<
get(inst);
124 template <
typename GUM_SCALAR >
128 if (
nbrDim() == 0)
return true;
147 if (cmp(
get(i), p.
get(i))) {
return false; }
155 template <
typename GUM_SCALAR >
162 template <
typename GUM_SCALAR >
164 const std::vector< GUM_SCALAR >& v)
const {
177 template <
typename GUM_SCALAR >
179 std::initializer_list< GUM_SCALAR > l)
const {
186 for (
const auto& elt : l) {
192 template <
typename GUM_SCALAR >
194 std::function< GUM_SCALAR(GUM_SCALAR) > f)
const {
201 template <
typename GUM_SCALAR >
203 std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f,
204 GUM_SCALAR base)
const {
205 GUM_SCALAR tmp = base;
208 tmp = f(tmp,
get(i));
214 template <
typename GUM_SCALAR >
221 if (p_i ==
nullptr) {
230 i_dest.
incIn(*p_i), ++i_src) {
231 set(i_dest, src[i_src]);
236 template <
typename GUM_SCALAR >
243 for (
Idx i = 0; i < nbr; i++) {
258 set(inst, src[inst]);
261 template <
typename GUM_SCALAR >
272 set(i_dest, src[i_src]);
278 template <
typename GUM_SCALAR >
285 for (
Idx i = 0; i < nbr; i++) {
297 template <
typename GUM_SCALAR >
302 template <
typename GUM_SCALAR >
310 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.
gum is the global namespace for all aGrUM entities
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.