Public Member Functions | Protected Attributes | List of all members
o2scl::permutation Class Reference

A class for representing permutations. More...

#include <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. More...
int allocate (size_t dim)
 Allocate memory for a permutation of size dim.
int free ()
 Free the memory. More...
void resize (size_t dim)
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)

Protected Attributes

size_t size_
boost::numeric::ublas::unbounded_array< size_t > data

Detailed Description

To apply a permutation to a user-specified vector, see o2scl::permutation::apply().

Definition at line 70 of file permutation.h.

Member Function Documentation

◆ free()

int o2scl::permutation::free ( )

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

Definition at line 233 of file permutation.h.

◆ size()

size_t o2scl::permutation::size ( ) const

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

Definition at line 213 of file permutation.h.

The documentation for this class was generated from the following file:

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