aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::MultiDimDecorator< GUM_SCALAR > Class Template Referenceabstract

Decorator design pattern in order to separate implementations from multidimensional matrix concepts. More...

#include <agrum/base/multidim/multiDimDecorator.h>

Inheritance diagram for gum::MultiDimDecorator< GUM_SCALAR >:
Collaboration diagram for gum::MultiDimDecorator< GUM_SCALAR >:

Public Member Functions

Constructors / Destructors
 MultiDimDecorator (MultiDimImplementation< GUM_SCALAR > *aContent=nullptr, GUM_SCALAR empty_value=(GUM_SCALAR) 0)
 Class constructor.
 MultiDimDecorator (const MultiDimDecorator< GUM_SCALAR > &from)
 copy constructor & assignment
MultiDimDecorator< GUM_SCALAR > & operator= (const MultiDimDecorator &from) noexcept
 copy operator
 MultiDimDecorator (MultiDimDecorator< GUM_SCALAR > &&) noexcept
 Class move constructor.
MultiDimDecorator< GUM_SCALAR > & operator= (MultiDimDecorator &&from)
 assignment operator.
 ~MultiDimDecorator ()
 Class destructor.
MultiDimInterface implementation
virtual Idx nbrDim () const final
 Returns the number of vars in the multidimensional container.
virtual Size domainSize () const final
 Returns the product of the variables domain size.
virtual void add (const DiscreteVariable &v) final
 Adds a new var to the variables of the multidimensional matrix.
virtual void erase (const DiscreteVariable &var) final
 Removes a var from the variables of the multidimensional matrix.
virtual void erase (const std::string &name) final
virtual const Sequence< const DiscreteVariable * > & variablesSequence () const final
 Returns a const ref to the sequence of DiscreteVariable*.
virtual const DiscreteVariablevariable (Idx) const final
 Returns a const ref to the ith var.
virtual const DiscreteVariablevariable (const std::string &name) const final
 Returns the variable with the name.
virtual Idx pos (const DiscreteVariable &var) const final
 Returns the index of a variable.
virtual bool contains (const DiscreteVariable &var) const final
 Returns true if var is in *this.
virtual bool empty () const final
 Returns true if no var is in *this.
MultiDimAddressable implementation
virtual bool unregisterSlave (Instantiation &i) final
 Unregister i as a slave of this MultiDimAdressable.
virtual bool registerSlave (Instantiation &i) final
 Register i as a slave of this MultiDimAdressable.
virtual void changeNotification (const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval) final
 Listen to changes in a given Instantiation.
virtual void setChangeNotification (const Instantiation &i) final
 Listen to an assignment of a value in a Instantiation.
virtual void setFirstNotification (const Instantiation &i) final
 Listen to setFirst in a given Instantiation.
virtual void setLastNotification (const Instantiation &i) final
 Listen to setLast in a given Instantiation.
virtual void setIncNotification (const Instantiation &i) final
 Listen to increment in a given Instantiation.
virtual void setDecNotification (const Instantiation &i) final
 Listen to increment in each recorded Instantiation.
virtual void notifyChange () const final
MultiDimContainer implementation
virtual void set (const Instantiation &i, const GUM_SCALAR &value) const final
 Default implementation of MultiDimContainer::set().
virtual GUM_SCALAR get (const Instantiation &i) const final
 Default implementation of MultiDimContainer::get().
virtual void fill (const GUM_SCALAR &d) const final
 Default implementation of MultiDimContainer::set().
virtual void populate (const std::vector< GUM_SCALAR > &v) const final
 Automatically fills this MultiDimContainer with the values in v.
virtual void apply (std::function< GUM_SCALAR(GUM_SCALAR) > f) const final
 Apply a function on every element of the container.
virtual GUM_SCALAR reduce (std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f, GUM_SCALAR base) const final
 compute lfold for this container
virtual MultiDimDecorator< GUM_SCALAR > * newFactory () const =0
 Default implementation of MultiDimContainer::set().
virtual void beginMultipleChanges () final
 Default implementation of MultiDimContainer::set().
virtual void endMultipleChanges () final
 Default implementation of MultiDimContainer::set().
virtual void endMultipleChanges (const GUM_SCALAR &) final
 Default implementation of MultiDimContainer::set().
virtual std::string toString (const Instantiation *i) const
 Default implementation of MultiDimContainer::set().
virtual std::string toString () const
 Default implementation of MultiDimContainer::set().
Various methods.
virtual const MultiDimImplementation< GUM_SCALAR > * content () const final
 Returns the implementation for this object (may be *this).
virtual MultiDimImplementation< GUM_SCALAR > * content () final
 Returns the implementation for this object (may be *this).
Accessors / Modifiers
GUM_SCALAR operator[] (const Instantiation &i) const
 An [] operator using a Instantiation as argument.
virtual void populate (std::initializer_list< GUM_SCALAR > l) const
 Automatically fills this MultiDimContainer with the values in l.
Copy methods.
virtual void copyFrom (const MultiDimContainer< GUM_SCALAR > &src) const
 Basic copy of a MultiDimContainer.
virtual void copyFrom (const MultiDimContainer< GUM_SCALAR > &src, Instantiation *p_i) const
 Basic copy of a MultiDimContainer.
virtual void extractFrom (const MultiDimContainer< GUM_SCALAR > &src, const Instantiation &mask)
 Basic extraction of a MultiDimContainer.
virtual MultiDimAdressablegetMasterRef ()
 In order to insure the dereference for decorators, we need to virtualize the access to master pointer.
virtual const MultiDimAdressablegetMasterRef () const
 In order to insure the dereference for decorators, we need to virtualize the access to master pointer.
virtual void copy (const MultiDimContainer< GUM_SCALAR > &src)
 Removes all variables in this MultiDimContainer and copy the content of src, variables included.
Various methods.
bool operator== (const MultiDimContainer< GUM_SCALAR > &p) const
 Test if this MultiDimContainer is equal to p.
bool operator!= (const MultiDimContainer< GUM_SCALAR > &p) const
 Test if this MultiDimContainer is different of p.
Accessors / Modifiers
void replace (const DiscreteVariable &x, const DiscreteVariable &y)
 Replace variables in this multidim.

Protected Member Functions

virtual void replace_ (const DiscreteVariable *x, const DiscreteVariable *y)
 This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.
void swapContent_ (MultiDimImplementation< GUM_SCALAR > *aContent) const
 protected method to swap the implementation behind the Tensor
GUM_SCALAR & get_ (const Instantiation &i) const final
 Return a data, given a Instantiation - final method.

Protected Attributes

MultiDimImplementation< GUM_SCALAR > * content_
 The true container.
GUM_SCALAR empty_value_
 value of the MultiDimDecorator if no dimension.

Detailed Description

template<typename GUM_SCALAR>
class gum::MultiDimDecorator< GUM_SCALAR >

Decorator design pattern in order to separate implementations from multidimensional matrix concepts.

A MultiDimDecorator is a virtual class for all encapsulation of MultiDimImplementation, for example probability, utility, etc. It implements a decorator design pattern in order to have a array, tree, sparse or matrix (...) implementation of MultiDimImplementation.

Template Parameters
GUM_SCALARThe type of the scalar stored in this multidimensional matrix.

Definition at line 81 of file multiDimDecorator.h.

Constructor & Destructor Documentation

◆ MultiDimDecorator() [1/3]

template<typename GUM_SCALAR>
INLINE gum::MultiDimDecorator< GUM_SCALAR >::MultiDimDecorator ( MultiDimImplementation< GUM_SCALAR > * aContent = nullptr,
GUM_SCALAR empty_value = (GUM_SCALAR)0 )

Class constructor.

Parameters
aContentThe implementation used by this MultiDimDecorator.

Definition at line 86 of file multiDimDecorator_tpl.h.

91 }
Decorator design pattern in order to separate implementations from multidimensional matrix concepts.
GUM_SCALAR empty_value_
value of the MultiDimDecorator if no dimension.
MultiDimDecorator(MultiDimImplementation< GUM_SCALAR > *aContent=nullptr, GUM_SCALAR empty_value=(GUM_SCALAR) 0)
Class constructor.
MultiDimImplementation< GUM_SCALAR > * content_
The true container.
void _initTensorOperators__()

References MultiDimDecorator(), gum::_initTensorOperators__(), content_, and empty_value_.

Referenced by MultiDimDecorator(), MultiDimDecorator(), MultiDimDecorator(), gum::Tensor< GUM_SCALAR >::Tensor(), gum::Tensor< GUM_SCALAR >::Tensor(), gum::Tensor< GUM_SCALAR >::Tensor(), gum::Tensor< GUM_SCALAR >::Tensor(), ~MultiDimDecorator(), newFactory(), operator=(), operator=(), and gum::Tensor< GUM_SCALAR >::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MultiDimDecorator() [2/3]

template<typename GUM_SCALAR>
INLINE gum::MultiDimDecorator< GUM_SCALAR >::MultiDimDecorator ( const MultiDimDecorator< GUM_SCALAR > & from)

copy constructor & assignment

Definition at line 94 of file multiDimDecorator_tpl.h.

99 content()->copy(from.content());
100 }
MultiDimContainer()
Default constructor.
virtual const MultiDimImplementation< GUM_SCALAR > * content() const final
Returns the implementation for this object (may be *this).

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), MultiDimDecorator(), gum::_initTensorOperators__(), content(), and empty_value_.

Here is the call graph for this function:

◆ MultiDimDecorator() [3/3]

template<typename GUM_SCALAR>
INLINE gum::MultiDimDecorator< GUM_SCALAR >::MultiDimDecorator ( MultiDimDecorator< GUM_SCALAR > && from)
noexcept

Class move constructor.

Definition at line 120 of file multiDimDecorator_tpl.h.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), MultiDimDecorator(), content_, and empty_value_.

Here is the call graph for this function:

◆ ~MultiDimDecorator()

template<typename GUM_SCALAR>
INLINE gum::MultiDimDecorator< GUM_SCALAR >::~MultiDimDecorator ( )

Class destructor.

Definition at line 146 of file multiDimDecorator_tpl.h.

146 {
147 if (content_ != nullptr) { delete (content_); }
148
150 }

References MultiDimDecorator(), and content_.

Here is the call graph for this function:

Member Function Documentation

◆ add()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::add ( const DiscreteVariable & v)
finalvirtual

Adds a new var to the variables of the multidimensional matrix.

See also
operator<<(MultiDimInterface& c, const DiscreteVariable& v)
Warning
Note that the variable passed in argument is not duplicated, that is, only a pointer toward the variable is kept by the MultiDimInterface.
Parameters
vThe new var.
Exceptions
DuplicateElementRaised if the variable already belongs to the sequence of variables.
OperationNotAllowedRaised if this object is non mutable.

Implements gum::MultiDimInterface.

Definition at line 188 of file multiDimDecorator_tpl.h.

188 {
189 if (v.domainSize() < 1) {
190 GUM_ERROR(InvalidArgument, "Empty variable " << v << " cannot be added in a Tensor")
191 }
193 }
virtual void add(const DiscreteVariable &v) final
Adds a new var to the variables of the multidimensional matrix.
virtual Size domainSize() const final
Returns the product of the variables domain size.
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), add(), content_, gum::DiscreteVariable::domainSize(), and GUM_ERROR.

Referenced by gum::Tensor< GUM_SCALAR >::Tensor(), gum::Tensor< GUM_SCALAR >::Tensor(), add(), gum::Tensor< GUM_SCALAR >::evEq(), gum::Tensor< GUM_SCALAR >::evGt(), gum::Tensor< GUM_SCALAR >::evIn(), and gum::Tensor< GUM_SCALAR >::evLt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply()

template<typename GUM_SCALAR>
void gum::MultiDimDecorator< GUM_SCALAR >::apply ( std::function< GUM_SCALAR(GUM_SCALAR) > f) const
finalvirtual

Apply a function on every element of the container.

Parameters
fthe function to apply

Reimplemented from gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 338 of file multiDimDecorator_tpl.h.

338 {
339 if (static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->empty()) {
341 } else {
342 content_->apply(f);
343 }
344 }
virtual bool empty() const final
Returns true if no var is in *this.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, empty(), and empty_value_.

Referenced by gum::Tensor< GUM_SCALAR >::abs(), gum::Tensor< GUM_SCALAR >::inverse(), gum::Tensor< GUM_SCALAR >::log2(), gum::Tensor< GUM_SCALAR >::normalize(), gum::Tensor< GUM_SCALAR >::scale(), gum::Tensor< GUM_SCALAR >::sgn(), gum::Tensor< GUM_SCALAR >::sq(), and gum::Tensor< GUM_SCALAR >::translate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ beginMultipleChanges()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::beginMultipleChanges ( )
finalvirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 371 of file multiDimDecorator_tpl.h.

371 {
373 }
virtual void beginMultipleChanges() final
Default implementation of MultiDimContainer::set().

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), beginMultipleChanges(), and content_.

Referenced by gum::Tensor< GUM_SCALAR >::Tensor(), and beginMultipleChanges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeNotification()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::changeNotification ( const Instantiation & i,
const DiscreteVariable *const var,
Idx oldval,
Idx newval )
finalvirtual

Listen to changes in a given Instantiation.

Parameters
iThe Instantiation to listen.
varThe changed dim.
oldvalThe old value.
newvalThe changed value.

Implements gum::MultiDimAdressable.

Definition at line 198 of file multiDimDecorator_tpl.h.

201 {
203 var,
204 oldval,
205 newval);
206 }
virtual void changeNotification(const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval) final
Listen to changes in a given Instantiation.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), changeNotification(), and content_.

Referenced by changeNotification().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains()

template<typename GUM_SCALAR>
INLINE bool gum::MultiDimDecorator< GUM_SCALAR >::contains ( const DiscreteVariable & v) const
finalvirtual

Returns true if var is in *this.

Parameters
vA DiscreteVariable.
Returns
Returns true if var is in *this.

Implements gum::MultiDimInterface.

Definition at line 277 of file multiDimDecorator_tpl.h.

277 {
278 return static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->contains(var);
279 }
virtual bool contains(const DiscreteVariable &var) const final
Returns true if var is in *this.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), contains(), and content_.

Referenced by contains(), gum::Tensor< GUM_SCALAR >::KL(), gum::Tensor< GUM_SCALAR >::putFirst(), and gum::Tensor< GUM_SCALAR >::reorganize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content() [1/2]

◆ content() [2/2]

template<typename GUM_SCALAR>
INLINE MultiDimImplementation< GUM_SCALAR > * gum::MultiDimDecorator< GUM_SCALAR >::content ( )
finalvirtual

Returns the implementation for this object (may be *this).

Implements gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 359 of file multiDimDecorator_tpl.h.

359 {
360 return content_;
361 }

References content_.

◆ copy()

template<typename GUM_SCALAR>
void gum::MultiDimContainer< GUM_SCALAR >::copy ( const MultiDimContainer< GUM_SCALAR > & src)
virtualinherited

Removes all variables in this MultiDimContainer and copy the content of src, variables included.

Parameters
srcThe MultiDimContainer to copy.

Reimplemented in gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >, gum::MultiDimFunctionGraph< bool >, gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< double >, gum::MultiDimFunctionGraph< double, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< gum::ActionSet, gum::SetTerminalNodePolicy >, gum::MultiDimFunctionGraph< GUM_SCALAR, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< Size >, and gum::MultiDimFunctionGraph< Size, ExactTerminalNodePolicy >.

Definition at line 288 of file multiDimContainer_tpl.h.

288 {
289 this->beginMultipleChanges();
290
291 Size nbr = this->nbrDim();
292
293 for (Idx i = 0; i < nbr; i++) {
294 this->erase(this->variable(0));
295 }
296
297 for (Idx i = 0; i < src.nbrDim(); i++) {
298 this->add(src.variable(i));
299 }
300
301 this->endMultipleChanges();
302 this->copyFrom(src);
303 }
Abstract base class for all multi dimensionnal containers.
virtual void beginMultipleChanges()=0
Call this method before doing important changes in this MultiDimContainer.
virtual void endMultipleChanges()=0
Call this method after doing important changes in this MultiDimContainer.
virtual void copyFrom(const MultiDimContainer< GUM_SCALAR > &src) const
Basic copy of a MultiDimContainer.
virtual void add(const DiscreteVariable &v)=0
Adds a new var to the variables of the multidimensional matrix.
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 void erase(const DiscreteVariable &v)=0
Removes a var from the variables of the multidimensional matrix.

References MultiDimContainer(), beginMultipleChanges(), gum::MultiDimInterface::erase(), gum::MultiDimInterface::nbrDim(), and gum::MultiDimInterface::variable().

Referenced by gum::TreeRegress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::compute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyFrom() [1/2]

template<typename GUM_SCALAR>
void gum::MultiDimContainer< GUM_SCALAR >::copyFrom ( const MultiDimContainer< GUM_SCALAR > & src) const
virtualinherited

Basic copy of a MultiDimContainer.

This method is virtual because it should be optimized in certain MultiDimContainer.

Parameters
srcThe MultiDimContainer src which values are copied. This is a full copy with no verification of dimensions.
Exceptions
OperationNotAllowedRaised if src does not have the same domain size than this MultiDimContainer.

Reimplemented in gum::aggregator::MultiDimAggregator< GUM_SCALAR >, gum::MultiDimArray< GUM_SCALAR >, and gum::MultiDimICIModel< GUM_SCALAR >.

Definition at line 271 of file multiDimContainer_tpl.h.

271 {
272 if (src.domainSize() != domainSize()) {
274 "Domain sizes do not fit : " << src.domainSize() << "!=" << domainSize());
275 }
276
277 Instantiation i_dest(*this);
279
280 for (i_dest.setFirst(), i_src.setFirst(); !i_dest.end(); ++i_dest, ++i_src) {
281 set(i_dest, src[i_src]);
282 }
283 }
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const
Changes the value pointed by i.
virtual Size domainSize() const =0
Returns the product of the variables domain size.

References MultiDimContainer(), gum::MultiDimInterface::domainSize(), and GUM_ERROR.

Referenced by gum::aggregator::MultiDimAggregator< GUM_SCALAR >::copyFrom(), gum::MultiDimArray< GUM_SCALAR >::copyFrom(), and gum::MultiDimICIModel< GUM_SCALAR >::copyFrom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyFrom() [2/2]

template<typename GUM_SCALAR>
void gum::MultiDimContainer< GUM_SCALAR >::copyFrom ( const MultiDimContainer< GUM_SCALAR > & src,
Instantiation * p_i ) const
virtualinherited

Basic copy of a MultiDimContainer.

This method is virtual because it should be optimized in certain MultiDimContainer.

Parameters
srcThe MultiDimContainer src which values are copied.
p_iGive the order to iterate in this MultiDimContainer during the copy (nullptr will correctly copy if this is a reorganization of src).
Exceptions
OperationNotAllowedRaised if src does not have the same domain size than this MultiDimContainer.

Reimplemented in gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >, and gum::MultiDimFunctionGraph< GUM_SCALAR, ExactTerminalNodePolicy >.

Definition at line 225 of file multiDimContainer_tpl.h.

226 {
227 if (src.domainSize() != domainSize()) {
229 "Domain sizes do not fit : " << src.domainSize() << "!=" << domainSize());
230 }
231
232 if (p_i == nullptr) { // if null, we just follow the same order
234 for (i.setFirst(); !i.end(); ++i) {
235 set(i, src[i]);
236 }
237 } else {
238 Instantiation i_dest(*this);
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]);
242 }
243 }
244 }

References MultiDimContainer(), gum::MultiDimInterface::domainSize(), and GUM_ERROR.

Here is the call graph for this function:

◆ domainSize()

template<typename GUM_SCALAR>
INLINE Size gum::MultiDimDecorator< GUM_SCALAR >::domainSize ( ) const
finalvirtual

Returns the product of the variables domain size.

Returns
Returns the product of the variables domain size.

Implements gum::MultiDimInterface.

Definition at line 181 of file multiDimDecorator_tpl.h.

181 {
182 return static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->domainSize();
183 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and domainSize().

Referenced by domainSize(), gum::SimpleUTGenerator::generateUT(), gum::SimpleUTGenerator::generateUT(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), gum::Tensor< GUM_SCALAR >::random(), gum::Tensor< GUM_SCALAR >::randomCPT(), and gum::Tensor< GUM_SCALAR >::randomDistribution().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

template<typename GUM_SCALAR>
INLINE bool gum::MultiDimDecorator< GUM_SCALAR >::empty ( ) const
finalvirtual

Returns true if no var is in *this.

Returns
Returns true if no var is in *this.

Implements gum::MultiDimInterface.

Definition at line 282 of file multiDimDecorator_tpl.h.

282 {
283 if (content_ == nullptr) return true;
284 return static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->empty();
285 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and empty().

Referenced by apply(), empty(), gum::Tensor< GUM_SCALAR >::expectedValue(), fill(), get(), gum::Tensor< GUM_SCALAR >::max(), gum::Tensor< GUM_SCALAR >::maxIn(), gum::Tensor< GUM_SCALAR >::maxNonOne(), gum::Tensor< GUM_SCALAR >::maxOut(), gum::Tensor< GUM_SCALAR >::min(), gum::Tensor< GUM_SCALAR >::minIn(), gum::Tensor< GUM_SCALAR >::minNonZero(), gum::Tensor< GUM_SCALAR >::minOut(), gum::Tensor< GUM_SCALAR >::normalize(), gum::Tensor< GUM_SCALAR >::normalizeAsCPT(), gum::Tensor< GUM_SCALAR >::operator*(), gum::Tensor< GUM_SCALAR >::operator+(), gum::Tensor< GUM_SCALAR >::operator-(), gum::Tensor< GUM_SCALAR >::operator/(), gum::Tensor< GUM_SCALAR >::operator==(), populate(), gum::Tensor< GUM_SCALAR >::prodIn(), gum::Tensor< GUM_SCALAR >::prodOut(), gum::Tensor< GUM_SCALAR >::product(), reduce(), gum::Tensor< GUM_SCALAR >::sum(), gum::Tensor< GUM_SCALAR >::sumIn(), gum::Tensor< GUM_SCALAR >::sumOut(), and toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endMultipleChanges() [1/2]

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::endMultipleChanges ( )
finalvirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 376 of file multiDimDecorator_tpl.h.

376 {
378 }
virtual void endMultipleChanges() final
Default implementation of MultiDimContainer::set().

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and endMultipleChanges().

Referenced by gum::Tensor< GUM_SCALAR >::Tensor(), endMultipleChanges(), endMultipleChanges(), and newFactory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endMultipleChanges() [2/2]

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::endMultipleChanges ( const GUM_SCALAR & x)
finalvirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 381 of file multiDimDecorator_tpl.h.

381 {
383 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and endMultipleChanges().

Here is the call graph for this function:

◆ erase() [1/2]

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::erase ( const DiscreteVariable & v)
finalvirtual

Removes a var from the variables of the multidimensional matrix.

See also
operator>>(MultiDimInterface& c, const DiscreteVariable& v)
Exceptions
OperationNotAllowedRaised if this object is non mutable.
NotFoundRaised if v does not belong to this.

Implements gum::MultiDimInterface.

Definition at line 251 of file multiDimDecorator_tpl.h.

251 {
253 }
virtual void erase(const DiscreteVariable &var) final
Removes a var from the variables of the multidimensional matrix.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and erase().

Referenced by erase(), and erase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase() [2/2]

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::erase ( const std::string & name)
finalvirtual

Definition at line 256 of file multiDimDecorator_tpl.h.

256 {
258 }
virtual const DiscreteVariable & variable(Idx) const final
Returns a const ref to the ith var.

References erase(), and variable().

Here is the call graph for this function:

◆ extractFrom()

template<typename GUM_SCALAR>
void gum::MultiDimContainer< GUM_SCALAR >::extractFrom ( const MultiDimContainer< GUM_SCALAR > & src,
const Instantiation & mask )
virtualinherited

Basic extraction of a MultiDimContainer.

This method is virtual because it should be optimized in certain MultiDimContainer.

Parameters
srcThe MultiDimContainer src which datas are copied.
maskpartial instantiation of variables of the Tensor : the

extraction will concern every variable not in the instantiation and the copy of data will use the (relevant) values in this instantiation.

Definition at line 247 of file multiDimContainer_tpl.h.

248 {
249 this->beginMultipleChanges();
250
251 Size nbr = this->nbrDim();
252 for (Idx i = 0; i < nbr; i++) {
253 this->erase(this->variable(0));
254 }
255
256 for (Idx i = 0; i < src.nbrDim(); i++) {
257 if (!imask.contains(src.variable(i))) this->add(src.variable(i));
258 }
259
260 this->endMultipleChanges();
261
262 if (this->nbrDim() == 0) { GUM_ERROR(FatalError, "Empty tensor") }
263
265 inst.setVals(imask);
266 for (inst.setFirstOut(imask); !inst.end(); inst.incOut(imask))
267 set(inst, src[inst]);
268 }
virtual bool contains(const DiscreteVariable &v) const =0
Returns true if var is in *this.

References MultiDimContainer(), and beginMultipleChanges().

Here is the call graph for this function:

◆ fill()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::fill ( const GUM_SCALAR & d) const
finalvirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 293 of file multiDimDecorator_tpl.h.

293 {
294 if (static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->empty()) {
295 empty_value_ = d;
296 } else {
298 }
299 }
virtual void fill(const GUM_SCALAR &d) const final
Default implementation of MultiDimContainer::set().

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, empty(), empty_value_, and fill().

Referenced by fill(), and gum::Tensor< GUM_SCALAR >::fillWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

template<typename GUM_SCALAR>
INLINE GUM_SCALAR gum::MultiDimDecorator< GUM_SCALAR >::get ( const Instantiation & i) const
finalvirtual

Default implementation of MultiDimContainer::get().

Calls get_ as a l-value.

Reimplemented from gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 160 of file multiDimDecorator_tpl.h.

160 {
161 if (static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->empty()) {
162 return empty_value_;
163 } else {
164 return static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->get(i);
165 }
166 }
virtual GUM_SCALAR get(const Instantiation &i) const final
Default implementation of MultiDimContainer::get().

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, empty(), empty_value_, and get().

Referenced by gum::Tensor< GUM_SCALAR >::draw(), gum::Tensor< GUM_SCALAR >::entropy(), gum::Tensor< GUM_SCALAR >::expectedValue(), gum::Tensor< GUM_SCALAR >::findAll(), get(), gum::Tensor< GUM_SCALAR >::KL(), gum::Tensor< GUM_SCALAR >::normalizeAsCPT(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), gum::prm::o3prmr::O3prmrInterpreter::query(), and gum::Tensor< GUM_SCALAR >::toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_()

template<typename GUM_SCALAR>
INLINE GUM_SCALAR & gum::MultiDimDecorator< GUM_SCALAR >::get_ ( const Instantiation & i) const
finalprotectedvirtual

Return a data, given a Instantiation - final method.

Parameters
iThe instantiation.
Exceptions
NullElement
NotFound

Implements gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 155 of file multiDimDecorator_tpl.h.

155 {
156 GUM_ERROR(OperationNotAllowed, "_get in the implementation !")
157 }

References GUM_ERROR.

◆ getMasterRef() [1/2]

template<typename GUM_SCALAR>
INLINE MultiDimAdressable & gum::MultiDimContainer< GUM_SCALAR >::getMasterRef ( )
virtualinherited

In order to insure the dereference for decorators, we need to virtualize the access to master pointer.

Returns
Returns the ref to content as MultiDimAdressable&

Implements gum::MultiDimAdressable.

Reimplemented in gum::MultiDimBucket< GUM_SCALAR >.

Definition at line 306 of file multiDimContainer_tpl.h.

306 {
307 return static_cast< MultiDimAdressable& >(*content());
308 }
MultiDimAdressable()
Default constructor.
virtual const MultiDimImplementation< GUM_SCALAR > * content() const =0
Returns the implementation for this object (may be *this).

References gum::MultiDimAdressable::MultiDimAdressable(), and content().

Here is the call graph for this function:

◆ getMasterRef() [2/2]

template<typename GUM_SCALAR>
INLINE const MultiDimAdressable & gum::MultiDimContainer< GUM_SCALAR >::getMasterRef ( ) const
virtualinherited

In order to insure the dereference for decorators, we need to virtualize the access to master pointer.

Returns
Returns the master of this MultiDimAdressable.

Implements gum::MultiDimAdressable.

Reimplemented in gum::MultiDimBucket< GUM_SCALAR >.

Definition at line 311 of file multiDimContainer_tpl.h.

311 {
312 return static_cast< const MultiDimAdressable& >(*content());
313 }

References gum::MultiDimAdressable::MultiDimAdressable(), and content().

Here is the call graph for this function:

◆ nbrDim()

template<typename GUM_SCALAR>
INLINE Idx gum::MultiDimDecorator< GUM_SCALAR >::nbrDim ( ) const
finalvirtual

Returns the number of vars in the multidimensional container.

Returns
Returns the number of vars in the multidimensional container.

Implements gum::MultiDimInterface.

Definition at line 320 of file multiDimDecorator_tpl.h.

320 {
321 return static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->nbrDim();
322 }
virtual Idx nbrDim() const final
Returns the number of vars in the multidimensional container.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and nbrDim().

Referenced by gum::GibbsOperator< GUM_SCALAR >::_GibbsSample_(), gum::Tensor< GUM_SCALAR >::draw(), gum::Tensor< GUM_SCALAR >::fillWith(), gum::Tensor< GUM_SCALAR >::isEvidence(), gum::Tensor< GUM_SCALAR >::KL(), nbrDim(), gum::Tensor< GUM_SCALAR >::normalizeAsCPT(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), gum::Tensor< GUM_SCALAR >::putFirst(), gum::Tensor< GUM_SCALAR >::putFirst(), gum::Tensor< GUM_SCALAR >::reorganize(), and set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newFactory()

template<typename GUM_SCALAR>
virtual MultiDimDecorator< GUM_SCALAR > * gum::MultiDimDecorator< GUM_SCALAR >::newFactory ( ) const
pure virtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_SCALAR >.

Implemented in gum::Tensor< GUM_SCALAR >.

References MultiDimDecorator(), content(), endMultipleChanges(), replace_(), swapContent_(), and toString().

Referenced by operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyChange()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::notifyChange ( ) const
finalvirtual

Definition at line 304 of file multiDimDecorator_tpl.h.

304 {
305 /*( (MultiDimContainer<GUM_SCALAR> *) content_)->notifyChange();*/
306 GUM_ERROR(OperationNotAllowed, "Not implemented yet")
307 }

References GUM_ERROR.

◆ operator!=()

template<typename GUM_SCALAR>
INLINE bool gum::MultiDimContainer< GUM_SCALAR >::operator!= ( const MultiDimContainer< GUM_SCALAR > & p) const
inherited

Test if this MultiDimContainer is different of p.

Parameters
pThe MultiDimContainer to test for inequality.
Returns
Returns true if this MultiDimContainer is different of p.

Definition at line 171 of file multiDimContainer_tpl.h.

171 {
172 return !operator==(p);
173 }
bool operator==(const MultiDimContainer< GUM_SCALAR > &p) const
Test if this MultiDimContainer is equal to p.

References MultiDimContainer().

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename GUM_SCALAR>
INLINE MultiDimDecorator< GUM_SCALAR > & gum::MultiDimDecorator< GUM_SCALAR >::operator= ( const MultiDimDecorator< GUM_SCALAR > & from)
noexcept

copy operator

Definition at line 131 of file multiDimDecorator_tpl.h.

132 {
137 if (content_ == nullptr)
140 return *this;
141 }
MultiDimContainer & operator=(const MultiDimContainer< GUM_SCALAR > &src)
Default constructor.
virtual MultiDimDecorator< GUM_SCALAR > * newFactory() const =0
Default implementation of MultiDimContainer::set().

References MultiDimDecorator(), gum::_initTensorOperators__(), content(), content_, empty_value_, newFactory(), and gum::MultiDimContainer< GUM_SCALAR >::operator=().

Referenced by gum::Tensor< GUM_SCALAR >::operator=(), and gum::Tensor< GUM_SCALAR >::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [2/2]

template<typename GUM_SCALAR>
INLINE MultiDimDecorator< GUM_SCALAR > & gum::MultiDimDecorator< GUM_SCALAR >::operator= ( MultiDimDecorator< GUM_SCALAR > && from)

assignment operator.

Definition at line 104 of file multiDimDecorator_tpl.h.

104 {
108
109 if (this != &from) {
110 if (content_ != nullptr) delete (content_); // should be the case
113 from.content_ = nullptr;
114 }
115
116 return *this;
117 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), MultiDimDecorator(), content_, empty_value_, and gum::MultiDimContainer< GUM_SCALAR >::operator=().

Here is the call graph for this function:

◆ operator==()

template<typename GUM_SCALAR>
bool gum::MultiDimContainer< GUM_SCALAR >::operator== ( const MultiDimContainer< GUM_SCALAR > & p) const
inherited

Test if this MultiDimContainer is equal to p.

Parameters
pThe MultiDimContainer to test for equality.
Returns
Returns true if this MultiDimContainer is equal to p.

Definition at line 146 of file multiDimContainer_tpl.h.

146 {
147 if ((nbrDim() == p.nbrDim()) && (domainSize() == p.domainSize())) {
148 if (nbrDim() == 0) return true;
149
150 for (auto iter = variablesSequence().beginSafe(); iter != variablesSequence().endSafe();
151 ++iter) {
152 if (!p.variablesSequence().exists(*iter)) { return false; }
153 }
154 } else {
155 return false;
156 }
157
158 Instantiation i(*this);
160 for (i.setFirst(); !i.end(); ++i) {
161 if (cmp(get(i), p.get(i))) { return false; }
162 }
163
164 return true;
165 }
virtual GUM_SCALAR get(const Instantiation &i) const
Returns the value pointed by i.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.

References MultiDimContainer(), gum::MultiDimInterface::domainSize(), gum::MultiDimInterface::nbrDim(), and gum::MultiDimInterface::variablesSequence().

Here is the call graph for this function:

◆ operator[]()

template<typename GUM_SCALAR>
INLINE GUM_SCALAR gum::MultiDimContainer< GUM_SCALAR >::operator[] ( const Instantiation & i) const
inherited

An [] operator using a Instantiation as argument.

Warning
If i variables set is disjoint with this MultiDimContainer then 0 is assumed for dimensions (i.e. variables) not prensent in the instantiation.
Parameters
iAn Instantiation.
Returns
Returns the adressed (GUM_SCALAR) value.

Definition at line 101 of file multiDimContainer_tpl.h.

101 {
102 return get(i);
103 }

References get().

Here is the call graph for this function:

◆ populate() [1/2]

template<typename GUM_SCALAR>
void gum::MultiDimContainer< GUM_SCALAR >::populate ( std::initializer_list< GUM_SCALAR > l) const
virtualinherited

Automatically fills this MultiDimContainer with the values in l.

The order used to fill this MultiDimContainer is the same as with an instantiation over it.

Size cpt = 0;
Instantiation i( *this );
for (i.setFirst(); !i.end(); ++i, ++cpt) {
set(i, v[cpt]);
}
Class for assigning/browsing values to tuples of discrete variables.
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const final
Default implementation of MultiDimContainer::set().
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Parameters
lcontains the data.
Exceptions
SizeErrorRaised if l size's does not matches this MultiDimContainer domain size.

Reimplemented in gum::MultiDimBijArray< GUM_SCALAR >, and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >.

Definition at line 191 of file multiDimContainer_tpl.h.

191 {
192 if (domainSize() != l.size()) {
193 GUM_ERROR(SizeError, "Sizes do not match : " << domainSize() << "!=" << l.size())
194 }
195
196 Instantiation i(*this);
197 // insert all the elements
198 for (const auto& elt: l) {
199 set(i, elt);
200 ++i;
201 }
202 }

References gum::MultiDimInterface::domainSize(), GUM_ERROR, and set().

Here is the call graph for this function:

◆ populate() [2/2]

template<typename GUM_SCALAR>
void gum::MultiDimDecorator< GUM_SCALAR >::populate ( const std::vector< GUM_SCALAR > & v) const
finalvirtual

Automatically fills this MultiDimContainer with the values in v.

The order used to fill this MultiDimContainer is the same as with an instantiation over it.

Size cpt = 0;
Instantiation i( *this );
for (i.setFirst(); !i.end(); ++i, ++cpt) {
set(i, v[cpt]);
}
Parameters
vVector of values.
Exceptions
SizeErrorRaised if v size's does not matches this MultiDimContainer domain size.

Reimplemented from gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 325 of file multiDimDecorator_tpl.h.

325 {
326 if (static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->empty()) {
327 if (v.size() == 1) {
328 empty_value_ = v[0];
329 } else {
330 GUM_ERROR(SizeError, "Size do not match in populate")
331 }
332 } else {
333 content_->populate(v);
334 }
335 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, empty(), empty_value_, and GUM_ERROR.

Referenced by gum::Tensor< GUM_SCALAR >::fillWith(), gum::SimpleUTGenerator::generateUT(), and gum::SimpleUTGenerator::generateUT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pos()

template<typename GUM_SCALAR>
INLINE Idx gum::MultiDimDecorator< GUM_SCALAR >::pos ( const DiscreteVariable & v) const
finalvirtual

Returns the index of a variable.

Parameters
vThe variable for which the index is returned.
Returns
Returns the index of a variable.
Exceptions
NotFoundRaised if v is not in this multidimensional matrix.

Implements gum::MultiDimInterface.

Definition at line 272 of file multiDimDecorator_tpl.h.

272 {
273 return static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->pos(var);
274 }
virtual Idx pos(const DiscreteVariable &var) const final
Returns the index of a variable.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and pos().

Referenced by pos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reduce()

template<typename GUM_SCALAR>
GUM_SCALAR gum::MultiDimDecorator< GUM_SCALAR >::reduce ( std::function< GUM_SCALAR(GUM_SCALAR, GUM_SCALAR) > f,
GUM_SCALAR base ) const
finalvirtual

compute lfold for this container

Parameters
fthe function to apply
basethe initial value

Reimplemented from gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 348 of file multiDimDecorator_tpl.h.

349 {
350 if (static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->empty()) {
351 return base;
352 } else {
353 return content_->reduce(f, base);
354 }
355 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and empty().

Referenced by gum::Tensor< GUM_SCALAR >::maxNonOne(), and gum::Tensor< GUM_SCALAR >::minNonZero().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerSlave()

template<typename GUM_SCALAR>
INLINE bool gum::MultiDimDecorator< GUM_SCALAR >::registerSlave ( Instantiation & i)
finalvirtual

Register i as a slave of this MultiDimAdressable.

Parameters
iThe Instantiation to enslave.
Returns
Returns true if i becomes a slave of this MultiDimAdressable.

Implements gum::MultiDimAdressable.

Definition at line 246 of file multiDimDecorator_tpl.h.

246 {
248 }
virtual bool registerSlave(Instantiation &i) final
Register i as a slave of this MultiDimAdressable.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and registerSlave().

Referenced by registerSlave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace()

INLINE void gum::MultiDimInterface::replace ( const DiscreteVariable & x,
const DiscreteVariable & y )
inherited

Replace variables in this multidim.

If x is in this MultiDim and y has the same domain size, then x will be replace by y in this MultiDim.

Parameters
xThe variable in this which will be replaced.
yThe variable replacing y.
Exceptions
NotFoundRaised if x does not belong to this MultiDim.
OperationNotAllowedIf y and x are not interchangeable.
DuplicateElementIf y is already in this MultiDim.

Definition at line 56 of file multiDimInterface_inl.h.

56 {
57 if (!contains(x)) { GUM_ERROR(NotFound, "could not find the variable") }
58
59 if (contains(y)) { GUM_ERROR(DuplicateElement, "variable " << y << " already in MultiDim") }
60
61 if (x.domainSize() != y.domainSize()) {
62 GUM_ERROR(OperationNotAllowed, "incompatible variables")
63 }
64
65 replace_(&x, &y);
66 }
virtual void replace_(const DiscreteVariable *x, const DiscreteVariable *y)=0
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.

References contains(), gum::DiscreteVariable::domainSize(), GUM_ERROR, and replace_().

Here is the call graph for this function:

◆ replace_()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::replace_ ( const DiscreteVariable * x,
const DiscreteVariable * y )
protectedvirtual

This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.

This is called only when everything have been checked.

Parameters
xThe variable to replace in
yThe second variable to swap.

Implements gum::MultiDimInterface.

Definition at line 405 of file multiDimDecorator_tpl.h.

406 {
407 this->content()->replace(*x, *y);
408 }

References content().

Referenced by newFactory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::set ( const Instantiation & i,
const GUM_SCALAR & value ) const
finalvirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Reimplemented from gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 169 of file multiDimDecorator_tpl.h.

170 {
171 if (static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->nbrDim() == 0) {
173 } else {
175 }
176 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, empty_value_, nbrDim(), and set().

Referenced by gum::Tensor< GUM_SCALAR >::evEq(), gum::Tensor< GUM_SCALAR >::evGt(), gum::Tensor< GUM_SCALAR >::evIn(), gum::Tensor< GUM_SCALAR >::evLt(), gum::Tensor< GUM_SCALAR >::fillWith(), gum::Tensor< GUM_SCALAR >::fillWith(), gum::Tensor< GUM_SCALAR >::normalizeAsCPT(), gum::Tensor< GUM_SCALAR >::randomCPT(), and set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setChangeNotification()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::setChangeNotification ( const Instantiation & i)
finalvirtual

Listen to an assignment of a value in a Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 211 of file multiDimDecorator_tpl.h.

211 {
213 }
virtual void setChangeNotification(const Instantiation &i) final
Listen to an assignment of a value in a Instantiation.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setChangeNotification().

Referenced by setChangeNotification().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDecNotification()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::setDecNotification ( const Instantiation & i)
finalvirtual

Listen to increment in each recorded Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 239 of file multiDimDecorator_tpl.h.

239 {
241 }
virtual void setDecNotification(const Instantiation &i) final
Listen to increment in each recorded Instantiation.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setDecNotification().

Referenced by setDecNotification().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFirstNotification()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::setFirstNotification ( const Instantiation & i)
finalvirtual

Listen to setFirst in a given Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 218 of file multiDimDecorator_tpl.h.

218 {
220 }
virtual void setFirstNotification(const Instantiation &i) final
Listen to setFirst in a given Instantiation.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setFirstNotification().

Referenced by setFirstNotification().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setIncNotification()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::setIncNotification ( const Instantiation & i)
finalvirtual

Listen to increment in a given Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 232 of file multiDimDecorator_tpl.h.

232 {
234 }
virtual void setIncNotification(const Instantiation &i) final
Listen to increment in a given Instantiation.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setIncNotification().

Referenced by setIncNotification().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLastNotification()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::setLastNotification ( const Instantiation & i)
finalvirtual

Listen to setLast in a given Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 225 of file multiDimDecorator_tpl.h.

225 {
227 }
virtual void setLastNotification(const Instantiation &i) final
Listen to setLast in a given Instantiation.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setLastNotification().

Referenced by setLastNotification().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swapContent_()

template<typename GUM_SCALAR>
INLINE void gum::MultiDimDecorator< GUM_SCALAR >::swapContent_ ( MultiDimImplementation< GUM_SCALAR > * aContent) const
protected

protected method to swap the implementation behind the Tensor

Warning
unsafe method for slave Instantiations !

Definition at line 386 of file multiDimDecorator_tpl.h.

387 {
388 if (aContent != nullptr) {
389 // TODO : frees all slave instantiations
390 // TODO : control the dimensions ?
393 // registers all instantiations
394 delete (tmp);
395 }
396 }

References content_.

Referenced by newFactory().

Here is the caller graph for this function:

◆ toString() [1/2]

template<typename GUM_SCALAR>
INLINE std::string gum::MultiDimDecorator< GUM_SCALAR >::toString ( ) const
virtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Reimplemented from gum::MultiDimContainer< GUM_SCALAR >.

Reimplemented in gum::Tensor< GUM_SCALAR >.

Definition at line 411 of file multiDimDecorator_tpl.h.

411 {
412 if (static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->empty()) {
414 ss << "<> :: " << empty_value_;
415 return ss.str();
416 } else {
417 return content_->toString();
418 }
419 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, empty(), and empty_value_.

Here is the call graph for this function:

◆ toString() [2/2]

template<typename GUM_SCALAR>
INLINE std::string gum::MultiDimDecorator< GUM_SCALAR >::toString ( const Instantiation * i) const
virtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_SCALAR >.

Definition at line 400 of file multiDimDecorator_tpl.h.

400 {
401 return content_->toString(i);
402 }

References content_.

Referenced by newFactory().

Here is the caller graph for this function:

◆ unregisterSlave()

template<typename GUM_SCALAR>
INLINE bool gum::MultiDimDecorator< GUM_SCALAR >::unregisterSlave ( Instantiation & i)
finalvirtual

Unregister i as a slave of this MultiDimAdressable.

Parameters
iThe Instantiation to free.
Returns
Returns true, whatever happens.

Implements gum::MultiDimAdressable.

Definition at line 288 of file multiDimDecorator_tpl.h.

288 {
290 }
virtual bool unregisterSlave(Instantiation &i) final
Unregister i as a slave of this MultiDimAdressable.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and unregisterSlave().

Referenced by unregisterSlave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ variable() [1/2]

template<typename GUM_SCALAR>
INLINE const DiscreteVariable & gum::MultiDimDecorator< GUM_SCALAR >::variable ( const std::string & name) const
finalvirtual

Returns the variable with the name.

Parameters
nameThe index of the variable
Returns
Returns the variable qith the name in the tuple. @warging This function is not O(1)
Exceptions
NotFoundRaised if the element cannot be found.

Implements gum::MultiDimInterface.

Definition at line 267 of file multiDimDecorator_tpl.h.

267 {
268 return static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->variable(name);
269 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and variable().

Here is the call graph for this function:

◆ variable() [2/2]

template<typename GUM_SCALAR>
INLINE const DiscreteVariable & gum::MultiDimDecorator< GUM_SCALAR >::variable ( Idx i) const
finalvirtual

Returns a const ref to the ith var.

param i An index of this multidimensional matrix.

Returns
Returns a const ref to the ith var.
Exceptions
NotFoundRaised if i does not reference a variable in this multidimensional matrix.

Implements gum::MultiDimInterface.

Definition at line 261 of file multiDimDecorator_tpl.h.

261 {
262 return static_cast< MultiDimContainer< GUM_SCALAR >* >(content_)->variable(i);
263 }

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and variable().

Referenced by gum::Tensor< GUM_SCALAR >::draw(), erase(), gum::Tensor< GUM_SCALAR >::fillWith(), gum::Tensor< GUM_SCALAR >::normalizeAsCPT(), gum::Tensor< GUM_SCALAR >::operator&(), gum::Tensor< GUM_SCALAR >::operator|(), gum::Tensor< GUM_SCALAR >::putFirst(), gum::Tensor< GUM_SCALAR >::putFirst(), gum::Tensor< GUM_SCALAR >::randomCPT(), variable(), and variable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ variablesSequence()

template<typename GUM_SCALAR>
INLINE const Sequence< const DiscreteVariable * > & gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence ( ) const
finalvirtual

Returns a const ref to the sequence of DiscreteVariable*.

Returns
Returns a const ref to the sequence of DiscreteVariable*.

Implements gum::MultiDimInterface.

Definition at line 313 of file multiDimDecorator_tpl.h.

313 {
315 }
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const final
Returns a const ref to the sequence of DiscreteVariable*.

References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and variablesSequence().

Referenced by gum::Tensor< GUM_SCALAR >::complementVars_(), gum::learning::DAG2BNLearner::createBNwithEM(), gum::Tensor< GUM_SCALAR >::fillWith(), gum::Tensor< GUM_SCALAR >::KL(), gum::Tensor< GUM_SCALAR >::maxOut(), gum::Tensor< GUM_SCALAR >::minOut(), gum::Tensor< GUM_SCALAR >::prodOut(), gum::Tensor< GUM_SCALAR >::sumOut(), and variablesSequence().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ content_

◆ empty_value_


The documentation for this class was generated from the following files: