Parallel generator of random permutaitons. More...
#include <paraperm/Paraperm.h>
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_type & | perm () const |
Returns local array with generated permutation values. | |
T | pos () const |
Returns argument of the first local permutation value. | |
T | count () const |
Returns number of local permutation values. |
Parallel generator of random permutaitons.
T | Integer 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:
paraperm::Paraperm<> paraperm;
n
elements is generated over an MPI communicator: paraperm.generate(MPI_COMM_WORLD, n);
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
~Paraperm | ( | ) |
The destructor.
Release implementation resources.
void generate | ( | MPI_Comm | comm, |
T | n | ||
) |
Parallelly generates random permutation.
[in] | comm | a valid MPI communicator |
[in] | n | number 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.
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.
T count | ( | ) | const |
Returns number of local permutation values.