@@ -10,30 +10,22 @@ module mod_random
10
10
private
11
11
public :: randn
12
12
13
- real (rk), parameter :: pi = 4 * atan (1._rk )
14
-
15
13
interface randn
16
- module procedure :: randn1d, randn2d
17
- end interface randn
18
14
19
- contains
20
-
21
- function randn1d (n ) result(r)
22
- ! ! Generates n random numbers with a normal distribution.
23
- integer (ik), intent (in ) :: n
24
- real (rk) :: r(n), r2(n)
25
- call random_number (r)
26
- call random_number (r2)
27
- r = sqrt (- 2 * log (r)) * cos (2 * pi * r2)
28
- end function randn1d
29
-
30
- function randn2d (m , n ) result(r)
31
- ! ! Generates m x n random numbers with a normal distribution.
32
- integer (ik), intent (in ) :: m, n
33
- real (rk) :: r(m, n), r2(m, n)
34
- call random_number (r)
35
- call random_number (r2)
36
- r = sqrt (- 2 * log (r)) * cos (2 * pi * r2)
37
- end function randn2d
15
+ module function randn1d (n ) result(r)
16
+ ! ! Generates n random numbers with a normal distribution.
17
+ implicit none
18
+ integer (ik), intent (in ) :: n
19
+ real (rk) :: r(n)
20
+ end function randn1d
21
+
22
+ module function randn2d (m , n ) result(r)
23
+ ! ! Generates m x n random numbers with a normal distribution.
24
+ implicit none
25
+ integer (ik), intent (in ) :: m, n
26
+ real (rk) :: r(m, n)
27
+ end function randn2d
28
+
29
+ end interface randn
38
30
39
31
end module mod_random
0 commit comments