aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
gum::MultiDimDecorator< GUM_ELEMENT > 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_ELEMENT >:
Collaboration diagram for gum::MultiDimDecorator< GUM_ELEMENT >:

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

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

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 an array, tree, sparse or matrix (...) implementation of MultiDimImplementation.

Template Parameters
GUM_ELEMENTThe 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_ELEMENT>
gum::MultiDimDecorator< GUM_ELEMENT >::MultiDimDecorator ( MultiDimImplementation< GUM_ELEMENT > * aContent = nullptr,
GUM_ELEMENT empty_value = (GUM_ELEMENT)0 )

Class constructor.

Parameters
aContentThe implementation used by this MultiDimDecorator.

Definition at line 87 of file multiDimDecorator_tpl.h.

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

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

Referenced by MultiDimDecorator(), MultiDimDecorator(), MultiDimDecorator(), newFactory(), and operator=().

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

◆ MultiDimDecorator() [2/3]

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

copy constructor & assignment

Definition at line 95 of file multiDimDecorator_tpl.h.

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

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

Here is the call graph for this function:

◆ MultiDimDecorator() [3/3]

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

Class move constructor.

Definition at line 121 of file multiDimDecorator_tpl.h.

References gum::MultiDimContainer< GUM_ELEMENT >::MultiDimContainer(), and MultiDimDecorator().

Here is the call graph for this function:

◆ ~MultiDimDecorator()

template<typename GUM_ELEMENT>
gum::MultiDimDecorator< GUM_ELEMENT >::~MultiDimDecorator ( )
override

Class destructor.

Definition at line 148 of file multiDimDecorator_tpl.h.

148 {
149 if (content_ != nullptr) { delete (content_); }
150
152 }

References content_.

Member Function Documentation

◆ add()

template<typename GUM_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::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 190 of file multiDimDecorator_tpl.h.

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

References gum::DiscreteVariable::domainSize().

Referenced by 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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::apply ( std::function< GUM_ELEMENT(GUM_ELEMENT) > f) const
finalvirtual

Apply a function on every element of the container.

Parameters
fthe function to apply

Reimplemented from gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 339 of file multiDimDecorator_tpl.h.

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

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

Here is the call graph for this function:

◆ beginMultipleChanges()

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

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 371 of file multiDimDecorator_tpl.h.

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

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

Referenced by beginMultipleChanges().

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

◆ changeNotification()

template<typename GUM_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::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 200 of file multiDimDecorator_tpl.h.

203 {
205 var,
206 oldval,
207 newval);
208 }
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_ELEMENT >::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_ELEMENT>
bool gum::MultiDimDecorator< GUM_ELEMENT >::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 278 of file multiDimDecorator_tpl.h.

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

◆ content() [1/2]

template<typename GUM_ELEMENT>
const MultiDimImplementation< GUM_ELEMENT > * gum::MultiDimDecorator< GUM_ELEMENT >::content ( ) const
finalvirtual

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

Implements gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 366 of file multiDimDecorator_tpl.h.

366 {
367 return content_;
368 }

References content_.

Referenced by MultiDimDecorator(), newFactory(), and replace_().

Here is the caller graph for this function:

◆ content() [2/2]

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

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

Implements gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 360 of file multiDimDecorator_tpl.h.

360 {
361 return content_;
362 }

References content_.

◆ copy()

template<typename GUM_ELEMENT>
void gum::MultiDimContainer< GUM_ELEMENT >::copy ( const MultiDimContainer< GUM_ELEMENT > & 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_ELEMENT, TerminalNodePolicy >, gum::MultiDimFunctionGraph< bool >, gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< double >, gum::MultiDimFunctionGraph< double, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< gum::ActionSet, gum::SetTerminalNodePolicy >, gum::MultiDimFunctionGraph< GUM_ELEMENT, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< Size >, and gum::MultiDimFunctionGraph< Size, ExactTerminalNodePolicy >.

Definition at line 284 of file multiDimContainer_tpl.h.

284 {
285 this->beginMultipleChanges();
286
287 Size nbr = this->nbrDim();
288
289 for (Idx i = 0; i < nbr; i++) {
290 this->erase(this->variable(0));
291 }
292
293 for (Idx i = 0; i < src.nbrDim(); i++) {
294 this->add(src.variable(i));
295 }
296
297 this->endMultipleChanges();
298 this->copyFrom(src);
299 }
Abstract base class for all multi dimensionnal containers.
virtual void beginMultipleChanges()=0
Call this method before doing important changes in this MultiDimContainer.
virtual void copyFrom(const MultiDimContainer< GUM_ELEMENT > &src) const
Basic copy of a MultiDimContainer.
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.
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(), gum::MultiDimInterface::add(), beginMultipleChanges(), endMultipleChanges(), gum::MultiDimInterface::erase(), gum::MultiDimInterface::nbrDim(), and gum::MultiDimInterface::variable().

Referenced by gum::TreeRegress< GUM_ELEMENT, 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_ELEMENT>
void gum::MultiDimContainer< GUM_ELEMENT >::copyFrom ( const MultiDimContainer< GUM_ELEMENT > & 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_ELEMENT >, gum::aggregator::MultiDimAggregator< GUM_SCALAR >, gum::MultiDimArray< GUM_ELEMENT >, gum::MultiDimICIModel< GUM_ELEMENT >, and gum::MultiDimICIModel< GUM_SCALAR >.

Definition at line 266 of file multiDimContainer_tpl.h.

267 {
268 if (src.domainSize() != domainSize()) {
270 "Domain sizes do not fit : " << src.domainSize() << "!=" << domainSize());
271 }
272
273 Instantiation i_dest(*this);
275
276 for (i_dest.setFirst(), i_src.setFirst(); !i_dest.end(); ++i_dest, ++i_src) {
277 set(i_dest, src[i_src]);
278 }
279 }
virtual void set(const Instantiation &i, const GUM_ELEMENT &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(), gum::Instantiation::end(), GUM_ERROR, set(), and gum::Instantiation::setFirst().

Referenced by gum::Tensor< GUM_SCALAR >::Tensor(), gum::MultiDimArray< GUM_ELEMENT >::copyFrom(), and gum::MultiDimICIModel< GUM_SCALAR >::externalWeight().

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

◆ copyFrom() [2/2]

template<typename GUM_ELEMENT>
void gum::MultiDimContainer< GUM_ELEMENT >::copyFrom ( const MultiDimContainer< GUM_ELEMENT > & 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_ELEMENT, TerminalNodePolicy >, and gum::MultiDimFunctionGraph< GUM_ELEMENT, ExactTerminalNodePolicy >.

Definition at line 220 of file multiDimContainer_tpl.h.

221 {
222 if (src.domainSize() != domainSize()) {
224 "Domain sizes do not fit : " << src.domainSize() << "!=" << domainSize());
225 }
226
227 if (p_i == nullptr) { // if null, we just follow the same order
229 for (i.setFirst(); !i.end(); ++i) {
230 set(i, src[i]);
231 }
232 } else {
233 Instantiation i_dest(*this);
235 for (i_dest.setFirst(), i_src.setFirst(); !i_dest.end(); i_dest.incIn(*p_i), ++i_src) {
236 set(i_dest, src[i_src]);
237 }
238 }
239 }

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

Here is the call graph for this function:

◆ domainSize()

template<typename GUM_ELEMENT>
Size gum::MultiDimDecorator< GUM_ELEMENT >::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 183 of file multiDimDecorator_tpl.h.

183 {
184 return static_cast< MultiDimContainer< GUM_ELEMENT >* >(content_)->domainSize();
185 }

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

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

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

◆ empty()

template<typename GUM_ELEMENT>
bool gum::MultiDimDecorator< GUM_ELEMENT >::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 283 of file multiDimDecorator_tpl.h.

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

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

Referenced by apply(), empty(), fill(), get(), populate(), reduce(), and toString().

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

◆ endMultipleChanges() [1/2]

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

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 376 of file multiDimDecorator_tpl.h.

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

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

Referenced by 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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::endMultipleChanges ( const GUM_ELEMENT & x)
finalvirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 381 of file multiDimDecorator_tpl.h.

381 {
383 }

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

Here is the call graph for this function:

◆ erase() [1/2]

template<typename GUM_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::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 253 of file multiDimDecorator_tpl.h.

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

References gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::erase ( std::string_view name)
finalvirtual

Definition at line 258 of file multiDimDecorator_tpl.h.

258 {
260 }
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_ELEMENT>
void gum::MultiDimContainer< GUM_ELEMENT >::extractFrom ( const MultiDimContainer< GUM_ELEMENT > & 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 242 of file multiDimContainer_tpl.h.

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

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

Here is the call graph for this function:

◆ fill()

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

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 294 of file multiDimDecorator_tpl.h.

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

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

Referenced by fill().

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

◆ get()

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

Default implementation of MultiDimContainer::get().

Calls get_ as a l-value.

Reimplemented from gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 162 of file multiDimDecorator_tpl.h.

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

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

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::operator==(), and gum::prm::o3prmr::O3prmrInterpreter::query().

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

◆ get_()

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

Return a data, given a Instantiation - final method.

Parameters
iThe instantiation.
Exceptions
NullElement
NotFound

Implements gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 157 of file multiDimDecorator_tpl.h.

157 {
158 GUM_ERROR(OperationNotAllowed, "_get in the implementation !")
159 }

References GUM_ERROR.

◆ getMasterRef() [1/2]

template<typename GUM_ELEMENT>
const MultiDimAdressable & gum::MultiDimContainer< GUM_ELEMENT >::getMasterRef ( ) const
overridevirtualinherited

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.

Definition at line 307 of file multiDimContainer_tpl.h.

307 {
308 return static_cast< const MultiDimAdressable& >(*content());
309 }
MultiDimAdressable()
Default constructor.
virtual const MultiDimImplementation< GUM_ELEMENT > * 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_ELEMENT>
MultiDimAdressable & gum::MultiDimContainer< GUM_ELEMENT >::getMasterRef ( )
overridevirtualinherited

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.

Definition at line 302 of file multiDimContainer_tpl.h.

302 {
303 return static_cast< MultiDimAdressable& >(*content());
304 }

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

Here is the call graph for this function:

◆ nbrDim()

template<typename GUM_ELEMENT>
Idx gum::MultiDimDecorator< GUM_ELEMENT >::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 321 of file multiDimDecorator_tpl.h.

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

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

Referenced by gum::GibbsOperator< GUM_SCALAR >::_GibbsSample_(), nbrDim(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), and set().

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

◆ newFactory()

template<typename GUM_ELEMENT>
MultiDimDecorator< GUM_ELEMENT > * gum::MultiDimDecorator< GUM_ELEMENT >::newFactory ( ) const
nodiscardoverridepure virtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_ELEMENT >.

Implemented in gum::Tensor< GUM_SCALAR >, and gum::Tensor< GUM_ELEMENT >.

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

Here is the call graph for this function:

◆ notifyChange()

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

Definition at line 305 of file multiDimDecorator_tpl.h.

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

References GUM_ERROR.

◆ operator=() [1/2]

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

copy operator

Definition at line 132 of file multiDimDecorator_tpl.h.

133 {
138 if (content_ == nullptr)
142 return *this;
143 }
MultiDimContainer & operator=(const MultiDimContainer< GUM_ELEMENT > &src)
Default constructor.
MultiDimDecorator< GUM_ELEMENT > * newFactory() const override=0
Default implementation of MultiDimContainer::set().

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

Here is the caller graph for this function:

◆ operator=() [2/2]

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

assignment operator.

Definition at line 105 of file multiDimDecorator_tpl.h.

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

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

Here is the call graph for this function:

◆ operator==()

template<typename GUM_ELEMENT>
bool gum::MultiDimContainer< GUM_ELEMENT >::operator== ( const MultiDimContainer< GUM_ELEMENT > & 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 148 of file multiDimContainer_tpl.h.

149 {
150 if ((nbrDim() == p.nbrDim()) && (domainSize() == p.domainSize())) {
151 if (nbrDim() == 0) return true;
152
153 for (auto iter = variablesSequence().beginSafe(); iter != variablesSequence().endSafe();
154 ++iter) {
155 if (!p.variablesSequence().exists(*iter)) { return false; }
156 }
157 } else {
158 return false;
159 }
160
161 Instantiation i(*this);
163 for (i.setFirst(); !i.end(); ++i) {
164 if (cmp(get(i), p.get(i))) { return false; }
165 }
166
167 return true;
168 }
virtual GUM_ELEMENT 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_ELEMENT>
GUM_ELEMENT gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT) value.

Definition at line 103 of file multiDimContainer_tpl.h.

103 {
104 return get(i);
105 }

References get().

Here is the call graph for this function:

◆ populate() [1/2]

template<typename GUM_ELEMENT>
void gum::MultiDimContainer< GUM_ELEMENT >::populate ( std::initializer_list< GUM_ELEMENT > 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.
void set(const Instantiation &i, const GUM_ELEMENT &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_ELEMENT >, and gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >.

Definition at line 186 of file multiDimContainer_tpl.h.

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

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

Here is the call graph for this function:

◆ populate() [2/2]

template<typename GUM_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::populate ( const std::vector< GUM_ELEMENT > & 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_ELEMENT >.

Definition at line 326 of file multiDimDecorator_tpl.h.

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

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

Referenced by 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_ELEMENT>
Idx gum::MultiDimDecorator< GUM_ELEMENT >::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 273 of file multiDimDecorator_tpl.h.

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

References gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT>
GUM_ELEMENT gum::MultiDimDecorator< GUM_ELEMENT >::reduce ( std::function< GUM_ELEMENT(GUM_ELEMENT, GUM_ELEMENT) > f,
GUM_ELEMENT base ) const
finalvirtual

compute lfold for this container

Parameters
fthe function to apply
basethe initial value

Reimplemented from gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 348 of file multiDimDecorator_tpl.h.

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

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

Here is the call graph for this function:

◆ registerSlave()

template<typename GUM_ELEMENT>
bool gum::MultiDimDecorator< GUM_ELEMENT >::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 248 of file multiDimDecorator_tpl.h.

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

References gum::MultiDimContainer< GUM_ELEMENT >::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 57 of file multiDimInterface_inl.h.

57 {
58 if (!contains(x)) { GUM_ERROR(NotFound, "could not find the variable") }
59
60 if (contains(y)) { GUM_ERROR(DuplicateElement, "variable " << y << " already in MultiDim") }
61
62 if (x.domainSize() != y.domainSize()) {
63 GUM_ERROR(OperationNotAllowed, "incompatible variables")
64 }
65
66 replace_(&x, &y);
67 }
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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::replace_ ( const DiscreteVariable * x,
const DiscreteVariable * y )
overrideprotectedvirtual

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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::set ( const Instantiation & i,
const GUM_ELEMENT & value ) const
finalvirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Reimplemented from gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 171 of file multiDimDecorator_tpl.h.

172 {
173 if (static_cast< MultiDimContainer< GUM_ELEMENT >* >(content_)->nbrDim() == 0) {
175 } else {
177 }
178 }

References gum::MultiDimContainer< GUM_ELEMENT >::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(), and set().

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

◆ setChangeNotification()

template<typename GUM_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::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 213 of file multiDimDecorator_tpl.h.

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

References gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::setDecNotification ( const Instantiation & i)
finalvirtual

Listen to increment in each recorded Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 241 of file multiDimDecorator_tpl.h.

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

References gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::setFirstNotification ( const Instantiation & i)
finalvirtual

Listen to setFirst in a given Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 220 of file multiDimDecorator_tpl.h.

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

References gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::setIncNotification ( const Instantiation & i)
finalvirtual

Listen to increment in a given Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 234 of file multiDimDecorator_tpl.h.

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

References gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::setLastNotification ( const Instantiation & i)
finalvirtual

Listen to setLast in a given Instantiation.

Parameters
iThe Instantiation to listen.

Implements gum::MultiDimAdressable.

Definition at line 227 of file multiDimDecorator_tpl.h.

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

References gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT>
void gum::MultiDimDecorator< GUM_ELEMENT >::swapContent_ ( MultiDimImplementation< GUM_ELEMENT > * 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_ELEMENT>
std::string gum::MultiDimDecorator< GUM_ELEMENT >::toString ( ) const
overridevirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Reimplemented from gum::MultiDimContainer< GUM_ELEMENT >.

Definition at line 411 of file multiDimDecorator_tpl.h.

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

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

Here is the call graph for this function:

◆ toString() [2/2]

template<typename GUM_ELEMENT>
std::string gum::MultiDimDecorator< GUM_ELEMENT >::toString ( const Instantiation * i) const
overridevirtual

Default implementation of MultiDimContainer::set().

Calls get_ as a r-value.

Implements gum::MultiDimContainer< GUM_ELEMENT >.

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_ELEMENT>
bool gum::MultiDimDecorator< GUM_ELEMENT >::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 289 of file multiDimDecorator_tpl.h.

289 {
291 }
bool unregisterSlave(Instantiation &i) final
Unregister i as a slave of this MultiDimAdressable.

References gum::MultiDimContainer< GUM_ELEMENT >::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_ELEMENT>
const DiscreteVariable & gum::MultiDimDecorator< GUM_ELEMENT >::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 263 of file multiDimDecorator_tpl.h.

263 {
264 return static_cast< MultiDimContainer< GUM_ELEMENT >* >(content_)->variable(i);
265 }

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

Referenced by erase(), variable(), and variable().

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

◆ variable() [2/2]

template<typename GUM_ELEMENT>
const DiscreteVariable & gum::MultiDimDecorator< GUM_ELEMENT >::variable ( std::string_view 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 268 of file multiDimDecorator_tpl.h.

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

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

Here is the call graph for this function:

◆ variablesSequence()

template<typename GUM_ELEMENT>
const Sequence< const DiscreteVariable * > & gum::MultiDimDecorator< GUM_ELEMENT >::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 314 of file multiDimDecorator_tpl.h.

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

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

Referenced by gum::learning::DAG2BNLearner::createBNwithEM(), and variablesSequence().

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

Member Data Documentation

◆ content_

◆ empty_value_

template<typename GUM_ELEMENT>
GUM_ELEMENT gum::MultiDimDecorator< GUM_ELEMENT >::empty_value_
mutableprotected

value of the MultiDimDecorator if no dimension.

Definition at line 285 of file multiDimDecorator.h.

Referenced by MultiDimDecorator(), MultiDimDecorator(), apply(), fill(), operator=(), populate(), set(), and toString().


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