Tool for calculating permutations of linear indices of multi-dimensional arrays. More...
#include <dai/index.h>
Public Member Functions | |
Permute () | |
Default constructor. | |
Permute (const std::vector< size_t > &rs, const std::vector< size_t > &sigma) | |
Construct from vector of index ranges and permutation. | |
Permute (const std::vector< Var > &vars) | |
Construct from vector of variables. | |
size_t | convertLinearIndex (size_t li) const |
Calculates a permuted linear index. | |
const std::vector< size_t > & | sigma () const |
Returns const reference to the permutation. | |
std::vector< size_t > & | sigma () |
Returns reference to the permutation. | |
size_t | operator[] (size_t i) const |
Returns the result of applying the permutation on i. | |
Private Attributes | |
std::vector< size_t > | _ranges |
Stores the number of possible values of all indices. | |
std::vector< size_t > | _sigma |
Stores the permutation. |
Tool for calculating permutations of linear indices of multi-dimensional arrays.
dai::Permute::Permute | ( | ) | [inline] |
Default constructor.
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 | ) | [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.
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.
const std::vector<size_t>& dai::Permute::sigma | ( | ) | const [inline] |
Returns const reference to the permutation.
std::vector<size_t>& dai::Permute::sigma | ( | ) | [inline] |
Returns reference to the permutation.
size_t dai::Permute::operator[] | ( | size_t | i | ) | const [inline] |
Returns the result of applying the permutation on i.
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] |
Stores the permutation.