Paraperm
 All Classes Namespaces Functions Typedefs
Public Types | Public Member Functions
Paraperm< T > Class Template Reference

Parallel generator of random permutaitons. More...

#include <paraperm/Paraperm.h>

List of all members.

Public Types

typedef T value_type
 Integer data type for permutation elements. Matches template parameter T.
typedef std::vector< T > vector_type
 Standard library vector type with elemetns of type value_type.

Public Member Functions

 ~Paraperm ()
 The destructor.
void generate (MPI_Comm comm, T n)
 Parallelly generates random permutation.
const vector_typeperm () const
 Returns local array with generated permutation values.
pos () const
 Returns argument of the first local permutation value.
count () const
 Returns number of local permutation values.

Detailed Description

template<typename T = uintmax_t>
class paraperm::Paraperm< T >

Parallel generator of random permutaitons.

Template Parameters:
TInteger data type for permutation elements. Default value is uintmax_t.

The algorithm is described in detail in [1].

The intended usage of the class consists of the following steps running within all MPI processes:

  1. An instance of the class is defined:
  2. Random permutation of n elements is generated over an MPI communicator:
     paraperm.generate(MPI_COMM_WORLD, n);
    
  3. Permutation elements within all MPI processes are available as follows:
     const paraperm::Paraperm<>::vector_type& = paraperm.elements();
     const paraperm::Paraperm<>::value_type pos = paraperm.pos(); // argument of the first local permutation value
     const paraperm::Paraperm<>::value_type count = paraperm.count(); // number of local permutaion values
    

Constructor & Destructor Documentation

~Paraperm ( )

The destructor.

Release implementation resources.


Member Function Documentation

void generate ( MPI_Comm  comm,
n 
)

Parallelly generates random permutation.

Parameters:
[in]comma valid MPI communicator
[in]nnumber of elements of the permutation

Generation of the random permutation of a set of integer numbers from 0 to (n - 1). After the generation, these elements are available via the perm() member function.

Must be called collectively within all MPI processes that belongs to the comm communicator!

const vector_type & perm ( ) const

Returns local array with generated permutation values.

Returns:
vector of type vector_type with local generated permutation values

The argument of the first local value is provided by the pos() member function. The number of local permutation values is provided by the count() member function.

T pos ( ) const

Returns argument of the first local permutation value.

Returns:
argument of the first local permutation value
T count ( ) const

Returns number of local permutation values.

Returns:
the number of local permutation values

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Typedefs