![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
A class to combine efficiently several MultiDim tables. More...
#include <agrum/base/multidim/operators/multiDimCombinationDefault.h>
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 IScheduleMultiDim * | schedule (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 IScheduleMultiDim * | schedule (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, double > | memoryUsage (const Set< const TABLE * > &set) const final |
| Returns the additional memory consumption used during the combination. | |
| std::pair< double, double > | memoryUsage (const Set< const Sequence< const DiscreteVariable * > * > &set) const final |
| Returns the combination function currently used by the combinator. | |
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:
sequence of Discrete variables that represent the dimensions of the multidimensional object
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:
Definition at line 123 of file multiDimCombinationDefault.h.
|
inherited |
the type of the values contained into TABLE
Definition at line 136 of file multiDimCombination.h.
| gum::MultiDimCombinationDefault< TABLE >::MultiDimCombinationDefault | ( | TABLE(* | combine )(const TABLE &, const TABLE &) | ) |
Default constructor.
| combine | a 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().
| gum::MultiDimCombinationDefault< TABLE >::MultiDimCombinationDefault | ( | const MultiDimCombinationDefault< TABLE > & | ) |
Copy constructor.
References MultiDimCombinationDefault().
|
virtual |
Destructor.
|
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_().
|
private |
free the scheduling memory
References _freeData_(), and operations().
Referenced by _freeData_().
|
virtual |
virtual constructor
Implements gum::MultiDimCombination< TABLE >.
References MultiDimCombinationDefault().
|
finalvirtual |
Creates and returns the result of the combination of the tables within set.
| InvalidArgumentsNumber | exception 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_().
|
finalvirtual |
Returns the combination function currently used by the combinator.
Implements gum::MultiDimCombination< TABLE >.
|
finalvirtual |
Returns the combination function currently used by the combinator.
Implements gum::MultiDimCombination< TABLE >.
References memoryUsage().
|
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.
Implements gum::MultiDimCombination< TABLE >.
References memoryUsage().
Referenced by memoryUsage(), and memoryUsage().
|
finalvirtual |
Returns the combination function currently used by the combinator.
Implements gum::MultiDimCombination< TABLE >.
References nbOperations().
|
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().
|
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().
|
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.
Implements gum::MultiDimCombination< TABLE >.
Referenced by _freeData_(), and operations().
|
inherited |
add to a given schedule the set of operations needed to perform the combination
References schedule().
Referenced by gum::MultiDimCombinationDefault< TABLE >::operations(), schedule(), and schedule().
|
inherited |
returns the combination function currently used by the combinator
References schedule().
|
finalvirtual |
Changes the function used for combining two TABLES.
Implements gum::MultiDimCombination< TABLE >.
References setCombinationFunction().
Referenced by setCombinationFunction().
|
private |
The function used to combine two tables.
Definition at line 219 of file multiDimCombinationDefault.h.
| 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.