Tool for calculating permutations of linear indices of multi-dimensional arrays.
More...
#include <dai/index.h>
|
| Permute () |
| Default constructor. More...
|
|
| Permute (const std::vector< size_t > &rs, const std::vector< size_t > &sigma) |
| Construct from vector of index ranges and permutation. More...
|
|
| Permute (const std::vector< Var > &vars, bool reverse=false) |
| Construct from vector of variables. More...
|
|
size_t | convertLinearIndex (size_t li) const |
| Calculates a permuted linear index. More...
|
|
const std::vector< size_t > & | sigma () const |
| Returns constant reference to the permutation. More...
|
|
std::vector< size_t > & | sigma () |
| Returns reference to the permutation. More...
|
|
const std::vector< size_t > & | ranges () |
| Returns constant reference to the dimensionality vector. More...
|
|
size_t | operator[] (size_t i) const |
| Returns the result of applying the permutation on i. More...
|
|
Permute | inverse () const |
| Returns the inverse permutation. More...
|
|
|
std::vector< size_t > | _ranges |
| Stores the number of possible values of all indices. More...
|
|
std::vector< size_t > | _sigma |
| Stores the permutation. More...
|
|
Tool for calculating permutations of linear indices of multi-dimensional arrays.
- Note
- This is mainly useful for converting indices into multi-dimensional arrays corresponding to joint states of variables to and from the canonical ordering used in libDAI.
- Examples:
- example_permute.cpp.
dai::Permute::Permute |
( |
| ) |
|
|
inline |
dai::Permute::Permute |
( |
const std::vector< size_t > & |
rs, |
|
|
const std::vector< size_t > & |
sigma |
|
) |
| |
|
inline |
Construct from vector of index ranges and permutation.
dai::Permute::Permute |
( |
const std::vector< Var > & |
vars, |
|
|
bool |
reverse = false |
|
) |
| |
|
inline |
Construct from vector of variables.
The implied permutation maps the index of each variable in vars according to the canonical ordering (i.e., sorted ascendingly according to their label) to the index it has in vars. If reverse == true
, reverses the indexing in vars first.
size_t dai::Permute::convertLinearIndex |
( |
size_t |
li | ) |
const |
|
inline |
Calculates a permuted linear index.
Converts the linear index li to a vector index, permutes its components, and converts it back to a linear index.
- Examples:
- example_permute.cpp.
const std::vector<size_t>& dai::Permute::sigma |
( |
| ) |
const |
|
inline |
std::vector<size_t>& dai::Permute::sigma |
( |
| ) |
|
|
inline |
Returns reference to the permutation.
const std::vector<size_t>& dai::Permute::ranges |
( |
| ) |
|
|
inline |
Returns constant reference to the dimensionality vector.
size_t dai::Permute::operator[] |
( |
size_t |
i | ) |
const |
|
inline |
Returns the result of applying the permutation on i.
Permute dai::Permute::inverse |
( |
| ) |
const |
|
inline |
Returns the inverse permutation.
std::vector<size_t> dai::Permute::_ranges |
|
private |
Stores the number of possible values of all indices.
std::vector<size_t> dai::Permute::_sigma |
|
private |
The documentation for this class was generated from the following file: