Random
Module
Provides functions for random numbers.
rand
rand[type: DType](ptr: DTypePointer[type], size: Int)
Fill memory with random values.
Parameters:
- type (
DType
): The dtype of the pointer.
Args:
- ptr (
DTypePointer[type]
): The pointer to the memory area to fill. - size (
Int
): The number of elements to fill.
randint
randint[type: DType](ptr: DTypePointer[type], size: Int, low: Int, high: Int)
Fill memory with random values.
Constraints:
The type should be integral.
Parameters:
- type (
DType
): The dtype of the pointer.
Args:
- ptr (
DTypePointer[type]
): The pointer to the memory area to fill. - size (
Int
): The number of elements to fill. - low (
Int
): The minimal value for random. - high (
Int
): The maximal value for random.
random_f64
random_f64(min: SIMD[f64, 1], max: SIMD[f64, 1]) -> SIMD[f64, 1]
Return a random F64
number from the given range.
Args:
- min (
SIMD[f64, 1]
): The minimum number in the range (default is 0.0). - max (
SIMD[f64, 1]
): The maximum number in the range (default is 1.0).
Returns:
A random number from the specified range.
random_si64
random_si64(min: SIMD[si64, 1], max: SIMD[si64, 1]) -> SIMD[si64, 1]
Return a random SI64
number from the given range.
Args:
- min (
SIMD[si64, 1]
): The minimum number in the range. - max (
SIMD[si64, 1]
): The maximum number in the range.
Returns:
A random number from the specified range.
random_ui64
random_ui64(min: SIMD[ui64, 1], max: SIMD[ui64, 1]) -> SIMD[ui64, 1]
Return a random UI64
number from the given range.
Args:
- min (
SIMD[ui64, 1]
): The minimum number in the range. - max (
SIMD[ui64, 1]
): The maximum number in the range.
Returns:
A random number from the specified range.