93
93
@test_throws MethodError ellipe (BigFloat (- 1 ))
94
94
@test_throws DomainError ellipe (Float16 (2.0 ))
95
95
@test_throws DomainError ellipe (Float32 (2.5 ))
96
- end
96
+ end
97
97
@testset " sine and cosine integrals" begin
98
98
# Computed via wolframalpha.com: SinIntegral[SetPrecision[Table[x,{x, 1,20,1}],20]] and CosIntegral[SetPrecision[Table[x,{x, 1,20,1}],20]]
99
99
sinintvals = [0.9460830703671830149 , 1.605412976802694849 , 1.848652527999468256 , 1.75820313894905306 , 1.54993124494467414 , 1.4246875512805065 , 1.4545966142480936 , 1.5741868217069421 , 1.665040075829602 , 1.658347594218874 , 1.578306806945727416 , 1.504971241526373371 , 1.499361722862824564 , 1.556211050077665054 , 1.618194443708368739 , 1.631302268270032886 , 1.590136415870701122 , 1.536608096861185462 , 1.518630031769363932 , 1.548241701043439840 ]
@@ -135,13 +135,13 @@ end
135
135
@test_throws AmosException airyai (200im )
136
136
@test_throws AmosException airybi (200 )
137
137
138
- for T in [Float32, Float64, Complex{Float32},Complex{Float64}]
138
+ for T in [Float16, Float32, Float64,Complex{Float16} , Complex{Float32},Complex{Float64}]
139
139
@test airyai (T (1.8 )) ≈ 0.0470362168668458052247
140
140
@test airyaiprime (T (1.8 )) ≈ - 0.0685247801186109345638
141
141
@test airybi (T (1.8 )) ≈ 2.595869356743906290060
142
142
@test airybiprime (T (1.8 )) ≈ 2.98554005084659907283
143
143
end
144
- for T in [Complex{Float32}, Complex{Float64}]
144
+ for T in [Complex{Float16}, Complex{ Float32}, Complex{Float64}]
145
145
z = convert (T,1.8 + 1.0im )
146
146
@test airyaix (z) ≈ airyai (z) * exp (2 / 3 * z * sqrt (z))
147
147
@test airyaiprimex (z) ≈ airyaiprime (z) * exp (2 / 3 * z * sqrt (z))
172
172
@testset " $z , $o " for (z, o, f) in bessel_funcs
173
173
@test z (Float32 (2.0 )) ≈ z (Float64 (2.0 ))
174
174
@test o (Float32 (2.0 )) ≈ o (Float64 (2.0 ))
175
+ @test z (Float16 (2.0 )) ≈ z (Float64 (2.0 ))
176
+ @test o (Float16 (2.0 )) ≈ o (Float64 (2.0 ))
175
177
@test z (2 ) ≈ z (2.0 )
176
178
@test o (2 ) ≈ o (2.0 )
177
179
@test z (2.0 + im) ≈ f (0 , 2.0 + im)
187
189
true_h133 = 0.30906272225525164362 - 0.53854161610503161800im
188
190
@test besselh (3 ,1 ,3 ) ≈ true_h133
189
191
@test besselh (- 3 ,1 ,3 ) ≈ - true_h133
192
+ @test besselh (Float32 (3 ),1 ,Float32 (3 )) ≈ true_h133
193
+ @test besselh (Float16 (3 ),1 ,Float16 (3 )) ≈ true_h133
190
194
@test besselh (3 ,2 ,3 ) ≈ conj (true_h133)
191
195
@test besselh (- 3 ,2 ,3 ) ≈ - conj (true_h133)
192
196
@testset " Error throwing" begin
@@ -204,12 +208,15 @@ end
204
208
@test besseli (3 ,- 3 ) ≈ - true_i33
205
209
@test besseli (- 3 ,- 3 ) ≈ - true_i33
206
210
@test besseli (Float32 (- 3 ),Complex {Float32} (- 3 ,0 )) ≈ - true_i33
211
+ @test besseli (Float16 (- 3 ),Complex {Float16} (- 3 ,0 )) ≈ - true_i33
207
212
true_im3p1_3 = 0.84371226532586351965
208
213
@test besseli (- 3.1 ,3 ) ≈ true_im3p1_3
209
214
for i in [- 5 - 3 - 1 1 3 5 ]
210
215
@test besseli (i,0 ) == 0.0
211
216
@test besseli (i,Float32 (0 )) == 0
212
217
@test besseli (i,Complex {Float32} (0 )) == 0
218
+ @test besseli (i,Float16 (0 )) == 0
219
+ @test besseli (i,Complex {Float16} (0 )) == 0
213
220
end
214
221
@testset " Error throwing" begin
215
222
@test_throws AmosException besseli (1 ,1000 )
225
232
for i in [- 5 - 3 - 1 1 3 5 ]
226
233
@test besselj (i,0 ) == 0
227
234
@test besselj (i,Float32 (0 )) == 0
228
- @test besselj (i,Complex {Float32} (0 )) == 0
235
+ @test besselj (i,Complex {Float32} (0 )) == 0.0
229
236
end
230
237
231
238
j33 = besselj (3 ,3. )
257
264
258
265
true_jm3p1_3 = - 0.45024252862270713882
259
266
@test besselj (- 3.1 ,3 ) ≈ true_jm3p1_3
267
+ @test besselj (Float16 (- 3.1 ),Float16 (3 )) ≈ true_jm3p1_3
260
268
261
269
@testset " Error throwing" begin
262
270
@test_throws DomainError besselj (0.1 , - 0.4 )
268
276
@testset " besselk" begin
269
277
true_k33 = 0.12217037575718356792
270
278
@test besselk (3 ,3 ) ≈ true_k33
279
+ @test besselk (Float32 (3 ),Float32 (3 )) ≈ true_k33
280
+ @test besselk (Float16 (3 ),Float16 (3 )) ≈ true_k33
271
281
@test besselk (- 3 ,3 ) ≈ true_k33
272
282
true_k3m3 = - 0.1221703757571835679 - 3.0151549516807985776im
273
283
@test besselk (3 ,complex (- 3 )) ≈ true_k3m3
311
321
end
312
322
313
323
@testset " besselhx" begin
314
- for elty in [Complex{Float32},Complex{Float64}]
324
+ for elty in [Complex{Float16},Complex{ Float32},Complex{Float64}]
315
325
z = convert (elty, 1.0 + 1.9im )
316
326
@test besselhx (1.0 , 1 , z) ≈ convert (elty,- 0.5949634147786144 - 0.18451272807835967im )
317
327
@test besselhx (Float32 (1.0 ), 1 , z) ≈ convert (elty,- 0.5949634147786144 - 0.18451272807835967im )
341
351
@test besselix (i,Float32 (0 )) == 0
342
352
@test besseljx (i,Complex {Float32} (0 )) == 0
343
353
@test besselix (i,Complex {Float32} (0 )) == 0
354
+ @test besseljx (i,Float16 (0 )) == 0
355
+ @test besselix (i,Float16 (0 )) == 0
356
+ @test besseljx (i,Complex {Float16} (0 )) == 0
357
+ @test besselix (i,Complex {Float16} (0 )) == 0
344
358
end
345
359
@testset " Error throwing" begin
346
360
@test_throws AmosException hankelh1x (1 , 0 )
358
372
@testset " $f " for f in (besselj,bessely,besseli,besselk,hankelh1,hankelh2)
359
373
@test f (0 ,1 ) ≈ f (0 ,Complex {Float64} (1 ))
360
374
@test f (0 ,1 ) ≈ f (0 ,Complex {Float32} (1 ))
375
+ @test f (0 ,1 ) ≈ f (0 ,Complex {Float16} (1 ))
361
376
end
362
377
end
363
378
end
596
611
end
597
612
598
613
@test sprint (showerror, AmosException (1 )) == " AmosException with id 1: input error."
599
-
600
614
# Used to check method existence below
601
615
struct NotAFloat <: AbstractFloat
602
616
end
664
678
@test lgamma (- Inf * im) === - Inf - Inf * im
665
679
@test lgamma (Inf + Inf * im) === lgamma (NaN + 0im ) === lgamma (NaN * im) === NaN + NaN * im
666
680
end
667
-
668
681
@testset " Other float types" begin
669
682
let x = one (Float16)
670
683
@test gamma (x) ≈ one (Float16)
0 commit comments