The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



FillRandomUniform


Unit:SDL_openarrays
Class: none
Declaration: [1] function FillRandomUniform (var Arr: TIntArray; RangeLow, RangeHigh: integer): integer;
[2] function FillRandomUniform (var Arr: TInt2DArray; RangeLow, RangeHigh: integer): integer;
[3] function FillRandomUniform (var Arr: TInt3DArray; RangeLow, RangeHigh: integer): integer;
[4] function FillRandomUniform (var Arr: TInt4DArray; RangeLow, RangeHigh: integer): integer;
[5] function FillRandomUniform (var Arr: TDoubleArray; RangeLow, RangeHigh: double): integer;
[6] function FillRandomUniform (var Arr: TDouble2DArray; RangeLow, RangeHigh: double): integer;
[7] function FillRandomUniform (var Arr: TDouble3DArray; RangeLow, RangeHigh: double): integer;
[8] function FillRandomUniform (var Arr: TDouble4DArray; RangeLow, RangeHigh: double): integer;
[9] function FillRandomUniform (var Arr: TIntArray; RangeLow, RangeHigh: integer; DupsAllowed: boolean): integer;

The function FillRandomUniform fills every cell of the given array Arr with a random number with uniform distribution. The generated random numbers are in the range from RangeLow to RangeHigh. Version [9] of the function provides the option to fill an integer array with unique, non-repeating random numbers by setting the paramter DupsAllowed to a FALSE value. Please note that there are some restrictions on the parameters if DupsAllowed is set to FALSE: the maximum size of the array is limited to 1000000 entries and the range of the random numbers must not exceed 1000000.

The function returns the following error codes:

 0 ... everything is OK
-1 ... the matrix Arr has zero size
-2 ... RangeLow is greater than RangeHigh
-3 ... the range of the random numbers is too small, the array cannot be filled without creating duplicates
-4 ... the range of the random numbers is too big (currently limited to 1000000)

Hint: If DupsAllowed is set to TRUE version [9] is equivalent to version [1].



Last Update: 2023-Feb-06