VF_randomVD_randomVE_random
VCF_randomVCD_randomVCE_random
VI_randomVBI_randomVSI_randomVLI_randomVQI_random 
VU_randomVUB_randomVUS_randomVUL_randomVUQ_randomVUI_random
FunctionHigh-quality random numbers
Syntax C/C++#include <VFstd.h>
long VF_random( fVector X, ui siz, long seed, float MinVal, float MaxVal );
C++ VecObj#include <OptiVec.h>
long vector<T>::random( long seed, T MinVal, T MaxVal );
Pascal/Delphiuses VFstd;
function VF_random( X:fVector; size:UIntSize; seed:LongInt; MinVal, MaxVal:Single ): LongInt;
CUDA function C/C++#include <cudaVFstd.h>
int cudaVF_random( fVector d_X, ui siz, long seed, float MinVal, float MaxVal );
int cusdVF_random( fVector d_X, ui siz, long seed, float *d_MinVal, float *d_MaxVal );
CUDA function Pascal/Delphiuses VFstd;
function cudaVF_random( d_X:fVector; size:UIntSize; seed:LongInt; MinVal, MaxVal:Single ): IntBool;
function cusdVF_random( d_X:fVector; size:UIntSize; seed:LongInt; d_MinVal, d_MaxVal:PSingle ): IntBool;
DescriptionThe X vector is filled with a sequence of random numbers. Within the ranges defined by MinVal and MaxVal (and within the restrictions of floating-point representation in the floating-point versions), all numbers are equally probable (including the extreme values themselves), i.e., so-called "uniform deviates" are produced. The parameter seed may be any number. Successive calls to one and the same of these functions will yield identical sequences, if seed is chosen equal; if seed is chosen differently for successive calls, the results will be uncorrelated.

Internally, these functions employ a random number generator by H.W.Lewis. The smaller data types use a 32-bit generator, while the larger types use a 64-bit version. Additional steps (so-called "Bays-Durham shuffle") are taken to break sequential correlations. This ensures very good randomness. However, as this algorithm is well-known and its state can be inferred from a given series of output numbers, these functions are not suitable for cryptographic applications.

A long value is returned which may be used as new seed for subsequent calls. These calls will, however, not simply continue the series, as the random-number generator will have to run through a new initialization first. If continuity of the series is desired, call VF_randomLC instead.

The CUDA versions of this function do not return a new seed value, but the usual CUDA error flag.
There is no VFcu_ version of this function, as the random numbers are generated on the CPU anyway.

Error handlingnone
Return valuelast 32-bit random number generated; this may be used as a new seed value for future calls.
See alsorand,   srand (C/C++ only),  random,   VF_noise,   VF_randomLC

VectorLib Table of Contents  OptiVec home