VF_randomLC | VD_randomLC | VE_randomLC |
VCF_randomLC | VCD_randomLC | VCE_randomLC |
VI_randomLC | VBI_randomLC | VSI_randomLC | VLI_randomLC | VQI_randomLC | |
VU_randomLC | VUB_randomLC | VUS_randomLC | VUL_randomLC | VUQ_randomLC | VUI_randomLC |
|
Function | High-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/Delphi | uses 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/Delphi | uses 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;
|
|
Description | The 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/Delphi | uses 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 }
|
|
|
|
|