VF_randomLCVD_randomLCVE_randomLC
VCF_randomLCVCD_randomLCVCE_randomLC
VI_randomLCVBI_randomLCVSI_randomLCVLI_randomLCVQI_randomLC 
VU_randomLCVUB_randomLCVUS_randomLCVUL_randomLCVUQ_randomLCVUI_randomLC
FunctionHigh-quality random numbers
Syntax C/C++#include <VFstd.h>
void VF_randomLC( fVector X, ui siz, long seed, float MinVal, float MaxVal, V_RANDOMLCSTATE *state );
C++ VecObj#include <OptiVec.h>
void vector<T>::randomLC( long seed, T MinVal, T MaxVal, V_RANDOMLCSTATE *state );
Pascal/Delphiuses VFstd;
procedure VF_randomLC( X:fVector; size:UIntSize; seed:LongInt; MinVal, MaxVal:Single; state:PV_RANDOMLCSTATE );
CUDA function C/C++#include <cudaVFstd.h>
int cudaVF_randomLC( fVector d_X, ui siz, long seed, float MinVal, float MaxVal, V_RANDOMLCSTATE *h_state );
int cusdVF_randomLC( fVector d_X, ui siz, long seed, float *d_MinVal, float *d_MaxVal, V_RANDOMLCSTATE *h_state );
CUDA function Pascal/Delphiuses VFstd;
function cudaVF_randomLC( d_X:fVector; size:UIntSize; seed:LongInt; MinVal, MaxVal:Single; h_state:PV_RANDOMLCSTATE ): IntBool;
function cusdVF_randomLC( d_X:fVector; size:UIntSize; seed:LongInt; d_MinVal, d_MaxVal:PSingle; h_state:PV_RANDOMLCSTATE ): 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.

If the parameter seed is any non-zero number, the generator is initialized with that seed value and a new series of random numbers is generated. On the other hand, if you wish to continue a previous series, call this function with seed=0 and with the same parameter state as the previous call. 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 linear-congruential (hence the "LC" in the function name) 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 stretch of output numbers, these functions are not suitable for cryptographic applications.

A simplified form of this function is available as VF_random.

Example C/C++#include <VFstd.h>
V_RANDOMLCSTATE MyState;
   // Will hold the state of the generator
VF_randomLC( X, siz/2, −1111, −1.0, +1.0, &MyState );   // Initialisation by seed ≠ 0 and first half of series
VF_randomLC( X, siz-siz/2, 0, −1.0, +1.0, &MyState );   // Continuation of the series by seed = 0
VF_randomLC( Y, siz, −1111, −1.0, +1.0, &MyState );   // identical series in Y as in X by choice of identical seed
VF_randomLC( Z, siz, 234567, −1.0, +1.0, &MyState );   // different series in Z by choice of different seed
Beispiel Pascal/Delphiuses VFstd;
var MyState: V_RANDOMLCSTATE;
   { Will hold the state of the generator }
VF_randomLC( X, siz div 2, −1111, −1.0, +1.0, @MyState );   { Initialisation by seed ≠ 0 and first half of series }
VF_randomLC( X, siz-siz div 2, 0, −1.0, +1.0, @MyState );   { Continuation of the series by seed = 0 }
VF_randomLC( Y, siz, −1111, −1.0, +1.0, @MyState );   { identical series in Y as in X by choice of identical seed }
VF_randomLC( Z, siz, 234567, −1.0, +1.0, @MyState );   { different series in Z by choice of different seed }
Error handlingnone
Return valuenone
See alsorand,   srand (C/C++ only),  random,   VF_noiseLC,   VF_random

VectorLib Table of Contents  OptiVec home