![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
aGrUM's Tensor is a multi-dimensional array with tensor operators. More...
#include <agrum/base/multidim/tensor.h>
Public Member Functions | |
Constructors, Destructors and Copy | |
| Tensor () | |
| Default constructor. | |
| Tensor (const std::vector< const DiscreteVariable * > &vars) | |
| Default constructor. | |
| Tensor (MultiDimImplementation< GUM_SCALAR > *aContent) | |
| Creates an tensor around aContent. | |
| Tensor (MultiDimImplementation< GUM_SCALAR > *aContent, const MultiDimContainer< GUM_SCALAR > &src) | |
| Copy constructor. | |
| Tensor (const Tensor< GUM_SCALAR > &src) | |
| Copy constructor & assignment. | |
| Tensor< GUM_SCALAR > & | operator= (const Tensor< GUM_SCALAR > &src) |
| Default constructor. | |
| Tensor (Tensor< GUM_SCALAR > &&from) | |
| move constructor & assignement | |
| Tensor< GUM_SCALAR > & | operator= (Tensor< GUM_SCALAR > &&src) |
| Default constructor. | |
| ~Tensor () final | |
| Destructor. | |
MultiDimContainer implementation | |
| Tensor< GUM_SCALAR > * | newFactory () const final |
| Default implementation of MultiDimContainer::set(). | |
Class operation for Tensor instances | |
| const Tensor< GUM_SCALAR > & | random () const |
| generate a random Tensor with each parameter in [0,1] | |
| const Tensor< GUM_SCALAR > & | randomDistribution () const |
| generate a random Distribution in the Tensor | |
| const Tensor< GUM_SCALAR > & | randomCPT () const |
| generate a random CPT in the Tensor | |
| const Tensor< GUM_SCALAR > & | noising (GUM_SCALAR alpha) const |
| add a noise in a CPT by mixing (1-alpha)this+alpha.randomCPT() | |
| Tensor< GUM_SCALAR > | sumOut (const gum::VariableSet &del_vars) const |
| Projection using sum as operation (and implementation-optimized operations). | |
| Tensor< GUM_SCALAR > | sumIn (const gum::VariableSet &kept_vars) const |
| Projection using sum as operation (and implementation-optimized operations). | |
| Tensor< GUM_SCALAR > | prodOut (const gum::VariableSet &del_vars) const |
| Projection using multiplication as operation (and implementation-optimized operations). | |
| Tensor< GUM_SCALAR > | prodIn (const gum::VariableSet &kept_vars) const |
| Projection using multiplication as operation (and implementation-optimized operations). | |
| Tensor< GUM_SCALAR > | minOut (const gum::VariableSet &del_vars) const |
| Projection using min as operation (and implementation-optimized operations). | |
| Tensor< GUM_SCALAR > | minIn (const gum::VariableSet &kept_vars) const |
| Projection using min as operation (and implementation-optimized operations). | |
| Tensor< GUM_SCALAR > | maxOut (const gum::VariableSet &del_vars) const |
| Projection using max as operation (and implementation-optimized operations). | |
| Tensor< GUM_SCALAR > | maxIn (const gum::VariableSet &kept_vars) const |
| Projection using max as operation (and implementation-optimized operations). | |
| Tensor< GUM_SCALAR > | isNonZeroMap () const |
| create a boolean-like tensor using the predicate isNonZero | |
| GUM_SCALAR | sum () const |
| sum of all elements in the Tensor | |
| GUM_SCALAR | product () const |
| product of all elements in the Tensor | |
| GUM_SCALAR | max () const |
| max of all elements in the Tensor | |
| GUM_SCALAR | min () const |
| min of all elements in the Tensor | |
| GUM_SCALAR | maxNonOne () const |
| max of all non one elements in the Tensor | |
| GUM_SCALAR | minNonZero () const |
| min of all non zero elements in the Tensor | |
| Set< Instantiation > | findAll (GUM_SCALAR v) const |
| set of instantiation corresponding to the parameter v in the Tensor | |
| std::pair< Set< Instantiation >, GUM_SCALAR > | argmax () const |
| Pair of the set of instantiation corresponding to the max and this max in the Tensor. | |
| std::pair< Set< Instantiation >, GUM_SCALAR > | argmin () const |
| Pair of the set of instantiation corresponding to the min and this min in the Tensor. | |
| GUM_SCALAR | expectedValue (std::function< GUM_SCALAR(const gum::Instantiation &) >) const |
| ExpectedValue computes the expectation of f over *this. | |
| GUM_SCALAR | entropy () const |
| entropy of the Tensor | |
| Tensor< GUM_SCALAR > | reorganize (const std::vector< const DiscreteVariable * > &vars) const |
| create a new Tensor with another order | |
| Tensor< GUM_SCALAR > | reorganize (const std::vector< std::string > &vars) const |
| create a new Tensor with another order | |
| Tensor< GUM_SCALAR > | extract (const Instantiation &inst) const |
| create a new Tensor extracted from *this given a partial instantiation | |
| Tensor< GUM_SCALAR > | putFirst (const DiscreteVariable *var) const |
| create a new Tensor with a certain variable in first | |
| Tensor< GUM_SCALAR > | putFirst (const std::string &varname) const |
| create a new Tensor with a certain variable in first | |
| const Tensor< GUM_SCALAR > & | fillWith (const Tensor< GUM_SCALAR > &src) const |
| copy a Tensor data using name of variables and labels (not necessarily the same variables in the same orders) | |
| const Tensor< GUM_SCALAR > & | fillWith (const Tensor< GUM_SCALAR > &src, const std::vector< std::string > &mapSrc) const |
| copy a Tensor data using the sequence of names in mapSrc to find the corresponding variables. | |
| const Tensor< GUM_SCALAR > & | fillWith (const std::vector< GUM_SCALAR > &data) const |
| Automatically fills the tensor with the values in v. | |
| const Tensor< GUM_SCALAR > & | fillWith (const GUM_SCALAR &val) const |
| Automatically fills this MultiDimContainer with the value v. | |
| const Tensor< GUM_SCALAR > & | abs () const |
| Apply abs on every element of the container. | |
| const Tensor< GUM_SCALAR > & | sq () const |
| apply $x^2$ on every element of the container | |
| const Tensor< GUM_SCALAR > & | log2 () const |
| apply $log_2(x)$ on every element of the container | |
| const Tensor< GUM_SCALAR > & | sgn () const |
| apply sgn(x)$ on every element of the container | |
| Tensor< GUM_SCALAR > | new_abs () const |
| Create a new tensor and apply abs on every element of the container. | |
| Tensor< GUM_SCALAR > | new_sq () const |
| Create a new tensor and apply $x^2$ on every element of the container. | |
| Tensor< GUM_SCALAR > | new_log2 () const |
| Create a new tensor and apply $log_2(x)$ on every element of the container. | |
| Tensor< GUM_SCALAR > | new_sgn () const |
| Create a new tensor and apply sgn(x)$ on every element of the container. | |
| const Tensor< GUM_SCALAR > & | normalize () const |
| normalisation of this do nothing if sum is 0 | |
| GUM_SCALAR | KL (const Tensor< GUM_SCALAR > &p) const |
| compute KL divergence between this and p Checks the compatibility and then compute KL divergence | |
| const Tensor< GUM_SCALAR > & | normalizeAsCPT (const Idx &varId=0) const |
| normalisation of this as a CPT for the variable varId | |
| const Tensor< GUM_SCALAR > & | scale (GUM_SCALAR v) const |
| multiply (each value of) *this by v | |
| const Tensor< GUM_SCALAR > & | translate (GUM_SCALAR v) const |
| add v to (each value of) *this | |
| const Tensor< GUM_SCALAR > & | inverse () const |
| the function to inverse (each value of) *this | |
| Idx | draw () const |
| get a value at random from a 1-D distribution | |
| Size | memoryFootprint () const |
| compute the (approximated) footprint in memory of the tensor | |
Tensor algebra operators | |
| Tensor< GUM_SCALAR > | operator+ (const Tensor< GUM_SCALAR > &p2) const |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > | operator+ (const GUM_SCALAR &v) const |
| the function to be used to add a GUM_SCALAR to a Tensor | |
| Tensor< GUM_SCALAR > | operator- (const Tensor< GUM_SCALAR > &p2) const |
| the function to be used to subtract two Tensors | |
| Tensor< GUM_SCALAR > | operator- (const GUM_SCALAR &v) const |
| the function to be used to substract a GUM_SCALAR from a Tensor | |
| Tensor< GUM_SCALAR > | operator* (const Tensor< GUM_SCALAR > &p2) const |
| the function to be used to multiply two Tensors | |
| Tensor< GUM_SCALAR > | operator* (const GUM_SCALAR &v) const |
| the function to be used to multiply a Tensor and a scalar | |
| Tensor< GUM_SCALAR > | operator/ (const Tensor< GUM_SCALAR > &p2) const |
| the function to be used to divide two Tensors | |
| Tensor< GUM_SCALAR > | operator/ (const GUM_SCALAR &v) const |
| the function to be used to divide a Tensor by a scalar | |
| Tensor< GUM_SCALAR > & | operator+= (const Tensor< GUM_SCALAR > &r) |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > & | operator+= (const GUM_SCALAR &v) |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > & | operator*= (const Tensor< GUM_SCALAR > &r) |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > & | operator*= (const GUM_SCALAR &v) |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > & | operator-= (const Tensor< GUM_SCALAR > &r) |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > & | operator-= (const GUM_SCALAR &v) |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > & | operator/= (const Tensor< GUM_SCALAR > &r) |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > & | operator/= (const GUM_SCALAR &v) |
| the function to be used to add two Tensors | |
| bool | isEvidence () const |
| is an evidence ? (marginal-like but has not to sum to 1) | |
| Tensor< GUM_SCALAR > | operator| (const Tensor< GUM_SCALAR > &p2) const |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > | operator& (const Tensor< GUM_SCALAR > &p2) const |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > | operator~ () const |
| the function to be used to add two Tensors | |
| bool | operator== (const Tensor< GUM_SCALAR > &r) const |
| the function to be used to add two Tensors | |
| Tensor< GUM_SCALAR > & | operator<< (const DiscreteVariable &v) |
| the function to be used to add two Tensors | |
| std::string | toString () const final |
| the function to be used to add two Tensors | |
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 DiscreteVariable & | variable (Idx) const final |
| Returns a const ref to the ith var. | |
| virtual const DiscreteVariable & | variable (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 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(). | |
Accessors / Modifiers | |
| virtual void | populate (std::initializer_list< GUM_SCALAR > l) const |
| Automatically fills this MultiDimContainer with the values in l. | |
| GUM_SCALAR | operator[] (const Instantiation &i) const |
| An [] operator using a Instantiation as argument. | |
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). | |
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 MultiDimAdressable & | getMasterRef () |
| In order to insure the dereference for decorators, we need to virtualize the access to master pointer. | |
| virtual const MultiDimAdressable & | getMasterRef () 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. | |
Static Public Member Functions | |
| static Tensor< GUM_SCALAR > | deterministicTensor (const DiscreteVariable &var, Idx value) |
| static Tensor< GUM_SCALAR > | deterministicTensor (const DiscreteVariable &var, const std::string &label) |
| static Tensor< GUM_SCALAR > | uniformTensor (const DiscreteVariable &var) |
| static Tensor< GUM_SCALAR > | evEq (const DiscreteVariable &v, double val) |
| numerical evidence generator | |
| static Tensor< GUM_SCALAR > | evIn (const DiscreteVariable &v, double val1, double val2) |
| numerical evidence generator | |
| static Tensor< GUM_SCALAR > | evGt (const DiscreteVariable &v, double val) |
| numerical evidence generator | |
| static Tensor< GUM_SCALAR > | evLt (const DiscreteVariable &v, double val) |
| numerical evidence generator | |
Protected Member Functions | |
| gum::VariableSet | complementVars_ (const gum::VariableSet &del_vars) const |
| 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. | |
aGrUM's Tensor is a multi-dimensional array with tensor operators.
It is used to represent probabilities and utilities in aGrUMs' multidimensional (graphical) models.
Using the decorator pattern, this representation is independent from the implementation of the multidimensional matrix.
| GUM_SCALAR | The type of the scalar stored in this multidimensional matrix. |
| INLINE gum::Tensor< GUM_SCALAR >::Tensor | ( | ) |
Default constructor.
Creates an empty null dimensional matrix with a MultiDimArray as its implementation.
Definition at line 61 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::MultiDimDecorator(), and Tensor().
Referenced by Tensor(), Tensor(), Tensor(), Tensor(), Tensor(), Tensor(), ~Tensor(), operator=(), and operator=().
| INLINE gum::Tensor< GUM_SCALAR >::Tensor | ( | const std::vector< const DiscreteVariable * > & | vars | ) |
Default constructor.
Creates an empty null dimensional matrix with a MultiDimArray as its implementation and add the vars
Definition at line 69 of file tensor_tpl.h.
References Tensor(), and gum::MultiDimDecorator< GUM_SCALAR >::add().
|
explicit |
Creates an tensor around aContent.
| aContent | The implementation of this Tensor. |
Definition at line 78 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::MultiDimDecorator(), and Tensor().
| gum::Tensor< GUM_SCALAR >::Tensor | ( | MultiDimImplementation< GUM_SCALAR > * | aContent, |
| const MultiDimContainer< GUM_SCALAR > & | src ) |
Copy constructor.
The newly created Tensor share the variables and the values from src, but no instantiation is associated to it. It allows to force the chosen implementation and to copy the data from src.
| aContent | The implementation to use in this Tensor. |
| src | The MultiDimContainer to copy. |
Definition at line 104 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::MultiDimDecorator(), Tensor(), gum::MultiDimDecorator< GUM_SCALAR >::add(), gum::MultiDimDecorator< GUM_SCALAR >::beginMultipleChanges(), gum::MultiDimContainer< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimInterface::empty(), gum::MultiDimDecorator< GUM_SCALAR >::endMultipleChanges(), and gum::MultiDimInterface::variablesSequence().
| INLINE gum::Tensor< GUM_SCALAR >::Tensor | ( | const Tensor< GUM_SCALAR > & | src | ) |
Copy constructor & assignment.
Definition at line 86 of file tensor_tpl.h.
References Tensor(), gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, and newFactory().
| INLINE gum::Tensor< GUM_SCALAR >::Tensor | ( | Tensor< GUM_SCALAR > && | from | ) |
move constructor & assignement
move constructor
Definition at line 97 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::MultiDimDecorator(), and Tensor().
|
final |
Destructor.
Definition at line 144 of file tensor_tpl.h.
References Tensor().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::abs | ( | ) | const |
Apply abs on every element of the container.
Definition at line 379 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::apply().
|
finalvirtualinherited |
Adds a new var to the variables of the multidimensional matrix.
| v | The new var. |
| DuplicateElement | Raised if the variable already belongs to the sequence of variables. |
| OperationNotAllowed | Raised if this object is non mutable. |
Implements gum::MultiDimInterface.
Definition at line 188 of file multiDimDecorator_tpl.h.
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().
|
finalvirtualinherited |
Apply a function on every element of the container.
| f | the function to apply |
Reimplemented from gum::MultiDimContainer< GUM_SCALAR >.
Definition at line 338 of file multiDimDecorator_tpl.h.
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().
| INLINE std::pair< Set< Instantiation >, GUM_SCALAR > gum::Tensor< GUM_SCALAR >::argmax | ( | ) | const |
Pair of the set of instantiation corresponding to the max and this max in the Tensor.
Definition at line 732 of file tensor_tpl.h.
References findAll(), and max().
| INLINE std::pair< Set< Instantiation >, GUM_SCALAR > gum::Tensor< GUM_SCALAR >::argmin | ( | ) | const |
Pair of the set of instantiation corresponding to the min and this min in the Tensor.
Definition at line 739 of file tensor_tpl.h.
References findAll(), and min().
|
finalvirtualinherited |
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.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), beginMultipleChanges(), and content_.
Referenced by gum::Tensor< GUM_SCALAR >::Tensor(), and beginMultipleChanges().
|
finalvirtualinherited |
Listen to changes in a given Instantiation.
| i | The Instantiation to listen. |
| var | The changed dim. |
| oldval | The old value. |
| newval | The changed value. |
Implements gum::MultiDimAdressable.
Definition at line 198 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), changeNotification(), and content_.
Referenced by changeNotification().
|
nodiscardprotected |
Definition at line 607 of file tensor_tpl.h.
References gum::Set< Key >::contains(), gum::Set< Key >::insert(), and gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence().
Referenced by maxIn(), minIn(), prodIn(), and sumIn().
|
finalvirtualinherited |
Returns true if var is in *this.
| v | A DiscreteVariable. |
Implements gum::MultiDimInterface.
Definition at line 277 of file multiDimDecorator_tpl.h.
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().
|
finalvirtualinherited |
Returns the implementation for this object (may be *this).
Implements gum::MultiDimContainer< GUM_SCALAR >.
Definition at line 366 of file multiDimDecorator_tpl.h.
References content_.
Referenced by MultiDimDecorator(), gum::Tensor< GUM_SCALAR >::Tensor(), gum::Tensor< GUM_SCALAR >::Tensor(), gum::Tensor< GUM_SCALAR >::max(), gum::Tensor< GUM_SCALAR >::maxIn(), gum::Tensor< GUM_SCALAR >::maxOut(), gum::Tensor< GUM_SCALAR >::memoryFootprint(), gum::Tensor< GUM_SCALAR >::min(), gum::Tensor< GUM_SCALAR >::minIn(), gum::Tensor< GUM_SCALAR >::minOut(), newFactory(), gum::Tensor< GUM_SCALAR >::newFactory(), gum::Tensor< GUM_SCALAR >::operator*(), gum::Tensor< GUM_SCALAR >::operator+(), gum::Tensor< GUM_SCALAR >::operator-(), gum::Tensor< GUM_SCALAR >::operator/(), operator=(), gum::Tensor< GUM_SCALAR >::prodIn(), gum::Tensor< GUM_SCALAR >::prodOut(), gum::Tensor< GUM_SCALAR >::product(), replace_(), gum::Tensor< GUM_SCALAR >::sum(), gum::Tensor< GUM_SCALAR >::sumIn(), gum::Tensor< GUM_SCALAR >::sumOut(), and gum::Tensor< GUM_SCALAR >::toString().
|
finalvirtualinherited |
Returns the implementation for this object (may be *this).
Implements gum::MultiDimContainer< GUM_SCALAR >.
Definition at line 359 of file multiDimDecorator_tpl.h.
References content_.
|
virtualinherited |
Removes all variables in this MultiDimContainer and copy the content of src, variables included.
| src | The 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.
References MultiDimContainer(), beginMultipleChanges(), gum::MultiDimInterface::erase(), gum::MultiDimInterface::nbrDim(), and gum::MultiDimInterface::variable().
Referenced by gum::TreeRegress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::compute().
|
virtualinherited |
Basic copy of a MultiDimContainer.
This method is virtual because it should be optimized in certain MultiDimContainer.
| src | The MultiDimContainer src which values are copied. This is a full copy with no verification of dimensions. |
| OperationNotAllowed | Raised 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.
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().
|
virtualinherited |
Basic copy of a MultiDimContainer.
This method is virtual because it should be optimized in certain MultiDimContainer.
| src | The MultiDimContainer src which values are copied. |
| p_i | Give the order to iterate in this MultiDimContainer during the copy (nullptr will correctly copy if this is a reorganization of src). |
| OperationNotAllowed | Raised 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.
References MultiDimContainer(), gum::MultiDimInterface::domainSize(), and GUM_ERROR.
|
static |
Definition at line 1172 of file tensor_tpl.h.
References deterministicTensor(), and gum::DiscreteVariable::index().
|
static |
Definition at line 1156 of file tensor_tpl.h.
References gum::Instantiation::chgVal().
Referenced by gum::BayesNet< double >::_clearTensors_(), gum::GraphicalModelInference< GUM_SCALAR >::_createHardEvidence_(), and deterministicTensor().
|
finalvirtualinherited |
Returns the product of the variables domain size.
Implements gum::MultiDimInterface.
Definition at line 181 of file multiDimDecorator_tpl.h.
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().
|
nodiscard |
get a value at random from a 1-D distribution
Definition at line 696 of file tensor_tpl.h.
References gum::Instantiation::end(), gum::MultiDimDecorator< GUM_SCALAR >::get(), GUM_ERROR, gum::Instantiation::inc(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), gum::randomProba(), gum::Instantiation::setFirst(), gum::Instantiation::val(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
Referenced by gum::GibbsOperator< GUM_SCALAR >::_GibbsSample_().
|
finalvirtualinherited |
Returns true if no var is in *this.
Implements gum::MultiDimInterface.
Definition at line 282 of file multiDimDecorator_tpl.h.
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().
|
finalvirtualinherited |
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.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and endMultipleChanges().
Referenced by gum::Tensor< GUM_SCALAR >::Tensor(), endMultipleChanges(), endMultipleChanges(), and newFactory().
|
finalvirtualinherited |
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.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and endMultipleChanges().
| INLINE GUM_SCALAR gum::Tensor< GUM_SCALAR >::entropy | ( | ) | const |
entropy of the Tensor
Definition at line 250 of file tensor_tpl.h.
References expectedValue(), gum::MultiDimDecorator< GUM_SCALAR >::get(), and GUM_LOG2_OR_0.
|
finalvirtualinherited |
Removes a var from the variables of the multidimensional matrix.
| OperationNotAllowed | Raised if this object is non mutable. |
| NotFound | Raised if v does not belong to this. |
Implements gum::MultiDimInterface.
Definition at line 251 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and erase().
Referenced by erase(), and erase().
|
finalvirtualinherited |
Definition at line 256 of file multiDimDecorator_tpl.h.
References erase(), and variable().
|
static |
numerical evidence generator
Definition at line 1085 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::add(), gum::Instantiation::chgVal(), gum::DiscreteVariable::closestIndex(), fillWith(), and gum::MultiDimDecorator< GUM_SCALAR >::set().
Referenced by gum::IBayesNet< GUM_SCALAR >::evEq(), evGt(), and evLt().
|
static |
numerical evidence generator
Definition at line 1119 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::add(), gum::Instantiation::chgVal(), gum::DiscreteVariable::closestIndex(), gum::DiscreteVariable::domainSize(), evEq(), fillWith(), and gum::MultiDimDecorator< GUM_SCALAR >::set().
Referenced by gum::IBayesNet< GUM_SCALAR >::evGt().
|
static |
numerical evidence generator
Definition at line 1099 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::add(), gum::Instantiation::chgVal(), gum::DiscreteVariable::closestIndex(), fillWith(), GUM_ERROR, and gum::MultiDimDecorator< GUM_SCALAR >::set().
Referenced by gum::IBayesNet< GUM_SCALAR >::evIn().
|
static |
numerical evidence generator
Definition at line 1135 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::add(), gum::Instantiation::chgVal(), gum::DiscreteVariable::closestIndex(), evEq(), fillWith(), and gum::MultiDimDecorator< GUM_SCALAR >::set().
Referenced by gum::IBayesNet< GUM_SCALAR >::evLt().
| GUM_SCALAR gum::Tensor< GUM_SCALAR >::expectedValue | ( | std::function< GUM_SCALAR(const gum::Instantiation &) > | f | ) | const |
ExpectedValue computes the expectation of f over *this.
ExpectedValue assumes (and does not check) that the Tensor contains a joint distribution.
Definition at line 233 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), and gum::MultiDimDecorator< GUM_SCALAR >::get().
Referenced by entropy().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::extract | ( | const Instantiation & | inst | ) | const |
create a new Tensor extracted from *this given a partial instantiation
Definition at line 688 of file tensor_tpl.h.
|
virtualinherited |
Basic extraction of a MultiDimContainer.
This method is virtual because it should be optimized in certain MultiDimContainer.
| src | The MultiDimContainer src which datas are copied. |
| mask | partial 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.
References MultiDimContainer(), and beginMultipleChanges().
|
finalvirtualinherited |
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.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, empty(), empty_value_, and fill().
Referenced by fill(), and gum::Tensor< GUM_SCALAR >::fillWith().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::fillWith | ( | const GUM_SCALAR & | val | ) | const |
Automatically fills this MultiDimContainer with the value v.
| v | contains the data. |
Definition at line 264 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::fill().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::fillWith | ( | const std::vector< GUM_SCALAR > & | data | ) | const |
Automatically fills the tensor with the values in v.
| v | Vector of values. |
| SizeError | Raised if v size's does not matches this MultiDimContainer domain size. |
Definition at line 258 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::populate().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::fillWith | ( | const Tensor< GUM_SCALAR > & | src | ) | const |
copy a Tensor data using name of variables and labels (not necessarily the same variables in the same orders)
| InvalidArgument | if the Tensor is not compatible with this |
Definition at line 271 of file tensor_tpl.h.
References gum::Instantiation::chgVal(), gum::Set< Key >::contains(), gum::Instantiation::end(), GUM_ERROR, gum::Set< Key >::insert(), gum::Variable::name(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), gum::MultiDimDecorator< GUM_SCALAR >::set(), gum::Instantiation::setFirst(), gum::Instantiation::val(), gum::Instantiation::variable(), and gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence().
Referenced by gum::DecisionTensor< GUM_SCALAR >::clear(), evEq(), evGt(), evIn(), evLt(), noising(), random(), randomCPT(), and randomDistribution().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::fillWith | ( | const Tensor< GUM_SCALAR > & | src, |
| const std::vector< std::string > & | mapSrc ) const |
copy a Tensor data using the sequence of names in mapSrc to find the corresponding variables.
For instance, to copy the tensor P(A,B,C) in Q(D,E,A) with the mapping P.A<->Q.E, P.B<->Q.A, P.C<->Q.D (assuming that the corresponding variables have the same domain size and the order of labels):
| InvalidArgument | if the Tensor is not compatible with this |
Definition at line 304 of file tensor_tpl.h.
References gum::Instantiation::add(), gum::Instantiation::end(), GUM_ERROR, gum::MultiDimDecorator< GUM_SCALAR >::set(), gum::Instantiation::setFirst(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
| Set< Instantiation > gum::Tensor< GUM_SCALAR >::findAll | ( | GUM_SCALAR | v | ) | const |
set of instantiation corresponding to the parameter v in the Tensor
Definition at line 718 of file tensor_tpl.h.
References gum::Instantiation::end(), gum::MultiDimDecorator< GUM_SCALAR >::get(), gum::Set< Key >::insert(), and gum::Instantiation::setFirst().
Referenced by argmax(), and argmin().
|
finalvirtualinherited |
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.
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().
|
finalprotectedvirtualinherited |
Return a data, given a Instantiation - final method.
| i | The instantiation. |
| NullElement | |
| NotFound |
Implements gum::MultiDimContainer< GUM_SCALAR >.
Definition at line 155 of file multiDimDecorator_tpl.h.
References GUM_ERROR.
|
virtualinherited |
In order to insure the dereference for decorators, we need to virtualize the access to master pointer.
Implements gum::MultiDimAdressable.
Reimplemented in gum::MultiDimBucket< GUM_SCALAR >.
Definition at line 306 of file multiDimContainer_tpl.h.
References gum::MultiDimAdressable::MultiDimAdressable(), and content().
|
virtualinherited |
In order to insure the dereference for decorators, we need to virtualize the access to master pointer.
Implements gum::MultiDimAdressable.
Reimplemented in gum::MultiDimBucket< GUM_SCALAR >.
Definition at line 311 of file multiDimContainer_tpl.h.
References gum::MultiDimAdressable::MultiDimAdressable(), and content().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::inverse | ( | ) | const |
the function to inverse (each value of) *this
Definition at line 449 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::apply().
|
nodiscard |
is an evidence ? (marginal-like but has not to sum to 1)
Definition at line 839 of file tensor_tpl.h.
References max(), min(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), and sum().
Referenced by operator&(), operator|(), and operator~().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::isNonZeroMap | ( | ) | const |
create a boolean-like tensor using the predicate isNonZero
Definition at line 597 of file tensor_tpl.h.
| INLINE GUM_SCALAR gum::Tensor< GUM_SCALAR >::KL | ( | const Tensor< GUM_SCALAR > & | p | ) | const |
compute KL divergence between this and p Checks the compatibility and then compute KL divergence
| gum::InvalidArgument | if p is not compatible with $this (dimension, variables) |
| gum::FatalError | if a zero is found in p or this and not in the other. |
Definition at line 349 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::contains(), gum::Instantiation::end(), gum::MultiDimDecorator< GUM_SCALAR >::get(), GUM_ERROR, gum::Instantiation::inc(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), gum::Instantiation::setFirst(), and gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::log2 | ( | ) | const |
apply $log_2(x)$ on every element of the container
Definition at line 337 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::apply().
| INLINE GUM_SCALAR gum::Tensor< GUM_SCALAR >::max | ( | ) | const |
max of all elements in the Tensor
Definition at line 175 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, and gum::projectMax().
Referenced by argmax(), isEvidence(), maxIn(), and maxOut().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::maxIn | ( | const gum::VariableSet & | kept_vars | ) | const |
Projection using max as operation (and implementation-optimized operations).
| kept_vars | is the set of vars to keep |
Definition at line 584 of file tensor_tpl.h.
References complementVars_(), gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::Set< Key >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, max(), and gum::projectMax().
| GUM_SCALAR gum::Tensor< GUM_SCALAR >::maxNonOne | ( | ) | const |
max of all non one elements in the Tensor
Definition at line 194 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, and gum::MultiDimDecorator< GUM_SCALAR >::reduce().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::maxOut | ( | const gum::VariableSet & | del_vars | ) | const |
Projection using max as operation (and implementation-optimized operations).
| del_vars | is the set of vars to eliminate |
Definition at line 522 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, gum::Set< Key >::exists(), max(), gum::projectMax(), gum::Set< Key >::size(), and gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence().
| Size gum::Tensor< GUM_SCALAR >::memoryFootprint | ( | ) | const |
compute the (approximated) footprint in memory of the tensor
Definition at line 1151 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content().
| INLINE GUM_SCALAR gum::Tensor< GUM_SCALAR >::min | ( | ) | const |
min of all elements in the Tensor
Definition at line 184 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, and gum::projectMin().
Referenced by argmin(), isEvidence(), minIn(), and minOut().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::minIn | ( | const gum::VariableSet & | kept_vars | ) | const |
Projection using min as operation (and implementation-optimized operations).
| kept_vars | is the set of vars to keep |
Definition at line 571 of file tensor_tpl.h.
References complementVars_(), gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::Set< Key >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, min(), and gum::projectMin().
| INLINE GUM_SCALAR gum::Tensor< GUM_SCALAR >::minNonZero | ( | ) | const |
min of all non zero elements in the Tensor
Definition at line 215 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, and gum::MultiDimDecorator< GUM_SCALAR >::reduce().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::minOut | ( | const gum::VariableSet & | del_vars | ) | const |
Projection using min as operation (and implementation-optimized operations).
| del_vars | is the set of vars to eliminate |
Definition at line 500 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, gum::Set< Key >::exists(), min(), gum::projectMin(), gum::Set< Key >::size(), and gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence().
|
finalvirtualinherited |
Returns the number of vars in the multidimensional container.
Implements gum::MultiDimInterface.
Definition at line 320 of file multiDimDecorator_tpl.h.
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().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::new_abs | ( | ) | const |
Create a new tensor and apply abs on every element of the container.
Definition at line 797 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::new_log2 | ( | ) | const |
Create a new tensor and apply $log_2(x)$ on every element of the container.
Definition at line 807 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::new_sgn | ( | ) | const |
Create a new tensor and apply sgn(x)$ on every element of the container.
fill the tensor with -1 for a GUM_SCALAR<0,1 if >0 and 0 if ==0
Definition at line 812 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::new_sq | ( | ) | const |
Create a new tensor and apply $x^2$ on every element of the container.
Definition at line 802 of file tensor_tpl.h.
|
finalvirtual |
Default implementation of MultiDimContainer::set().
Calls get_ as a r-value.
Implements gum::MultiDimDecorator< GUM_SCALAR >.
Definition at line 150 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), and newFactory().
Referenced by Tensor(), and newFactory().
| const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::noising | ( | GUM_SCALAR | alpha | ) | const |
add a noise in a CPT by mixing (1-alpha)this+alpha.randomCPT()
Definition at line 788 of file tensor_tpl.h.
References fillWith(), GUM_ERROR, and scale().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::normalize | ( | ) | const |
normalisation of this do nothing if sum is 0
Definition at line 390 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::apply(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, and sum().
Referenced by gum::GibbsOperator< GUM_SCALAR >::_GibbsSample_().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::normalizeAsCPT | ( | const Idx & | varId = 0 | ) | const |
normalisation of this as a CPT for the variable varId
If the Tensor is empty, the argument is not used.
| FatalError | it some distribution sums to 0, or if varId>=nbrDim() |
Definition at line 405 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, gum::Instantiation::end(), gum::MultiDimDecorator< GUM_SCALAR >::get(), GUM_ERROR, gum::Instantiation::incNotVar(), gum::Instantiation::incVar(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), gum::MultiDimDecorator< GUM_SCALAR >::set(), gum::Instantiation::setFirst(), gum::Instantiation::setFirstVar(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
|
finalvirtualinherited |
Definition at line 304 of file multiDimDecorator_tpl.h.
References GUM_ERROR.
|
inherited |
Test if this MultiDimContainer is different of p.
| p | The MultiDimContainer to test for inequality. |
Definition at line 171 of file multiDimContainer_tpl.h.
References MultiDimContainer().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator& | ( | const Tensor< GUM_SCALAR > & | p2 | ) | const |
the function to be used to add two Tensors
Definition at line 862 of file tensor_tpl.h.
References gum::Instantiation::end(), GUM_ERROR, isEvidence(), gum::Instantiation::setFirst(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator* | ( | const GUM_SCALAR & | v | ) | const |
the function to be used to multiply a Tensor and a scalar
Definition at line 917 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator* | ( | const Tensor< GUM_SCALAR > & | p2 | ) | const |
the function to be used to multiply two Tensors
Definition at line 908 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::empty(), and gum::MultiDimDecorator< GUM_SCALAR >::empty_value_.
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator*= | ( | const GUM_SCALAR & | v | ) |
the function to be used to add two Tensors
Definition at line 958 of file tensor_tpl.h.
References scale().
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator*= | ( | const Tensor< GUM_SCALAR > & | r | ) |
the function to be used to add two Tensors
Definition at line 952 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator+ | ( | const GUM_SCALAR & | v | ) | const |
the function to be used to add a GUM_SCALAR to a Tensor
Definition at line 833 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator+ | ( | const Tensor< GUM_SCALAR > & | p2 | ) | const |
the function to be used to add two Tensors
Definition at line 824 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::empty(), and gum::MultiDimDecorator< GUM_SCALAR >::empty_value_.
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator+= | ( | const GUM_SCALAR & | v | ) |
the function to be used to add two Tensors
Definition at line 946 of file tensor_tpl.h.
References translate().
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator+= | ( | const Tensor< GUM_SCALAR > & | r | ) |
the function to be used to add two Tensors
Definition at line 940 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator- | ( | const GUM_SCALAR & | v | ) | const |
the function to be used to substract a GUM_SCALAR from a Tensor
Definition at line 902 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator- | ( | const Tensor< GUM_SCALAR > & | p2 | ) | const |
the function to be used to subtract two Tensors
Definition at line 890 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::empty(), and gum::MultiDimDecorator< GUM_SCALAR >::empty_value_.
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator-= | ( | const GUM_SCALAR & | v | ) |
the function to be used to add two Tensors
Definition at line 970 of file tensor_tpl.h.
References translate().
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator-= | ( | const Tensor< GUM_SCALAR > & | r | ) |
the function to be used to add two Tensors
Definition at line 964 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator/ | ( | const GUM_SCALAR & | v | ) | const |
the function to be used to divide a Tensor by a scalar
Definition at line 935 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator/ | ( | const Tensor< GUM_SCALAR > & | p2 | ) | const |
the function to be used to divide two Tensors
Definition at line 923 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::empty(), and gum::MultiDimDecorator< GUM_SCALAR >::empty_value_.
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator/= | ( | const GUM_SCALAR & | v | ) |
the function to be used to add two Tensors
Definition at line 982 of file tensor_tpl.h.
References scale().
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator/= | ( | const Tensor< GUM_SCALAR > & | r | ) |
the function to be used to add two Tensors
Definition at line 976 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator<< | ( | const DiscreteVariable & | v | ) |
the function to be used to add two Tensors
Definition at line 812 of file tensor_tpl.h.
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator= | ( | const Tensor< GUM_SCALAR > & | src | ) |
Default constructor.
Creates an empty null dimensional matrix with a MultiDimArray as its implementation.
Definition at line 124 of file tensor_tpl.h.
References Tensor(), and gum::MultiDimDecorator< GUM_SCALAR >::operator=().
| Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::operator= | ( | Tensor< GUM_SCALAR > && | src | ) |
Default constructor.
Creates an empty null dimensional matrix with a MultiDimArray as its implementation.
Definition at line 133 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::MultiDimDecorator(), Tensor(), and gum::MultiDimDecorator< GUM_SCALAR >::operator=().
|
inherited |
Test if this MultiDimContainer is equal to p.
| p | The MultiDimContainer to test for equality. |
Definition at line 146 of file multiDimContainer_tpl.h.
References MultiDimContainer(), gum::MultiDimInterface::domainSize(), gum::MultiDimInterface::nbrDim(), and gum::MultiDimInterface::variablesSequence().
| bool gum::Tensor< GUM_SCALAR >::operator== | ( | const Tensor< GUM_SCALAR > & | r | ) | const |
the function to be used to add two Tensors
Definition at line 988 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), and gum::MultiDimDecorator< GUM_SCALAR >::empty_value_.
|
inherited |
An [] operator using a Instantiation as argument.
| i | An Instantiation. |
Definition at line 101 of file multiDimContainer_tpl.h.
References get().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator| | ( | const Tensor< GUM_SCALAR > & | p2 | ) | const |
the function to be used to add two Tensors
Definition at line 847 of file tensor_tpl.h.
References gum::Instantiation::end(), GUM_ERROR, isEvidence(), gum::Instantiation::setFirst(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::operator~ | ( | ) | const |
the function to be used to add two Tensors
Definition at line 877 of file tensor_tpl.h.
References gum::Instantiation::end(), GUM_ERROR, isEvidence(), and gum::Instantiation::setFirst().
|
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.
| l | contains the data. |
| SizeError | Raised 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.
References gum::MultiDimInterface::domainSize(), GUM_ERROR, and set().
|
finalvirtualinherited |
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.
| v | Vector of values. |
| SizeError | Raised 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.
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().
|
finalvirtualinherited |
Returns the index of a variable.
| v | The variable for which the index is returned. |
| NotFound | Raised if v is not in this multidimensional matrix. |
Implements gum::MultiDimInterface.
Definition at line 272 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and pos().
Referenced by pos().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::prodIn | ( | const gum::VariableSet & | kept_vars | ) | const |
Projection using multiplication as operation (and implementation-optimized operations).
| kept_vars | is the set of vars to keep |
Definition at line 558 of file tensor_tpl.h.
References complementVars_(), gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::Set< Key >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, product(), and gum::projectProduct().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::prodOut | ( | const gum::VariableSet & | del_vars | ) | const |
Projection using multiplication as operation (and implementation-optimized operations).
| del_vars | is the set of vars to eliminate |
Definition at line 478 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, gum::Set< Key >::exists(), product(), gum::projectProduct(), gum::Set< Key >::size(), and gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence().
| INLINE GUM_SCALAR gum::Tensor< GUM_SCALAR >::product | ( | ) | const |
product of all elements in the Tensor
Definition at line 166 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, and gum::projectProduct().
Referenced by prodIn(), and prodOut().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::putFirst | ( | const DiscreteVariable * | var | ) | const |
create a new Tensor with a certain variable in first
| InvalidArgument | if the var is not in the tensor |
Definition at line 658 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::contains(), GUM_ERROR, gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), reorganize(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
Referenced by putFirst().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::putFirst | ( | const std::string & | varname | ) | const |
create a new Tensor with a certain variable in first
| InvalidArgument | if the var is not in the tensor |
Definition at line 673 of file tensor_tpl.h.
References GUM_ERROR, gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), putFirst(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
| const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::random | ( | ) | const |
generate a random Tensor with each parameter in [0,1]
Definition at line 745 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::domainSize(), fillWith(), and gum::randomProba().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::randomCPT | ( | ) | const |
generate a random CPT in the Tensor
Definition at line 770 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::domainSize(), gum::Instantiation::end(), fillWith(), gum::Instantiation::incNotVar(), gum::Instantiation::incVar(), gum::randomDistribution(), gum::MultiDimDecorator< GUM_SCALAR >::set(), gum::Instantiation::setFirstNotVar(), gum::Instantiation::setFirstVar(), gum::Instantiation::unsetEnd(), gum::Instantiation::val(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::randomDistribution | ( | ) | const |
generate a random Distribution in the Tensor
Definition at line 759 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::domainSize(), fillWith(), and gum::randomDistribution().
|
finalvirtualinherited |
compute lfold for this container
| f | the function to apply |
| base | the initial value |
Reimplemented from gum::MultiDimContainer< GUM_SCALAR >.
Definition at line 348 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and empty().
Referenced by gum::Tensor< GUM_SCALAR >::maxNonOne(), and gum::Tensor< GUM_SCALAR >::minNonZero().
|
finalvirtualinherited |
Register i as a slave of this MultiDimAdressable.
| i | The Instantiation to enslave. |
Implements gum::MultiDimAdressable.
Definition at line 246 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and registerSlave().
Referenced by registerSlave().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::reorganize | ( | const std::vector< const DiscreteVariable * > & | vars | ) | const |
create a new Tensor with another order
| InvalidArgument | if not all and only the vars of the tensor are in vars |
Definition at line 618 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::contains(), and GUM_ERROR.
Referenced by putFirst(), and reorganize().
| Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::reorganize | ( | const std::vector< std::string > & | vars | ) | const |
create a new Tensor with another order
| InvalidArgument | if not all and only the vars of the tensor are in vars |
Definition at line 640 of file tensor_tpl.h.
References gum::HashTable< Key, Val >::exists(), GUM_ERROR, gum::HashTable< Key, Val >::insert(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), and reorganize().
|
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.
| x | The variable in this which will be replaced. |
| y | The variable replacing y. |
| NotFound | Raised if x does not belong to this MultiDim. |
| OperationNotAllowed | If y and x are not interchangeable. |
| DuplicateElement | If y is already in this MultiDim. |
Definition at line 56 of file multiDimInterface_inl.h.
References contains(), gum::DiscreteVariable::domainSize(), GUM_ERROR, and replace_().
|
protectedvirtualinherited |
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.
This is called only when everything have been checked.
| x | The variable to replace in |
| y | The second variable to swap. |
Implements gum::MultiDimInterface.
Definition at line 405 of file multiDimDecorator_tpl.h.
References content().
Referenced by newFactory().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::scale | ( | GUM_SCALAR | v | ) | const |
multiply (each value of) *this by v
Definition at line 437 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::apply().
Referenced by noising(), operator*=(), and operator/=().
|
finalvirtualinherited |
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.
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().
|
finalvirtualinherited |
Listen to an assignment of a value in a Instantiation.
| i | The Instantiation to listen. |
Implements gum::MultiDimAdressable.
Definition at line 211 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setChangeNotification().
Referenced by setChangeNotification().
|
finalvirtualinherited |
Listen to increment in each recorded Instantiation.
| i | The Instantiation to listen. |
Implements gum::MultiDimAdressable.
Definition at line 239 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setDecNotification().
Referenced by setDecNotification().
|
finalvirtualinherited |
Listen to setFirst in a given Instantiation.
| i | The Instantiation to listen. |
Implements gum::MultiDimAdressable.
Definition at line 218 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setFirstNotification().
Referenced by setFirstNotification().
|
finalvirtualinherited |
Listen to increment in a given Instantiation.
| i | The Instantiation to listen. |
Implements gum::MultiDimAdressable.
Definition at line 232 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setIncNotification().
Referenced by setIncNotification().
|
finalvirtualinherited |
Listen to setLast in a given Instantiation.
| i | The Instantiation to listen. |
Implements gum::MultiDimAdressable.
Definition at line 225 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and setLastNotification().
Referenced by setLastNotification().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::sgn | ( | ) | const |
apply sgn(x)$ on every element of the container
fill the tensor with -1 for a GUM_SCALAR<0,1 if >0 and 0 if ==0
Definition at line 343 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::apply().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::sq | ( | ) | const |
apply $x^2$ on every element of the container
Definition at line 331 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::apply().
| INLINE GUM_SCALAR gum::Tensor< GUM_SCALAR >::sum | ( | ) | const |
sum of all elements in the Tensor
Definition at line 157 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, and gum::projectSum().
Referenced by gum::GibbsOperator< GUM_SCALAR >::_GibbsSample_(), isEvidence(), normalize(), sumIn(), and sumOut().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::sumIn | ( | const gum::VariableSet & | kept_vars | ) | const |
Projection using sum as operation (and implementation-optimized operations).
| kept_vars | is the set of vars to keep |
Definition at line 544 of file tensor_tpl.h.
References complementVars_(), gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::Set< Key >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, gum::projectSum(), and sum().
| INLINE Tensor< GUM_SCALAR > gum::Tensor< GUM_SCALAR >::sumOut | ( | const gum::VariableSet & | del_vars | ) | const |
Projection using sum as operation (and implementation-optimized operations).
| del_vars | is the set of vars to eliminate |
Definition at line 455 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::MultiDimDecorator< GUM_SCALAR >::content_, gum::MultiDimDecorator< GUM_SCALAR >::empty(), gum::MultiDimDecorator< GUM_SCALAR >::empty_value_, gum::Set< Key >::exists(), gum::projectSum(), gum::Set< Key >::size(), sum(), and gum::MultiDimDecorator< GUM_SCALAR >::variablesSequence().
|
protectedinherited |
protected method to swap the implementation behind the Tensor
Definition at line 386 of file multiDimDecorator_tpl.h.
References content_.
Referenced by newFactory().
|
virtualinherited |
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.
References content_.
Referenced by newFactory().
|
nodiscardfinalvirtual |
the function to be used to add two Tensors
Reimplemented from gum::MultiDimDecorator< GUM_SCALAR >.
Definition at line 999 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::content(), gum::Instantiation::decNotVar(), gum::Instantiation::end(), gum::MultiDimDecorator< GUM_SCALAR >::get(), gum::Instantiation::incNotVar(), gum::Instantiation::incVar(), gum::Instantiation::setFirst(), gum::Instantiation::setFirstVar(), gum::Instantiation::setLast(), and gum::Instantiation::val().
| INLINE const Tensor< GUM_SCALAR > & gum::Tensor< GUM_SCALAR >::translate | ( | GUM_SCALAR | v | ) | const |
add v to (each value of) *this
Definition at line 443 of file tensor_tpl.h.
References gum::MultiDimDecorator< GUM_SCALAR >::apply().
Referenced by operator+=(), and operator-=().
|
static |
Definition at line 1178 of file tensor_tpl.h.
|
finalvirtualinherited |
Unregister i as a slave of this MultiDimAdressable.
| i | The Instantiation to free. |
Implements gum::MultiDimAdressable.
Definition at line 288 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and unregisterSlave().
Referenced by unregisterSlave().
|
finalvirtualinherited |
Returns the variable with the name.
| name | The index of the variable |
| NotFound | Raised if the element cannot be found. |
Implements gum::MultiDimInterface.
Definition at line 267 of file multiDimDecorator_tpl.h.
References gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), content_, and variable().
|
finalvirtualinherited |
Returns a const ref to the ith var.
param i An index of this multidimensional matrix.
| NotFound | Raised if i does not reference a variable in this multidimensional matrix. |
Implements gum::MultiDimInterface.
Definition at line 261 of file multiDimDecorator_tpl.h.
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().
|
finalvirtualinherited |
Returns a const ref to the sequence of DiscreteVariable*.
Implements gum::MultiDimInterface.
Definition at line 313 of file multiDimDecorator_tpl.h.
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().
|
mutableprotectedinherited |
The true container.
Definition at line 271 of file multiDimDecorator.h.
Referenced by MultiDimDecorator(), MultiDimDecorator(), ~MultiDimDecorator(), add(), apply(), beginMultipleChanges(), changeNotification(), contains(), content(), content(), domainSize(), empty(), endMultipleChanges(), endMultipleChanges(), erase(), 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(), nbrDim(), gum::Tensor< GUM_SCALAR >::normalize(), gum::Tensor< GUM_SCALAR >::normalizeAsCPT(), operator=(), operator=(), gum::Tensor< GUM_SCALAR >::operator==(), populate(), pos(), gum::Tensor< GUM_SCALAR >::prodIn(), gum::Tensor< GUM_SCALAR >::prodOut(), gum::Tensor< GUM_SCALAR >::product(), reduce(), registerSlave(), set(), setChangeNotification(), setDecNotification(), setFirstNotification(), setIncNotification(), setLastNotification(), gum::Tensor< GUM_SCALAR >::sum(), gum::Tensor< GUM_SCALAR >::sumIn(), gum::Tensor< GUM_SCALAR >::sumOut(), swapContent_(), toString(), toString(), unregisterSlave(), variable(), variable(), and variablesSequence().
|
mutableprotectedinherited |
value of the MultiDimDecorator if no dimension.
Definition at line 285 of file multiDimDecorator.h.
Referenced by MultiDimDecorator(), MultiDimDecorator(), MultiDimDecorator(), gum::Tensor< GUM_SCALAR >::Tensor(), apply(), 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/(), operator=(), operator=(), gum::Tensor< GUM_SCALAR >::operator==(), populate(), gum::Tensor< GUM_SCALAR >::prodIn(), gum::Tensor< GUM_SCALAR >::prodOut(), gum::Tensor< GUM_SCALAR >::product(), set(), gum::Tensor< GUM_SCALAR >::sum(), gum::Tensor< GUM_SCALAR >::sumIn(), gum::Tensor< GUM_SCALAR >::sumOut(), and toString().