Public Member Functions | Private Attributes
mbl_random_n_from_m Class Reference

Class to generate arrays of n integers chosen without replacement from [0,m-1]. More...

#include <mbl_random_n_from_m.h>

List of all members.

Public Member Functions

 mbl_random_n_from_m ()
 Dflt ctor.
void reseed (long new_seed)
 Set seed of random number generator.
void choose_n_from_m (vcl_vector< unsigned > &chosen, unsigned int n, unsigned int m)
 Select n integers from range [0,m-1], without replacement.
void choose_n_from_m (vcl_vector< unsigned > &chosen, vcl_vector< unsigned > &not_chosen, unsigned int n, unsigned int m)
 Select n integers from range [0,m-1], without replacement.
void choose_n_from_m (vcl_vector< int > &chosen, unsigned int n, unsigned int m)
 Select n integers from range [0,m-1], without replacement.
void choose_n_from_m (vcl_vector< int > &chosen, vcl_vector< int > &not_chosen, unsigned int n, unsigned int m)
 Select n integers from range [0,m-1], without replacement.

Private Attributes

vnl_random mz_random_
vcl_vector< bool > used_

Detailed Description

Class to generate arrays of n integers chosen without replacement from [0,m-1].

Definition at line 12 of file mbl_random_n_from_m.h.


Constructor & Destructor Documentation

mbl_random_n_from_m::mbl_random_n_from_m ( )

Dflt ctor.

Definition at line 10 of file mbl_random_n_from_m.cxx.


Member Function Documentation

void mbl_random_n_from_m::choose_n_from_m ( vcl_vector< unsigned > &  chosen,
unsigned int  n,
unsigned int  m 
)

Select n integers from range [0,m-1], without replacement.

ie all different n is required to be <= m; otherwise, the function abort()s. But n might be 0, in which case an empty list is returned.

Return values:
chosenArray [0,n-1] of chosen elements

Definition at line 20 of file mbl_random_n_from_m.cxx.

void mbl_random_n_from_m::choose_n_from_m ( vcl_vector< unsigned > &  chosen,
vcl_vector< unsigned > &  not_chosen,
unsigned int  n,
unsigned int  m 
)

Select n integers from range [0,m-1], without replacement.

ie all different n is required to be <= m; otherwise, the function abort()s. But n might be 0, in which case an empty list is returned.

Return values:
chosenArray [0,n-1] of chosen elements
not_chosenArray[0,m-n-1] of not chosen elements

Definition at line 56 of file mbl_random_n_from_m.cxx.

void mbl_random_n_from_m::choose_n_from_m ( vcl_vector< int > &  chosen,
unsigned int  n,
unsigned int  m 
)

Select n integers from range [0,m-1], without replacement.

ie all different n is required to be <= m; otherwise, the function abort()s. But n might be 0, in which case an empty list is returned.

Return values:
chosenArray [0,n-1] of chosen elements

Definition at line 72 of file mbl_random_n_from_m.cxx.

void mbl_random_n_from_m::choose_n_from_m ( vcl_vector< int > &  chosen,
vcl_vector< int > &  not_chosen,
unsigned int  n,
unsigned int  m 
)

Select n integers from range [0,m-1], without replacement.

ie all different n is required to be <= m; otherwise, the function abort()s. But n might be 0, in which case an empty list is returned.

Return values:
chosenArray [0,n-1] of chosen elements
not_chosenArray[0,m-n-1] of not chosen elements

Definition at line 108 of file mbl_random_n_from_m.cxx.

void mbl_random_n_from_m::reseed ( long  new_seed)

Set seed of random number generator.

Definition at line 14 of file mbl_random_n_from_m.cxx.


Member Data Documentation

Definition at line 15 of file mbl_random_n_from_m.h.

vcl_vector<bool> mbl_random_n_from_m::used_ [private]

Definition at line 16 of file mbl_random_n_from_m.h.


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