#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, bool reverse=false) | |
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 constant reference to the permutation. | |
std::vector< size_t > & | sigma () |
Returns reference to the permutation. | |
const std::vector< size_t > & | ranges () |
Returns constant reference to the dimensionality vector. | |
size_t | operator[] (size_t i) const |
Returns the result of applying the permutation on i. | |
Permute | inverse () const |
Returns the inverse permutation. | |
Private Attributes | |
std::vector< size_t > | _ranges |
Stores the number of possible values of all indices. | |
std::vector< size_t > | _sigma |
Stores the permutation. |
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, | |
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.
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] |
Stores the permutation.