Object-oriented Scientific Computing Library: Version 0.910
Public Member Functions
permutation Class Reference

A class for representing permutations. More...

#include <permutation.h>


Detailed Description

A class for representing permutations. This permutation class is completely compatible with the GSL permutation object since it is derived from gsl_permutation_struct (and thus also gsl_permutation). For example, the last line in the code below is a trivial upcast, and permitted since gsl_permutation is a base type of this class.

      permuation p(5);
      p.init();
      gsl_permutation *gp=&p;

See also the Permutations section of the User's guide.

Definition at line 84 of file permutation.h.

Public Member Functions

 permutation (size_t dim=0)
 Create a permutation of size dim.
size_t & operator[] (size_t i)
 Array-like indexing.
const size_t & operator[] (size_t i) const
 Array-like indexing.
size_t & operator() (size_t i)
 Array-like indexing.
const size_t & operator() (size_t i) const
 Array-like indexing.
size_t get (size_t i) const
 Get (with optional range-checking)
int set (size_t i, size_t val)
 Set (with optional range-checking)
int init ()
 Initialize permutation to the identity.
size_t size () const
 Return permutation size.
int allocate (size_t dim)
 Allocate memory for a permutation of size dim.
int free ()
 Free the memory.
int swap (const size_t i, const size_t j)
 Swap two elements of a permutation.
bool valid () const
 Check to see that a permutation is valid.
int reverse ()
 Reverse the permutation.
permutation inverse () const
 Compute the inverse of a permutation.
template<class vec_t >
int apply (vec_t &v) const
 Apply the permutation to a vector.
template<class vec_t >
int apply_inverse (vec_t &v) const
 Apply the inverse permutation to a vector.
Copy constructors
 permutation (const permutation &v)
permutationoperator= (const permutation &v)

Member Function Documentation

size_t permutation::size ( ) const [inline]

If no memory has been allocated, this will quietly return zero.

Definition at line 234 of file permutation.h.

int permutation::free ( ) [inline]

This function will safely do nothing if used without first allocating memory or if called multiple times in succession.

Definition at line 255 of file permutation.h.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.