@@ -114,7 +114,7 @@ Module stdlib_stats_distribution_normal
114
114
if( .not. zig_norm_initialized ) call zigset
115
115
iz = 0
116
116
! original algorithm use 32bit
117
- hz = dist_rand(iz )
117
+ hz = dist_rand(1_int32 )
118
118
119
119
iz = iand( hz, 127 )
120
120
if( abs( hz ) < kn(iz) ) then
@@ -123,23 +123,23 @@ Module stdlib_stats_distribution_normal
123
123
L1: do
124
124
L2: if( iz == 0 ) then
125
125
do
126
- x = -log( uni( ) ) * rr
127
- y = -log( uni( ) )
126
+ x = -log( uni(1.0_${k1}$ ) ) * rr
127
+ y = -log( uni(1.0_${k1}$ ) )
128
128
if( y + y >= x * x ) exit
129
129
end do
130
130
res = r + x
131
131
if( hz <= 0 ) res = -res
132
132
exit L1
133
133
end if L2
134
134
x = hz * wn(iz)
135
- if( fn(iz) + uni( ) * (fn(iz-1) - fn(iz)) < &
135
+ if( fn(iz) + uni(1.0_${k1}$ ) * (fn(iz-1) - fn(iz)) < &
136
136
exp(-HALF * x * x) ) then
137
137
res = x
138
138
exit L1
139
139
end if
140
140
141
141
!original algorithm use 32bit
142
- hz = dist_rand(iz )
142
+ hz = dist_rand(1_int32 )
143
143
iz = iand( hz, 127 )
144
144
if( abs( hz ) < kn(iz) ) then
145
145
res = hz * wn(iz)
@@ -168,7 +168,7 @@ Module stdlib_stats_distribution_normal
168
168
if( .not. zig_norm_initialized ) call zigset
169
169
iz = 0
170
170
! original algorithm use 32bit
171
- hz = dist_rand(iz )
171
+ hz = dist_rand(1_int32 )
172
172
173
173
iz = iand( hz, 127 )
174
174
if( abs( hz ) < kn(iz) ) then
@@ -177,23 +177,23 @@ Module stdlib_stats_distribution_normal
177
177
L1: do
178
178
L2: if( iz == 0 ) then
179
179
do
180
- x = -log( uni( ) ) * rr
181
- y = -log( uni( ) )
180
+ x = -log( uni(1.0_${k1}$ ) ) * rr
181
+ y = -log( uni(1.0_${k1}$ ) )
182
182
if( y + y >= x * x ) exit
183
183
end do
184
184
res = r + x
185
185
if( hz <= 0 ) res = -res
186
186
exit L1
187
187
end if L2
188
188
x = hz * wn(iz)
189
- if( fn(iz) + uni( ) * (fn(iz-1) - fn(iz)) < &
189
+ if( fn(iz) + uni(1.0_${k1}$ ) * (fn(iz-1) - fn(iz)) < &
190
190
exp(-HALF * x * x) ) then
191
191
res = x
192
192
exit L1
193
193
end if
194
194
195
195
!original algorithm use 32bit
196
- hz = dist_rand(iz )
196
+ hz = dist_rand(1_int32 )
197
197
iz = iand( hz, 127 )
198
198
if( abs( hz ) < kn(iz) ) then
199
199
res = hz * wn(iz)
@@ -219,7 +219,7 @@ Module stdlib_stats_distribution_normal
219
219
220
220
tr = norm_dist_rvs_r${k1}$(real(loc), real(scale))
221
221
ti = norm_dist_rvs_r${k1}$(aimag(loc), aimag(scale))
222
- res = cmplx(tr, ti)
222
+ res = cmplx(tr, ti, kind=${k1}$ )
223
223
return
224
224
end function norm_dist_rvs_${t1[0]}$${k1}$
225
225
@@ -242,7 +242,7 @@ Module stdlib_stats_distribution_normal
242
242
do i = 1, array_size
243
243
iz = 0
244
244
! original algorithm use 32bit
245
- hz = dist_rand(iz )
245
+ hz = dist_rand(1_int32 )
246
246
247
247
iz = iand( hz, 127 )
248
248
if( abs( hz ) < kn(iz) ) then
@@ -251,23 +251,23 @@ Module stdlib_stats_distribution_normal
251
251
L1: do
252
252
L2: if( iz == 0 ) then
253
253
do
254
- x = -log( uni( ) ) * rr
255
- y = -log( uni( ) )
254
+ x = -log( uni(1.0_${k1}$ ) ) * rr
255
+ y = -log( uni(1.0_${k1}$ ) )
256
256
if( y + y >= x * x ) exit
257
257
end do
258
258
re = r + x
259
259
if( hz <= 0 ) re = -re
260
260
exit L1
261
261
end if L2
262
262
x = hz * wn(iz)
263
- if( fn(iz) + uni( ) * (fn(iz-1) - fn(iz)) < &
263
+ if( fn(iz) + uni(1.0_${k1}$ ) * (fn(iz-1) - fn(iz)) < &
264
264
exp(-HALF * x * x) ) then
265
265
re = x
266
266
exit L1
267
267
end if
268
268
269
269
!original algorithm use 32bit
270
- hz = dist_rand(iz )
270
+ hz = dist_rand(1_int32 )
271
271
iz = iand( hz, 127 )
272
272
if( abs( hz ) < kn(iz) ) then
273
273
re = hz * wn(iz)
@@ -295,7 +295,7 @@ Module stdlib_stats_distribution_normal
295
295
do i = 1, array_size
296
296
tr = norm_dist_rvs_r${k1}$(real(loc), real(scale))
297
297
ti = norm_dist_rvs_r${k1}$(aimag(loc), aimag(scale))
298
- res(i) = cmplx(tr, ti)
298
+ res(i) = cmplx(tr, ti, kind=${k1}$ )
299
299
end do
300
300
return
301
301
end function norm_dist_rvs_array_${t1[0]}$${k1}$
@@ -363,4 +363,4 @@ Module stdlib_stats_distribution_normal
363
363
364
364
#:endfor
365
365
366
- end module stdlib_stats_distribution_normal
366
+ end module stdlib_stats_distribution_normal
0 commit comments