cgv
Loading...
Searching...
No Matches
cgv::math::random Struct Reference

High quality random number generator, which is a little bit slower than typical random number generators but with a period about 3.138 x 10^57. More...

#include <random.h>

Public Member Functions

void set_seed (unsigned long long seed)
 set a new seed
 
 random ()
 standard constructor uses system time as random seed
 
 random (unsigned long long seed)
 constructor initializes random generator with given seed
 
void uniform (unsigned long long &rv)
 generates 64bit pseudo random integer
 
void uniform (unsigned int &rv)
 generates a 32bit pseudo random unsigned integer
 
void uniform (int &rv)
 generates a 32bit pseudo random signed integer
 
void uniform (long &rv)
 generates a 32bit pseudo random signed integer
 
void uniform (long long &rv)
 generates a 64bit pseudo random signed integer
 
void uniform (bool &rv)
 generates a pseudo random boolean
 
void uniform (const unsigned min, const unsigned max, unsigned &rv)
 generates a pseudo random integer between min and max
 
void uniform (const int min, const int max, int &rv)
 generates a pseudo random integer between min and max
 
void uniform (double &rv)
 generates a pseudo random double-precision floating point number uniformly distributed between 0 and 1
 
void uniform (const double min, const double max, double &rv)
 generates a pseudo random double-precision floating point number uniformly distributed between min and max
 
void uniform (float &rv)
 generates a pseudo random single-precision floating point number uniformly distributed between 0 and 1
 
void uniform (const float min, const float max, float &rv)
 generates a pseudo random single-precision floating point number uniformly distributed between min and max
 
void uniform (vec< float > &rv)
 generates a pseudo random single precision vector with uniformly distribute components between 0 and 1
 
void uniform (const float min, const float max, vec< float > &rv)
 generates a pseudo random single precision vector with uniformly distribute components between min and max
 
void uniform (vec< double > &rv)
 generates a pseudo random double precision vector with uniformly distribute components between 0 and 1
 
void uniform (const double min, const double max, vec< double > &rv)
 generates a pseudo random double precision vector with uniformly distribute components between min and max
 
template<typename T , cgv::type::uint32_type N>
void uniform (cgv::math::fvec< T, N > &rv)
 generates a pseudo random single precision fixed-size vector with uniformly distribute components between 0 and 1
 
template<typename T , cgv::type::uint32_type N>
void uniform (const float min, const float max, cgv::math::fvec< T, N > &rv)
 generates a pseudo random single precision fixed-size vector with uniformly distribute components between min and max
 
void uniform (mat< float > &rv)
 generates a pseudo random single precision full matrix with uniformly distribute components between 0 and 1
 
void uniform (const float min, const float max, mat< float > &rv)
 generates a pseudo random single precision full matrix with uniformly distribute components between min and max
 
void uniform (perm_mat &rv)
 generates a pseudo random permutation matrix
 
void uniform (up_tri_mat< float > &rv)
 generates a pseudo random single precision upper triangular matrix with uniformly distribute components between 0 and 1
 
void uniform (const float min, const float max, up_tri_mat< float > &rv)
 generates a pseudo random single precision upper triangular matrix with uniformly distribute components between min and max
 
void uniform (up_tri_mat< double > &rv)
 generates a pseudo random double precision upper triangular matrix with uniformly distribute components between 0 and 1
 
void uniform (const double min, const double max, up_tri_mat< double > &rv)
 generates a pseudo random double precision upper triangular matrix with uniformly distribute components between min and max
 
void uniform (low_tri_mat< float > &rv)
 generates a pseudo random single precision lower triangular matrix with uniformly distribute components between 0 and 1
 
void uniform (const float min, const float max, low_tri_mat< float > &rv)
 generates a pseudo random single precision lower triangular matrix with uniformly distribute components between min and max
 
void uniform (low_tri_mat< double > &rv)
 generates a pseudo random double precision lower triangular matrix with uniformly distribute components between 0 and 1
 
void uniform (const double min, const double max, low_tri_mat< double > &rv)
 generates a pseudo random double precision lower triangular matrix with uniformly distribute components between min and max
 
void uniform (diag_mat< float > &rv)
 generates a pseudo random single precision diagonal matrix with uniformly distribute components between 0 and 1
 
void uniform (const float min, const float max, diag_mat< float > &rv)
 generates a pseudo random single precision diagonal matrix with uniformly distribute components between min and max
 
void uniform (diag_mat< double > &rv)
 generates a pseudo random double precision diagonal matrix with uniformly distribute components between 0 and 1
 
void uniform (const double min, const double max, diag_mat< double > &rv)
 generates a pseudo random double precision diagonal matrix with uniformly distribute components between min and max
 
void uniform (mat< double > &rv)
 generates a pseudo random double full matrix with uniformly distribute components between 0 and 1
 
void uniform (const double min, const double max, mat< double > &rv)
 generates a pseudo random double full matrix with uniformly distribute components between min and max
 
void normal (double &rv)
 generates a normal deviate double-precision floating point value with mu = 0 and sigma = 1
 
void normal (float &rv)
 generates a normal deviate single-precision floating point value with mu = 0 and sigma = 1
 
void normal (const double mu, const double sigma, double &rv)
 generates a normal deviate double-precision floating point value with mu and sigma
 
void normal (const float mu, const float sigma, float &rv)
 generates a normal deviate single-precision floating point value with mu and sigma
 
void uniform_direction (vec< float > &v)
 generates a single precision random direction (uniformly distributed position on the unit sphere)
 
void uniform_direction (vec< double > &v)
 generates a double precision random direction (uniformly distributed position on the unit sphere)
 
template<typename T >
void uniform_quat_orientation (quaternion< T > &q)
 generates a random orientation represented as a unit quaternion
 
template<typename T >
void uniform_orientation (fmat< T, 3, 3 > &m)
 generates a single precision random orientation represented as a rotation matrix
 
template<typename T >
void uniform_orientation (fmat< T, 4, 4 > &m)
 generates a single precision random orientation represented as a homogeneous rotation matrix
 
void uniform_point_in_unit_box (vec< double > &p)
 creates an uniform distributed random point in unit box (0,0,...,0)..(1,1,...,1); if dim(p)=0, it is set to 3
 
void uniform_point_in_box (const vec< double > &minp, const vec< double > &maxp, vec< double > &p)
 creates an uniform distributed random point in box minp..maxp
 
void uniform_point_in_unit_ball (vec< double > &p)
 creates an uniform distributed random point in unit sphere
 
void uniform_point_in_triangle (const vec< double > &p1, const vec< double > &p2, const vec< double > &p3, vec< double > p)
 creates an uniform distributed random point in triangle p1,p2,p3
 
void uniform_point_on_sphere (const vec< double > &center, const double &radius, vec< double > &p)
 creates an uniform distributed random point on the surface of a sphere with given center and radius
 
void uniform_nchoosek (unsigned n, unsigned k, vec< unsigned > &indices)
 creates a vector of k unique indices drawn from 0 to n-1
 

Detailed Description

High quality random number generator, which is a little bit slower than typical random number generators but with a period about 3.138 x 10^57.

Definition at line 26 of file random.h.

Constructor & Destructor Documentation

◆ random() [1/2]

cgv::math::random::random ( )
inline

standard constructor uses system time as random seed

Definition at line 45 of file random.h.

References set_seed().

◆ random() [2/2]

cgv::math::random::random ( unsigned long long  seed)
inline

constructor initializes random generator with given seed

Definition at line 52 of file random.h.

References set_seed().

Member Function Documentation

◆ normal() [1/4]

void cgv::math::random::normal ( const double  mu,
const double  sigma,
double &  rv 
)
inline

generates a normal deviate double-precision floating point value with mu and sigma

Definition at line 376 of file random.h.

References normal().

◆ normal() [2/4]

void cgv::math::random::normal ( const float  mu,
const float  sigma,
float &  rv 
)
inline

generates a normal deviate single-precision floating point value with mu and sigma

Definition at line 384 of file random.h.

References normal().

◆ normal() [3/4]

void cgv::math::random::normal ( double &  rv)
inline

generates a normal deviate double-precision floating point value with mu = 0 and sigma = 1

Definition at line 342 of file random.h.

References uniform().

Referenced by normal(), normal(), normal(), uniform_direction(), uniform_direction(), and uniform_point_on_sphere().

◆ normal() [4/4]

void cgv::math::random::normal ( float &  rv)
inline

generates a normal deviate single-precision floating point value with mu = 0 and sigma = 1

Definition at line 368 of file random.h.

References normal().

◆ set_seed()

void cgv::math::random::set_seed ( unsigned long long  seed)
inline

set a new seed

Definition at line 33 of file random.h.

References uniform().

Referenced by random(), and random().

◆ uniform() [1/35]

void cgv::math::random::uniform ( bool &  rv)
inline

generates a pseudo random boolean

Definition at line 100 of file random.h.

References uniform().

◆ uniform() [2/35]

template<typename T , cgv::type::uint32_type N>
void cgv::math::random::uniform ( cgv::math::fvec< T, N > &  rv)
inline

generates a pseudo random single precision fixed-size vector with uniformly distribute components between 0 and 1

Definition at line 186 of file random.h.

References uniform().

◆ uniform() [3/35]

void cgv::math::random::uniform ( const double  min,
const double  max,
diag_mat< double > &  rv 
)
inline

generates a pseudo random double precision diagonal matrix with uniformly distribute components between min and max

Definition at line 316 of file random.h.

References cgv::math::diag_mat< T >::nrows(), and uniform().

◆ uniform() [4/35]

void cgv::math::random::uniform ( const double  min,
const double  max,
double &  rv 
)
inline

generates a pseudo random double-precision floating point number uniformly distributed between min and max

Definition at line 131 of file random.h.

References uniform().

◆ uniform() [5/35]

void cgv::math::random::uniform ( const double  min,
const double  max,
low_tri_mat< double > &  rv 
)
inline

generates a pseudo random double precision lower triangular matrix with uniformly distribute components between min and max

Definition at line 287 of file random.h.

References uniform().

◆ uniform() [6/35]

void cgv::math::random::uniform ( const double  min,
const double  max,
mat< double > &  rv 
)
inline

generates a pseudo random double full matrix with uniformly distribute components between min and max

Definition at line 332 of file random.h.

References cgv::math::mat< T >::ncols(), cgv::math::mat< T >::nrows(), and uniform().

◆ uniform() [7/35]

void cgv::math::random::uniform ( const double  min,
const double  max,
up_tri_mat< double > &  rv 
)
inline

generates a pseudo random double precision upper triangular matrix with uniformly distribute components between min and max

Definition at line 255 of file random.h.

References uniform().

◆ uniform() [8/35]

void cgv::math::random::uniform ( const double  min,
const double  max,
vec< double > &  rv 
)
inline

generates a pseudo random double precision vector with uniformly distribute components between min and max

Definition at line 178 of file random.h.

References cgv::math::vec< T >::size(), and uniform().

◆ uniform() [9/35]

template<typename T , cgv::type::uint32_type N>
void cgv::math::random::uniform ( const float  min,
const float  max,
cgv::math::fvec< T, N > &  rv 
)
inline

generates a pseudo random single precision fixed-size vector with uniformly distribute components between min and max

Definition at line 194 of file random.h.

References uniform().

◆ uniform() [10/35]

void cgv::math::random::uniform ( const float  min,
const float  max,
diag_mat< float > &  rv 
)
inline

generates a pseudo random single precision diagonal matrix with uniformly distribute components between min and max

Definition at line 302 of file random.h.

References cgv::math::diag_mat< T >::nrows(), and uniform().

◆ uniform() [11/35]

void cgv::math::random::uniform ( const float  min,
const float  max,
float &  rv 
)
inline

generates a pseudo random single-precision floating point number uniformly distributed between min and max

Definition at line 147 of file random.h.

References uniform().

◆ uniform() [12/35]

void cgv::math::random::uniform ( const float  min,
const float  max,
low_tri_mat< float > &  rv 
)
inline

generates a pseudo random single precision lower triangular matrix with uniformly distribute components between min and max

Definition at line 271 of file random.h.

References uniform().

◆ uniform() [13/35]

void cgv::math::random::uniform ( const float  min,
const float  max,
mat< float > &  rv 
)
inline

generates a pseudo random single precision full matrix with uniformly distribute components between min and max

Definition at line 209 of file random.h.

References cgv::math::mat< T >::ncols(), cgv::math::mat< T >::nrows(), and uniform().

◆ uniform() [14/35]

void cgv::math::random::uniform ( const float  min,
const float  max,
up_tri_mat< float > &  rv 
)
inline

generates a pseudo random single precision upper triangular matrix with uniformly distribute components between min and max

Definition at line 239 of file random.h.

References uniform().

◆ uniform() [15/35]

void cgv::math::random::uniform ( const float  min,
const float  max,
vec< float > &  rv 
)
inline

generates a pseudo random single precision vector with uniformly distribute components between min and max

Definition at line 162 of file random.h.

References cgv::math::vec< T >::size(), and uniform().

◆ uniform() [16/35]

void cgv::math::random::uniform ( const int  min,
const int  max,
int &  rv 
)
inline

generates a pseudo random integer between min and max

Definition at line 115 of file random.h.

References uniform().

◆ uniform() [17/35]

void cgv::math::random::uniform ( const unsigned  min,
const unsigned  max,
unsigned &  rv 
)
inline

generates a pseudo random integer between min and max

Definition at line 108 of file random.h.

References uniform().

◆ uniform() [18/35]

void cgv::math::random::uniform ( diag_mat< double > &  rv)
inline

generates a pseudo random double precision diagonal matrix with uniformly distribute components between 0 and 1

Definition at line 309 of file random.h.

References cgv::math::diag_mat< T >::nrows(), and uniform().

◆ uniform() [19/35]

void cgv::math::random::uniform ( diag_mat< float > &  rv)
inline

generates a pseudo random single precision diagonal matrix with uniformly distribute components between 0 and 1

Definition at line 295 of file random.h.

References cgv::math::diag_mat< T >::nrows(), and uniform().

◆ uniform() [20/35]

void cgv::math::random::uniform ( double &  rv)
inline

generates a pseudo random double-precision floating point number uniformly distributed between 0 and 1

Definition at line 123 of file random.h.

References uniform().

◆ uniform() [21/35]

void cgv::math::random::uniform ( float &  rv)
inline

generates a pseudo random single-precision floating point number uniformly distributed between 0 and 1

Definition at line 139 of file random.h.

References uniform().

◆ uniform() [22/35]

void cgv::math::random::uniform ( int &  rv)
inline

generates a 32bit pseudo random signed integer

Definition at line 76 of file random.h.

References uniform().

◆ uniform() [23/35]

void cgv::math::random::uniform ( long &  rv)
inline

generates a 32bit pseudo random signed integer

Definition at line 84 of file random.h.

References uniform().

◆ uniform() [24/35]

void cgv::math::random::uniform ( long long &  rv)
inline

generates a 64bit pseudo random signed integer

Definition at line 92 of file random.h.

References uniform().

◆ uniform() [25/35]

void cgv::math::random::uniform ( low_tri_mat< double > &  rv)
inline

generates a pseudo random double precision lower triangular matrix with uniformly distribute components between 0 and 1

Definition at line 279 of file random.h.

References uniform().

◆ uniform() [26/35]

void cgv::math::random::uniform ( low_tri_mat< float > &  rv)
inline

generates a pseudo random single precision lower triangular matrix with uniformly distribute components between 0 and 1

Definition at line 263 of file random.h.

References uniform().

◆ uniform() [27/35]

void cgv::math::random::uniform ( mat< double > &  rv)
inline

generates a pseudo random double full matrix with uniformly distribute components between 0 and 1

Definition at line 324 of file random.h.

References cgv::math::mat< T >::ncols(), cgv::math::mat< T >::nrows(), and uniform().

◆ uniform() [28/35]

void cgv::math::random::uniform ( mat< float > &  rv)
inline

generates a pseudo random single precision full matrix with uniformly distribute components between 0 and 1

Definition at line 201 of file random.h.

References cgv::math::mat< T >::ncols(), cgv::math::mat< T >::nrows(), and uniform().

◆ uniform() [29/35]

void cgv::math::random::uniform ( perm_mat rv)
inline

generates a pseudo random permutation matrix

Definition at line 217 of file random.h.

References cgv::math::perm_mat::size(), and uniform().

◆ uniform() [30/35]

void cgv::math::random::uniform ( unsigned int &  rv)
inline

generates a 32bit pseudo random unsigned integer

Definition at line 68 of file random.h.

References uniform().

◆ uniform() [31/35]

◆ uniform() [32/35]

void cgv::math::random::uniform ( up_tri_mat< double > &  rv)
inline

generates a pseudo random double precision upper triangular matrix with uniformly distribute components between 0 and 1

Definition at line 247 of file random.h.

References uniform().

◆ uniform() [33/35]

void cgv::math::random::uniform ( up_tri_mat< float > &  rv)
inline

generates a pseudo random single precision upper triangular matrix with uniformly distribute components between 0 and 1

Definition at line 229 of file random.h.

References uniform().

◆ uniform() [34/35]

void cgv::math::random::uniform ( vec< double > &  rv)
inline

generates a pseudo random double precision vector with uniformly distribute components between 0 and 1

Definition at line 171 of file random.h.

References cgv::math::vec< T >::size(), and uniform().

◆ uniform() [35/35]

void cgv::math::random::uniform ( vec< float > &  rv)
inline

generates a pseudo random single precision vector with uniformly distribute components between 0 and 1

Definition at line 155 of file random.h.

References cgv::math::vec< T >::size(), and uniform().

◆ uniform_direction() [1/2]

void cgv::math::random::uniform_direction ( vec< double > &  v)
inline

generates a double precision random direction (uniformly distributed position on the unit sphere)

Definition at line 401 of file random.h.

References normal(), cgv::math::vec< T >::normalize(), and cgv::math::vec< T >::size().

◆ uniform_direction() [2/2]

void cgv::math::random::uniform_direction ( vec< float > &  v)
inline

generates a single precision random direction (uniformly distributed position on the unit sphere)

Definition at line 391 of file random.h.

References normal(), cgv::math::vec< T >::normalize(), and cgv::math::vec< T >::size().

Referenced by uniform_point_in_unit_ball().

◆ uniform_nchoosek()

void cgv::math::random::uniform_nchoosek ( unsigned  n,
unsigned  k,
vec< unsigned > &  indices 
)
inline

creates a vector of k unique indices drawn from 0 to n-1

Definition at line 506 of file random.h.

References cgv::math::vec< T >::resize(), and uniform().

◆ uniform_orientation() [1/2]

template<typename T >
void cgv::math::random::uniform_orientation ( fmat< T, 3, 3 > &  m)
inline

generates a single precision random orientation represented as a rotation matrix

Definition at line 434 of file random.h.

References cgv::math::quaternion< T >::put_matrix(), and uniform_quat_orientation().

◆ uniform_orientation() [2/2]

template<typename T >
void cgv::math::random::uniform_orientation ( fmat< T, 4, 4 > &  m)
inline

generates a single precision random orientation represented as a homogeneous rotation matrix

Definition at line 444 of file random.h.

References cgv::math::quaternion< T >::put_homogeneous_matrix(), and uniform_quat_orientation().

◆ uniform_point_in_box()

void cgv::math::random::uniform_point_in_box ( const vec< double > &  minp,
const vec< double > &  maxp,
vec< double > &  p 
)
inline

creates an uniform distributed random point in box minp..maxp

Definition at line 462 of file random.h.

References cgv::math::vec< T >::resize(), cgv::math::vec< T >::size(), and uniform().

◆ uniform_point_in_triangle()

void cgv::math::random::uniform_point_in_triangle ( const vec< double > &  p1,
const vec< double > &  p2,
const vec< double > &  p3,
vec< double >  p 
)
inline

creates an uniform distributed random point in triangle p1,p2,p3

Definition at line 481 of file random.h.

References uniform().

◆ uniform_point_in_unit_ball()

void cgv::math::random::uniform_point_in_unit_ball ( vec< double > &  p)
inline

creates an uniform distributed random point in unit sphere

Definition at line 472 of file random.h.

References cgv::math::vec< T >::size(), uniform(), and uniform_direction().

◆ uniform_point_in_unit_box()

void cgv::math::random::uniform_point_in_unit_box ( vec< double > &  p)
inline

creates an uniform distributed random point in unit box (0,0,...,0)..(1,1,...,1); if dim(p)=0, it is set to 3

Definition at line 453 of file random.h.

References cgv::math::vec< T >::resize(), cgv::math::vec< T >::size(), and uniform().

◆ uniform_point_on_sphere()

void cgv::math::random::uniform_point_on_sphere ( const vec< double > &  center,
const double &  radius,
vec< double > &  p 
)
inline

creates an uniform distributed random point on the surface of a sphere with given center and radius

Definition at line 495 of file random.h.

References normal(), cgv::math::vec< T >::normalize(), and cgv::math::vec< T >::size().

◆ uniform_quat_orientation()

template<typename T >
void cgv::math::random::uniform_quat_orientation ( quaternion< T > &  q)
inline

generates a random orientation represented as a unit quaternion

Definition at line 410 of file random.h.

References cgv::math::quaternion< T >::set(), and uniform().

Referenced by uniform_orientation(), and uniform_orientation().


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