|
16 | 16 | ! along with xtb. If not, see <https://www.gnu.org/licenses/>.
|
17 | 17 |
|
18 | 18 | module random_generators
|
19 |
| - use xtb_mctc_accuracy, only: sp, wp |
| 19 | + use xtb_mctc_accuracy, only: sp, dp |
20 | 20 |
|
21 | 21 | implicit none
|
22 | 22 |
|
23 | 23 | private
|
24 | 24 |
|
25 | 25 | interface normal_distribution
|
26 | 26 | module procedure normal_distribution_sp
|
27 |
| - module procedure normal_distribution_wp |
| 27 | + module procedure normal_distribution_dp |
28 | 28 | end interface normal_distribution
|
29 | 29 |
|
30 | 30 | public normal_distribution
|
@@ -61,18 +61,18 @@ end function normal_distribution_sp
|
61 | 61 | !> @param[in] sigma standard deviation
|
62 | 62 | !> @param[in] mu mean of distribution
|
63 | 63 | !> @return pseudorandom value
|
64 |
| - real(wp) function normal_distribution_wp(sigma, mu) result(randval) |
65 |
| - real(wp), intent(in) :: sigma, mu |
66 |
| - real(wp), parameter :: two_pi = 2.0_wp * 4.0_wp * atan(1.0_wp) |
67 |
| - real(wp) :: u(2), mag |
| 64 | + real(dp) function normal_distribution_dp(sigma, mu) result(randval) |
| 65 | + real(dp), intent(in) :: sigma, mu |
| 66 | + real(dp), parameter :: two_pi = 2.0_dp * 4.0_dp * atan(1.0_dp) |
| 67 | + real(dp) :: u(2), mag |
68 | 68 |
|
69 |
| - u = 0.0_wp |
70 |
| - do while (u(1) == 0.0_wp) |
| 69 | + u = 0.0_dp |
| 70 | + do while (u(1) == 0.0_dp) |
71 | 71 | call random_number(u)
|
72 | 72 | end do
|
73 |
| - mag = sigma * sqrt(-2.0_wp * log(u(1))) |
| 73 | + mag = sigma * sqrt(-2.0_dp * log(u(1))) |
74 | 74 | randval = mag * cos(two_pi * u(2)) + mu
|
75 | 75 |
|
76 |
| - end function normal_distribution_wp |
| 76 | + end function normal_distribution_dp |
77 | 77 |
|
78 | 78 | end module random_generators
|
0 commit comments