@@ -125,11 +125,27 @@ end
125
125
@test_approx_eq airybiprime (1.8 ) 2.98554005084659907283
126
126
@test_throws Base. Math. AmosException airy (200im )
127
127
@test_throws Base. Math. AmosException airybi (200 )
128
+ @test_throws ArgumentError airy (5 ,one (Complex128))
128
129
z = 1.8 + 1.0im
129
130
@test_approx_eq airyx (0 , z) airy (0 , z) * exp (2 / 3 * z * sqrt (z))
130
131
@test_approx_eq airyx (1 , z) airy (1 , z) * exp (2 / 3 * z * sqrt (z))
131
132
@test_approx_eq airyx (2 , z) airy (2 , z) * exp (- abs (real (2 / 3 * z * sqrt (z))))
132
133
@test_approx_eq airyx (3 , z) airy (3 , z) * exp (- abs (real (2 / 3 * z * sqrt (z))))
134
+ @test_throws ArgumentError airyx (5 ,z)
135
+
136
+ # bessely0, bessely1, besselj0, besselj1
137
+ @test_approx_eq besselj0 (Float32 (2.0 )) besselj0 (Float64 (2.0 ))
138
+ @test_approx_eq besselj1 (Float32 (2.0 )) besselj1 (Float64 (2.0 ))
139
+ @test_approx_eq bessely0 (Float32 (2.0 )) bessely0 (Float64 (2.0 ))
140
+ @test_approx_eq bessely1 (Float32 (2.0 )) bessely1 (Float64 (2.0 ))
141
+ @test_approx_eq besselj0 (2 ) besselj0 (2.0 )
142
+ @test_approx_eq besselj1 (2 ) besselj1 (2.0 )
143
+ @test_approx_eq bessely0 (2 ) bessely0 (2.0 )
144
+ @test_approx_eq bessely1 (2 ) bessely1 (2.0 )
145
+ @test_approx_eq besselj0 (2.0 + im) besselj (0 , 2.0 + im)
146
+ @test_approx_eq besselj1 (2.0 + im) besselj (1 , 2.0 + im)
147
+ @test_approx_eq bessely0 (2.0 + im) bessely (0 , 2.0 + im)
148
+ @test_approx_eq bessely1 (2.0 + im) bessely (1 , 2.0 + im)
133
149
134
150
# besselh
135
151
true_h133 = 0.30906272225525164362 - 0.53854161610503161800im
@@ -147,12 +163,15 @@ true_i33 = 0.95975362949600785698
147
163
@test_approx_eq besseli (3 ,- 3 ) - true_i33
148
164
@test_approx_eq besseli (- 3 ,- 3 ) - true_i33
149
165
@test_throws Base. Math. AmosException besseli (1 ,1000 )
166
+ @test_throws DomainError besseli (0.4 ,- 1.0 )
150
167
151
168
# besselj
152
169
@test besselj (0 ,0 ) == 1
153
170
for i = 1 : 5
154
171
@test besselj (i,0 ) == 0
155
172
@test besselj (- i,0 ) == 0
173
+ @test besselj (- i,Float32 (0 )) == 0
174
+ @test besselj (- i,Float32 (0 )) == 0
156
175
end
157
176
158
177
j33 = besselj (3 ,3. )
@@ -190,11 +209,15 @@ true_k3m3 = -0.1221703757571835679 - 3.0151549516807985776im
190
209
# bessely
191
210
y33 = bessely (3 ,3. )
192
211
@test bessely (3 ,3 ) == y33
212
+ @test bessely (3. ,3. ) == y33
213
+ @test_approx_eq bessely (3 ,Float32 (3. )) y33
193
214
@test_approx_eq bessely (- 3 ,3 ) - y33
194
215
@test_approx_eq y33 - 0.53854161610503161800
195
216
@test_throws DomainError bessely (3 ,- 3 )
196
217
@test_approx_eq bessely (3 ,complex (- 3 )) 0.53854161610503161800 - 0.61812544451050328724im
197
218
@test_throws Base. Math. AmosException bessely (200.5 ,0.1 )
219
+ @test_throws DomainError bessely (0.4 ,- 1.0 )
220
+ @test_throws DomainError bessely (0.4 ,Float32 (- 1.0 ))
198
221
199
222
# issue #6653
200
223
for f in (besselj,bessely,besseli,besselk,hankelh1,hankelh2)
218
241
@test_throws Base. Math. AmosException besseljx (- 1 , 0 )
219
242
@test besselkx (1 , 0 ) == Inf
220
243
@test_throws Base. Math. AmosException besselyx (1 , 0 )
244
+ @test_throws DomainError besselix (0.4 ,- 1.0 )
245
+ @test_throws DomainError besseljx (0.4 , - 1.0 )
246
+ @test_throws DomainError besselkx (0.4 ,- 1.0 )
247
+ @test_throws DomainError besselyx (0.4 ,- 1.0 )
221
248
222
249
# beta, lbeta
223
250
@test_approx_eq beta (3 / 2 ,7 / 2 ) 5 π/ 128
@@ -233,9 +260,11 @@ if Base.Math.libm == "libopenlibm"
233
260
else
234
261
@test_approx_eq gamma (Float64[1 : 25 ;]) gamma (1 : 25 )
235
262
end
236
- @test_approx_eq gamma (1 / 2 ) sqrt (π)
237
- @test_approx_eq gamma (- 1 / 2 ) - 2 sqrt (π)
238
- @test_approx_eq lgamma (- 1 / 2 ) log (abs (gamma (- 1 / 2 )))
263
+ for elty in (Float32, Float64)
264
+ @test_approx_eq gamma (convert (elty,1 / 2 )) convert (elty,sqrt (π))
265
+ @test_approx_eq gamma (convert (elty,- 1 / 2 )) convert (elty,- 2 sqrt (π))
266
+ @test_approx_eq lgamma (convert (elty,- 1 / 2 )) convert (elty,log (abs (gamma (- 1 / 2 ))))
267
+ end
239
268
@test_approx_eq lgamma (1.4 + 3.7im ) - 3.7094025330996841898 + 2.4568090502768651184im
240
269
@test_approx_eq lgamma (1.4 + 3.7im ) log (gamma (1.4 + 3.7im ))
241
270
@test_approx_eq lgamma (- 4.2 + 0im ) lgamma (- 4.2 )- pi * im
296
325
@test_approx_eq zeta (0 ) - 0.5
297
326
@test_approx_eq zeta (2 ) pi ^ 2 / 6
298
327
@test_approx_eq zeta (4 ) pi ^ 4 / 90
328
+ @test_approx_eq zeta (one (Float32)) Float32 (zeta (one (Float64)))
299
329
300
330
# quadgk
301
331
@test_approx_eq quadgk (cos, 0 ,0.7 ,1 )[1 ] sin (1 )
353
383
@test isa ([polygamma (3 ,x) for x in [1.0 ]], Vector{Float64})
354
384
@test 1e-13 > errc (zeta (2 + 1im , - 1.1 ), zeta (2 + 1im , - 1.1 + 0im ))
355
385
@test 1e-13 > errc (zeta (2 + 1im , - 1.1 ), - 1525.8095173321060982383023516086563741006869909580583246557 + 1719.4753293650912305811325486980742946107143330321249869576im )
386
+ @test_approx_eq polygamma (3 ,5 ) polygamma (3 ,5. )
356
387
357
388
@test @evalpoly (2 ,3 ,4 ,5 ,6 ) == 3 + 2 * (4 + 2 * (5 + 2 * 6 )) == @evalpoly (2 + 0im ,3 ,4 ,5 ,6 )
358
389
@test let evalcounts= 0
0 commit comments