dai::Permute Class Reference

Tool for calculating permutations of linear indices of multi-dimensional arrays. More...

#include <dai/index.h>

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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]

Returns const reference to the permutation.

Examples:
example_permute.cpp.
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.


Member Data Documentation

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.


The documentation for this class was generated from the following file:
Generated on Sun May 9 16:51:36 2010 for libDAI by  doxygen 1.6.3