random_seed - set or get a value of seed to the probability distribution pseudorandom number generatorExperimental
Set or get the seed value before calling the probability distribution pseudorandom number generator for variates.
call random_seed (put, get)
put: argument has intent(in) and may be a scalar of type integer.
get: argument has intent(out) and is a scalar of type integer.
Return a scalar of type integer.
program example_random_seed
use stdlib_random, only: random_seed
implicit none
integer :: seed_put, seed_get
seed_put = 1234567
call random_seed(seed_put, seed_get) ! set and get current value of seed
end program example_random_seed
dist_rand - Get a random integer with specified kindExperimental
Generate an integer pseudorandom number in a specific range [-2^k, 2^k - 1] according to the input integer kind n. This pseudorandom number will be operated by bit opeartors instead of normal arithmetic operators.
result = dist_rand (n)
n: argument has intent(in) is a scalar of type integer.
Return a scalar of type integer.
program example_dist_rand
use stdlib_kinds, only: int8, int16, int32, int64
use stdlib_random, only: dist_rand, random_seed
implicit none
integer :: put, get
put = 135792468
call random_seed(put, get) ! set and get current value of seed
print *, dist_rand(1_int8) ! random integer in [-2^7, 2^7 - 1]
! -90
print *, dist_rand(1_int16) ! random integer in [-2^15, 2^15 - 1]
! -32725
print *, dist_rand(1_int32) ! random integer in [-2^31, 2^31 - 1]
! -1601563881
print *, dist_rand(1_int64) ! random integer in [-2^63, 2^63 - 1]
! 180977695517992208
end program example_dist_rand