MF_random MD_random ME_random
MCF_random MCD_random MCE_random
MI_randomMBI_randomMSI_randomMLI_randomMQI_random
MU_randomMUB_randomMUS_randomMUL_randomMUQ_random;
Functionfill a matrix with high-quality random numbers
Syntax C/C++#include <MFstd.h>
long MF_random( fMatrix MA, ui ht, ui len, long seed, float MinVal, float MaxVal );
C++ MatObj#include <OptiVec.h>
long matrix<T>::random( const long& seed, const T& MinVal, const T& MaxVal );
Pascal/Delphiuses MFstd;
  function MF_random( MA:fMatrix; ht, len:UIntSize; seed:LongInt; MinVal, MaxVal:Single ): LongInt;
CUDA function C/C++#include <cudaMFstd.h>
int cudaMF_random( fMatrix d_MA, ui ht, ui len, long seed, float MinVal, float MaxVal );
int cusdMF_random( fMatrix d_MA, ui ht, ui len, long seed, float *d_MinVal, float *d_MaxVal );
CUDA function Pascal/Delphiuses MFstd;
function cudaMF_random( d_MA:fMatrix; ht, len:UIntSize; seed:LongInt; MinVal, MaxVal:Single ): IntBool;
function cusdMF_random( d_MA:fMatrix; ht, len:UIntSize; seed:LongInt; d_MinVal, d_MaxVal:PSingle ): IntBool;
DescriptionThe matrix MA is filled with random numbers. Within the ranges defined by MinVal and MaxVal, and within the restrictions of floating-point representation, 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 32-bit integer random number generator by H.W.Lewis, with additional steps (so-called "Bays-Durham shuffle") to break sequential correlations. This ensures very good randomness, far superior to simpler generators (like the rand function of C/C++ compilers or the random function of Pascal/Delphi).

A long value is returned which may be used as new seed for subsequent calls.

The CUDA versions of this function do not return a new seed value, but the usual CUDA error flag.
There is no MFcu_ 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 alsoVF_random,   chapter 3

MatrixLib Table of Contents  OptiVec home