FORCES
FORtran lib for Comp. Env. Sys.
|
Uniform XOR4096-based RNG. More...
Public Member Functions | |
subroutine | xor4096s_0d (seed, singleintegerrn, save_state) |
subroutine | xor4096s_1d (seed, singleintegerrn, save_state) |
subroutine | xor4096f_0d (seed, singlerealrn, save_state) |
subroutine | xor4096f_1d (seed, singlerealrn, save_state) |
subroutine | xor4096l_0d (seed, doubleintegerrn, save_state) |
subroutine | xor4096l_1d (seed, doubleintegerrn, save_state) |
subroutine | xor4096d_0d (seed, doublerealrn, save_state) |
subroutine | xor4096d_1d (seed, doublerealrn, save_state) |
Uniform XOR4096-based RNG.
Generates a uniform distributed random number based on xor4096 algorithm proposed by Brent et.al (2006).
The original version of this source code (without multiple streams and optional arguments) is under GNU General Public Licence xorgens.c Copyright (C) 2004 R. P. Brent. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, June 1991, as published by the Free Software Foundation. For details see http://www.gnu.org/copyleft/gpl.html . Author: Richard P. Brent (rando.nosp@m.m@rp.nosp@m.brent.nosp@m..co..nosp@m.uk)
The period of the generator is
(2^4096 - 1)*2^32 for single precision version and (2^4096 - 1)*2^64 for double precision version.
The generator is based on bitwise XOR compositions of left- and right-shifted numbers.
The generator has to be called once with a non-zero seed value which initializes a new random number stream. The subsequent calls are with seed=0 which returns the following numbers within the beforehand initialized stream. Since the random numbers are based on the initial seed, the precison of the seed (sp/dp) determines the precision of the returned random number (sp/dp).
If one initialize the generator with an array of seeds, one initializes n independent streams of random numbers. Lets assume that the streams with seed: 1_sp is 10, 20, 30 ...
2_sp is 40, 50, 60 ...
3_sp is 70, 80, 90 ...
What you get is:
1st call
2nd call
3rd call
Since after every initialization one looses the old stream of random numbers, it might be necessary to switch between different streams. Therefore, one needs the optional save_state argument. What you get is: 1st call of 1st stream
2nd call of 1st stream
1st call of 2nd stream
3rd call of 1st stream
Note: If you would have called 4 times without optional argument, you would have get 50 in the 4th call.
Example
I4 seeds are generating I4 or SP random numbers, I8 seeds are generating I8 or DP random numbers.
Initializing:
After initializing
Literature
[in] | integer(i4/i8) :: seed/seed(:) | Value or 1D-array with non-zero seeds for initialization or zero for subsequent callsyy |
[out] | integer(i4/i8)/real(sp/dp) :: RN/RN(size(seed)) | uniform distributed random number with interval:
|
[in,out] | integer(i4/i8), dimension(size(seed), n_save_state), opional :: save_state | Array carrying state of random number stream this should be used if several streams are used, i.e. each stream has its own save_state. |
Definition at line 200 of file mo_xor4096.f90.
subroutine mo_xor4096::xor4096::xor4096d_0d | ( | integer(i8), intent(in) | seed, |
real(dp), intent(out) | doublerealrn, | ||
integer(i8), dimension(n_save_state), intent(inout), optional | save_state | ||
) |
Definition at line 1126 of file mo_xor4096.f90.
subroutine mo_xor4096::xor4096::xor4096d_1d | ( | integer(i8), dimension(:), intent(in) | seed, |
real(dp), dimension(size(seed, 1)), intent(out) | doublerealrn, | ||
integer(i8), dimension(size(seed, 1), n_save_state), intent(inout), optional | save_state | ||
) |
Definition at line 1237 of file mo_xor4096.f90.
subroutine mo_xor4096::xor4096::xor4096f_0d | ( | integer(i4), intent(in) | seed, |
real(sp), intent(out) | singlerealrn, | ||
integer(i4), dimension(n_save_state), intent(inout), optional | save_state | ||
) |
Definition at line 622 of file mo_xor4096.f90.
subroutine mo_xor4096::xor4096::xor4096f_1d | ( | integer(i4), dimension(:), intent(in) | seed, |
real(sp), dimension(size(seed)), intent(out) | singlerealrn, | ||
integer(i4), dimension(size(seed, 1), n_save_state), intent(inout), optional | save_state | ||
) |
Definition at line 737 of file mo_xor4096.f90.
subroutine mo_xor4096::xor4096::xor4096l_0d | ( | integer(i8), intent(in) | seed, |
integer(i8), intent(out) | doubleintegerrn, | ||
integer(i8), dimension(n_save_state), intent(inout), optional | save_state | ||
) |
Definition at line 886 of file mo_xor4096.f90.
subroutine mo_xor4096::xor4096::xor4096l_1d | ( | integer(i8), dimension(:), intent(in) | seed, |
integer(i8), dimension(size(seed, 1)), intent(out) | doubleintegerrn, | ||
integer(i8), dimension(size(seed, 1), n_save_state), intent(inout), optional | save_state | ||
) |
Definition at line 987 of file mo_xor4096.f90.
subroutine mo_xor4096::xor4096::xor4096s_0d | ( | integer(i4), intent(in) | seed, |
integer(i4), intent(out) | singleintegerrn, | ||
integer(i4), dimension(n_save_state), intent(inout), optional | save_state | ||
) |
Definition at line 382 of file mo_xor4096.f90.
subroutine mo_xor4096::xor4096::xor4096s_1d | ( | integer(i4), dimension(:), intent(in) | seed, |
integer(i4), dimension(size(seed, 1)), intent(out) | singleintegerrn, | ||
integer(i4), dimension(size(seed, 1), n_save_state), intent(inout), optional | save_state | ||
) |
Definition at line 483 of file mo_xor4096.f90.