gslmm::permutation Class Reference
[Permutations .]

#include <gslmm/permutation/permutation.hh>

Collaboration diagram for gslmm::permutation:

Collaboration graph
[legend]
List of all members.

Detailed Description

Permutation representation.

A permutation $ p $ is represented by an array of $ n $ integers in the range $ 0 \dots n-1 $, where each value $ p_i $ occurs once and only once.

Note that this is not a template, as it only makes sense for integer values.

Todo:
Should I leave in the put-to operator?
Examples:

linear/linear-test.cc, and permutation/permutation-test.cc.


Public Member Functions

 permutation (size_t n, bool id=true)
 permutation (const permutation &o)
virtual ~permutation ()
size_t size () const
bool is_valid () const
bool is_canonical () const
size_t & operator[] (const size_t i)
const size_t & operator[] (const size_t i) const
void swap (const size_t i, const size_t j)
void identity ()
void reverse ()
permutation inverse ()
bool next ()
bool previous ()
size_t inversions () const
size_t cycles () const
permutation canonical ()
permutation linear ()
template<typename Type>
void permute (Type data, size_t n, size_t stride=1, bool inv=false) const
template<typename Type>
void permute (vector< Type > &v, bool inv=false) const
template<typename Type>
void permute (complex< Type > &c, bool inv=false) const
permutationoperator= (const permutation &o)
permutationoperator *= (const permutation &o)
template<>
void permute (double *data, size_t n, size_t stride, bool inv) const
template<>
void permute (long double *data, size_t n, size_t stride, bool inv) const
template<>
void permute (float *data, size_t n, size_t stride, bool inv) const
template<>
void permute (long *data, size_t n, size_t stride, bool inv) const
template<>
void permute (unsigned long *data, size_t n, size_t stride, bool inv) const
template<>
void permute (int *data, size_t n, size_t stride, bool inv) const
template<>
void permute (unsigned int *data, size_t n, size_t stride, bool inv) const
template<>
void permute (short *data, size_t n, size_t stride, bool inv) const
template<>
void permute (unsigned short *data, size_t n, size_t stride, bool inv) const
template<>
void permute (char *data, size_t n, size_t stride, bool inv) const
template<>
void permute (unsigned char *data, size_t n, size_t stride, bool inv) const
template<>
void permute (gslmm::vector< double > &v, bool inv) const
template<>
void permute (gslmm::vector< long double > &v, bool inv) const
template<>
void permute (gslmm::vector< float > &v, bool inv) const
template<>
void permute (gslmm::vector< long > &v, bool inv) const
template<>
void permute (gslmm::vector< unsigned long > &v, bool inv) const
template<>
void permute (gslmm::vector< int > &v, bool inv) const
template<>
void permute (gslmm::vector< unsigned int > &v, bool inv) const
template<>
void permute (gslmm::vector< short > &v, bool inv) const
template<>
void permute (gslmm::vector< unsigned short > &v, bool inv) const
template<>
void permute (gslmm::vector< char > &v, bool inv) const
template<>
void permute (gslmm::vector< unsigned char > &v, bool inv) const

Public Attributes

gsl_permutation * _permutation

Protected Attributes

bool _canonical

Friends

permutation operator * (const permutation &lhs, const permutation &rhs)


Constructor & Destructor Documentation

gslmm::permutation::permutation size_t  n,
bool  id = true
[inline]
 

Constructor.

Parameters:
n The size of the permutation
id if true, initialise this to identity, otherwise, it's not initialised at all.

gslmm::permutation::permutation const permutation o  )  [inline]
 

Copy constructor.

gslmm::permutation::~permutation  )  [inline, virtual]
 

Destructor.


Member Function Documentation

permutation gslmm::permutation::canonical  )  [inline]
 

Return canonical form of this permutation.

If the permutation is already on canonical form, this is just a copy.

size_t gslmm::permutation::cycles  )  const [inline]
 

Count the number of cycles.

void gslmm::permutation::identity  )  [inline]
 

Make this permutation the identity permutation.

permutation gslmm::permutation::inverse  )  [inline]
 

Get the inverse permutation of this.

size_t gslmm::permutation::inversions  )  const [inline]
 

Count number of inversions.

bool gslmm::permutation::is_canonical  )  const [inline]
 

Check if this is in canonical form or not.

bool gslmm::permutation::is_valid  )  const [inline]
 

Check if this is a valid permutation.

permutation gslmm::permutation::linear  )  [inline]
 

Return linear form of this permutation.

If the permutation is already on linear form, this is just a copy.

bool gslmm::permutation::next  )  [inline]
 

Advances this permutation to the next permutation in lexicographic order.

Starting with the identity permutation and repeatedly applying this operation will iterate through all possible permutations of a given order.

Returns:
true if the permutation was advanced. If no further permutations are available, returns false and leaves the permutation unmodified.
Examples:
permutation/permutation-test.cc.

permutation & gslmm::permutation::operator *= const permutation o  )  [inline]
 

* assignment operator

permutation & gslmm::permutation::operator= const permutation o  )  [inline]
 

Assignment operator.

const size_t & gslmm::permutation::operator[] const size_t  i  )  const [inline]
 

Access an element in the permutation.

size_t & gslmm::permutation::operator[] const size_t  i  )  [inline]
 

Access an element in the permutation.

template<>
void gslmm::permutation::permute gslmm::vector< unsigned char > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< char > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< unsigned short > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< short > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< unsigned int > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< int > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< unsigned long > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< long > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< float > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< long double > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute gslmm::vector< double > &  v,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute unsigned char *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute char *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute unsigned short *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute short *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute unsigned int *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute int *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute unsigned long *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute long *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute float *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute long double *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<>
void gslmm::permutation::permute double *  data,
size_t  n,
size_t  stride,
bool  inv
const [inline]
 

template<typename Type>
void gslmm::permutation::permute complex< Type > &  c,
bool  inv = false
const [inline]
 

Permute the complex number c.

template<typename Type>
void gslmm::permutation::permute vector< Type > &  v,
bool  inv = false
const [inline]
 

Permute the vector v.

template<typename Type>
void gslmm::permutation::permute Type  data,
size_t  n,
size_t  stride = 1,
bool  inv = false
const [inline]
 

Permute the array data with stride stride.

Parameters:
data The array to permute.
n Size of data array
stride The stride in the array
inv if true, apply the inverse permutation.
Examples:
linear/linear-test.cc, and permutation/permutation-test.cc.

bool gslmm::permutation::previous  )  [inline]
 

This function steps backwards from this permutation to the previous permutation in lexicographic order.

Returns:
see also gslmm::permutation::next
Examples:
permutation/permutation-test.cc.

void gslmm::permutation::reverse  )  [inline]
 

Turn this permutation into it's reverse.

size_t gslmm::permutation::size  )  const [inline]
 

Get the size of this permutation.

void gslmm::permutation::swap const size_t  i,
const size_t  j
[inline]
 

Swap element i and j.


Friends And Related Function Documentation

permutation operator * const permutation lhs,
const permutation rhs
[friend]
 


Member Data Documentation

bool gslmm::permutation::_canonical [protected]
 

Wether this is in canonical form or not.

gsl_permutation* gslmm::permutation::_permutation
 

The underlying GSL data.


The documentation for this class was generated from the following file:
Top of page Last update Tue May 9 10:11:32 2006
Christian Holm
Created by DoxyGen 1.4.6