aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::MultiDimCombinationDefault< TABLE > Class Template Referencefinal

A class to combine efficiently several MultiDim tables. More...

#include <agrum/base/multidim/operators/multiDimCombinationDefault.h>

Inheritance diagram for gum::MultiDimCombinationDefault< TABLE >:
Collaboration diagram for gum::MultiDimCombinationDefault< TABLE >:

Public Types

using value_type = typename TableType< TABLE >::value_type
 the type of the values contained into TABLE

Public Member Functions

Constructors / Destructors
 MultiDimCombinationDefault (TABLE(*combine)(const TABLE &, const TABLE &))
 Default constructor.
 MultiDimCombinationDefault (const MultiDimCombinationDefault< TABLE > &)
 Copy constructor.
virtual ~MultiDimCombinationDefault ()
 Destructor.
virtual MultiDimCombinationDefault< TABLE > * clone () const
 virtual constructor
Accessors/Modifiers
const IScheduleMultiDimschedule (Schedule &schedule, const Set< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const
 add to a given schedule the set of operations needed to perform the combination
const IScheduleMultiDimschedule (Schedule &schedule, const std::vector< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const
 returns the combination function currently used by the combinator

Private Member Functions

double _combinedSize_ (const IScheduleMultiDim &table1, const IScheduleMultiDim &table2) const
 returns the domain size of the Cartesian product of the union of all the variables in seq1 and seq2.
void _freeData_ (std::vector< const IScheduleMultiDim * > &tables, std::vector< ScheduleOperator * > &operations) const
 free the scheduling memory

Private Attributes

TABLE(* _combine_ )(const TABLE &t1, const TABLE &t2)
 The function used to combine two tables.

Accessors/Modifiers

TABLE(*)(const TABLE &, const TABLE &) combinationFunction ()
 Returns the combination function currently used by the combinator.
TABLE * execute (const Set< const TABLE * > &set) const final
 Creates and returns the result of the combination of the tables within set.
void execute (TABLE &container, const Set< const TABLE * > &set) const final
 Returns the combination function currently used by the combinator.
std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > operations (const std::vector< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const final
 returns the set of operations to perform to make the combination
std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > operations (const Set< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const final
 Returns the combination function currently used by the combinator.
void setCombinationFunction (TABLE(*combine)(const TABLE &, const TABLE &)) final
 Changes the function used for combining two TABLES.
double nbOperations (const Set< const TABLE * > &set) const final
 returns a rough estimate of the number of operations that will be performed to compute the combination.
double nbOperations (const Set< const Sequence< const DiscreteVariable * > * > &set) const final
 Returns the combination function currently used by the combinator.
std::pair< double, doublememoryUsage (const Set< const TABLE * > &set) const final
 Returns the additional memory consumption used during the combination.
std::pair< double, doublememoryUsage (const Set< const Sequence< const DiscreteVariable * > * > &set) const final
 Returns the combination function currently used by the combinator.

Detailed Description

template<class TABLE>
class gum::MultiDimCombinationDefault< TABLE >

A class to combine efficiently several MultiDim tables.

MultiDimCombinationDefault is a class designed to combine efficiently several multidimensional objects, that is, to compute expressions like T1 op T2 op T3 op .... op Tn, where the Ti's are the multidimensional objects and op is an operator or a function taking in argument two such objects and producing a new (combined) Ti object. Note that the MultiDimCombinationDefault determines itself in which order the objects should be combined. As such, the combination operation to perform should thus be COMMUTATIVE and ASSOCIATIVE. Note also that MultiDimCombinationDefault always produce a new freshly allocated table as the result of the combinations.

By multidimensional objects, we mean of course MultiDimImplementations, but also more complex objects such as, for instance, pairs of MultiDimImplementations the first one of which being a utility function and the second one being a table of instantiations (useful, e.g., for computing MPE's) but this can also be a pair (Utility,Tensor) for the inference in an Influence Diagram. Actually, the important point for a multidimensional object to be eligible to be combined by the MultiDimCombinationDefault is:

that the object contains a method variablesSequence that returns a

sequence of Discrete variables that represent the dimensions of the multidimensional object

that there exists a function taking in arguments two such

multidimensional objects and producing a new object of the same type, which is the so-called combined result of these two objects.

To be quite generic, the MultiDimCombinationDefault takes in argument the function that produces the result of the combination of two multidimensional objects. The following code gives an example of the usage of MultiDimCombinations:

// a function used to combine two Tensor<float>'s:
Tensor<float> addTensor ( const Tensor<float>& t1,
const Tensor<float>& t2 ) {
return t1 + t2;
}
// another function used to combine two Tensor<float>'s:
Tensor<float> multTensor ( const Tensor<float>& t1,
const Tensor<float>& t2 ) {
return t1 * t2;
}
Tensor<float> t1, t2, t3;
Set< const Tensor< float >* > set;
set << &table1 << &table2 << &table3;
Tensor<float>* combined_table = Comb.execute ( set );
// change the operator to apply
Comb.setCombinationFunction ( multTensor );
Tensor<float>* combined_table2 = Comb.execute ( set );
MultiDimCombinationDefault(TABLE(*combine)(const TABLE &, const TABLE &))
Default constructor.
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Definition tensor.h:85

Definition at line 123 of file multiDimCombinationDefault.h.

Member Typedef Documentation

◆ value_type

template<class TABLE>
using gum::MultiDimCombination< TABLE >::value_type = typename TableType< TABLE >::value_type
inherited

the type of the values contained into TABLE

Definition at line 136 of file multiDimCombination.h.

Constructor & Destructor Documentation

◆ MultiDimCombinationDefault() [1/2]

template<class TABLE>
gum::MultiDimCombinationDefault< TABLE >::MultiDimCombinationDefault ( TABLE(* combine )(const TABLE &, const TABLE &))

Default constructor.

Parameters
combinea function that takes two tables in input and produces a new table which is the result of the combination of the two tables passed in argument.

Referenced by MultiDimCombinationDefault(), and clone().

Here is the caller graph for this function:

◆ MultiDimCombinationDefault() [2/2]

template<class TABLE>
gum::MultiDimCombinationDefault< TABLE >::MultiDimCombinationDefault ( const MultiDimCombinationDefault< TABLE > & )

Copy constructor.

References MultiDimCombinationDefault().

Here is the call graph for this function:

◆ ~MultiDimCombinationDefault()

template<class TABLE>
virtual gum::MultiDimCombinationDefault< TABLE >::~MultiDimCombinationDefault ( )
virtual

Destructor.

Member Function Documentation

◆ _combinedSize_()

template<class TABLE>
double gum::MultiDimCombinationDefault< TABLE >::_combinedSize_ ( const IScheduleMultiDim & table1,
const IScheduleMultiDim & table2 ) const
private

returns the domain size of the Cartesian product of the union of all the variables in seq1 and seq2.

References _combinedSize_().

Referenced by _combinedSize_().

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

◆ _freeData_()

template<class TABLE>
void gum::MultiDimCombinationDefault< TABLE >::_freeData_ ( std::vector< const IScheduleMultiDim * > & tables,
std::vector< ScheduleOperator * > & operations ) const
private

free the scheduling memory

References _freeData_(), and operations().

Referenced by _freeData_().

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

◆ clone()

template<class TABLE>
virtual MultiDimCombinationDefault< TABLE > * gum::MultiDimCombinationDefault< TABLE >::clone ( ) const
virtual

virtual constructor

Returns
A new fresh MultiDimCombinator with the same combination function.

Implements gum::MultiDimCombination< TABLE >.

References MultiDimCombinationDefault().

Here is the call graph for this function:

◆ execute() [1/2]

template<class TABLE>
TABLE * gum::MultiDimCombinationDefault< TABLE >::execute ( const Set< const TABLE * > & set) const
finalvirtual

Creates and returns the result of the combination of the tables within set.

Returns
a new freshly created TABLE which is the result of the combination of all the TABLES passed in argument
Exceptions
InvalidArgumentsNumberexception is thrown if the set passed in argument contains less than two elements.

Implements gum::MultiDimCombination< TABLE >.

Referenced by gum::prm::eliminateNode(), and gum::prm::StructuredInference< GUM_SCALAR >::posterior_().

Here is the caller graph for this function:

◆ execute() [2/2]

template<class TABLE>
void gum::MultiDimCombinationDefault< TABLE >::execute ( TABLE & container,
const Set< const TABLE * > & set ) const
finalvirtual

Returns the combination function currently used by the combinator.

Implements gum::MultiDimCombination< TABLE >.

◆ memoryUsage() [1/2]

template<class TABLE>
std::pair< double, double > gum::MultiDimCombinationDefault< TABLE >::memoryUsage ( const Set< const Sequence< const DiscreteVariable * > * > & set) const
finalvirtual

Returns the combination function currently used by the combinator.

Implements gum::MultiDimCombination< TABLE >.

References memoryUsage().

Here is the call graph for this function:

◆ memoryUsage() [2/2]

template<class TABLE>
std::pair< double, double > gum::MultiDimCombinationDefault< TABLE >::memoryUsage ( const Set< const TABLE * > & set) const
finalvirtual

Returns the additional memory consumption used during the combination.

Actually, this function does not return a precise account of the memory used by the multidimCombination but a rough estimate based on the sizes of the tables involved in the combination.

Returns
a pair of memory consumption: the first one is the maximum amount of memory used during the combination and the second one is the amount of memory still used at the end of the function ( the memory used by the resulting table ).

Implements gum::MultiDimCombination< TABLE >.

References memoryUsage().

Referenced by memoryUsage(), and memoryUsage().

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

◆ nbOperations() [1/2]

template<class TABLE>
double gum::MultiDimCombinationDefault< TABLE >::nbOperations ( const Set< const Sequence< const DiscreteVariable * > * > & set) const
finalvirtual

Returns the combination function currently used by the combinator.

Implements gum::MultiDimCombination< TABLE >.

References nbOperations().

Here is the call graph for this function:

◆ nbOperations() [2/2]

template<class TABLE>
double gum::MultiDimCombinationDefault< TABLE >::nbOperations ( const Set< const TABLE * > & set) const
finalvirtual

returns a rough estimate of the number of operations that will be performed to compute the combination.

Implements gum::MultiDimCombination< TABLE >.

References nbOperations().

Referenced by nbOperations(), and nbOperations().

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

◆ operations() [1/2]

template<class TABLE>
std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > gum::MultiDimCombinationDefault< TABLE >::operations ( const Set< const IScheduleMultiDim * > & set,
const bool is_result_persistent = false ) const
finalvirtual

Returns the combination function currently used by the combinator.

Implements gum::MultiDimCombination< TABLE >.

References gum::MultiDimCombination< TABLE >::MultiDimCombination(), operations(), and gum::MultiDimCombination< TABLE >::schedule().

Here is the call graph for this function:

◆ operations() [2/2]

template<class TABLE>
std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > gum::MultiDimCombinationDefault< TABLE >::operations ( const std::vector< const IScheduleMultiDim * > & set,
const bool is_result_persistent = false ) const
finalvirtual

returns the set of operations to perform to make the combination

Executing sequentially the set of operations returned is guaranteed to produce the right result.

Warning
MultiDimCombinations always produce a new freshly allocated resulting table

Implements gum::MultiDimCombination< TABLE >.

Referenced by _freeData_(), and operations().

Here is the caller graph for this function:

◆ schedule() [1/2]

template<class TABLE>
const IScheduleMultiDim * gum::MultiDimCombination< TABLE >::schedule ( Schedule & schedule,
const Set< const IScheduleMultiDim * > & set,
const bool is_result_persistent = false ) const
inherited

add to a given schedule the set of operations needed to perform the combination

Warning
whenever this method is executed, it is assumed that the ScheduleMultiDim already belong to the schedule.
MultiDimCombinations always produce a new freshly allocated resulting table

References schedule().

Referenced by gum::MultiDimCombinationDefault< TABLE >::operations(), schedule(), and schedule().

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

◆ schedule() [2/2]

template<class TABLE>
const IScheduleMultiDim * gum::MultiDimCombination< TABLE >::schedule ( Schedule & schedule,
const std::vector< const IScheduleMultiDim * > & set,
const bool is_result_persistent = false ) const
inherited

returns the combination function currently used by the combinator

References schedule().

Here is the call graph for this function:

◆ setCombinationFunction()

template<class TABLE>
void gum::MultiDimCombinationDefault< TABLE >::setCombinationFunction ( TABLE(* combine )(const TABLE &, const TABLE &))
finalvirtual

Changes the function used for combining two TABLES.

Implements gum::MultiDimCombination< TABLE >.

References setCombinationFunction().

Referenced by setCombinationFunction().

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

Member Data Documentation

◆ _combine_

template<class TABLE>
TABLE(* gum::MultiDimCombinationDefault< TABLE >::_combine_) (const TABLE &t1, const TABLE &t2)
private

The function used to combine two tables.

Definition at line 219 of file multiDimCombinationDefault.h.

◆ combinationFunction

template<class TABLE>
TABLE(*)(const TABLE &, const TABLE &) gum::MultiDimCombinationDefault< TABLE >::combinationFunction()

Returns the combination function currently used by the combinator.

Definition at line 191 of file multiDimCombinationDefault.h.


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