33
44use core:: f32;
55
6- use crate :: { CheckBasis , CheckCtx , Float , Int , TestResult } ;
6+ use CheckBasis :: { Mpfr , Musl } ;
7+ use Identifier as Id ;
8+
9+ use crate :: { CheckBasis , CheckCtx , Float , Identifier , Int , TestResult } ;
710
811/// Type implementing [`IgnoreCase`].
912pub struct SpecialCase ;
@@ -14,50 +17,42 @@ const MUSL_DEFAULT_ULP: u32 = 2;
1417/// Default ULP allowed to differ from multiprecision (i.e. infinite) results.
1518const MULTIPREC_DEFAULT_ULP : u32 = 1 ;
1619
17- /// ULP allowed to differ from muls results.
20+ /// ULP allowed to differ from the results returned by a test basis .
1821///
19- /// Note that these results were obtained using 400,000,000 rounds of random inputs, which
22+ /// Note that these results were obtained using 400M rounds of random inputs, which
2023/// is not a value used by default.
21- pub fn musl_allowed_ulp ( name : & str ) -> u32 {
22- // Consider overrides xfail
23- match name {
24- #[ cfg( x86_no_sse) ]
25- "asinh" | "asinhf" => 6 ,
26- "lgamma" | "lgamma_r" | "lgammaf" | "lgammaf_r" => 400 ,
27- "tanh" | "tanhf" => 4 ,
28- "tgamma" => 20 ,
29- "j0" | "j0f" | "j1" | "j1f" => {
24+ pub fn default_ulp ( ctx : & CheckCtx ) -> u32 {
25+ match ( & ctx. basis , ctx. fn_ident ) {
26+ // Overrides that apply to either basis
27+ ( _, Id :: J0 | Id :: J0f | Id :: J1 | Id :: J1f ) => {
3028 // Results seem very target-dependent
3129 if cfg ! ( target_arch = "x86_64" ) { 4000 } else { 800_000 }
3230 }
33- "jn" | "jnf" => 1000 ,
34- "sincosf" => 500 ,
35- #[ cfg( not( target_pointer_width = "64" ) ) ]
36- "exp10" => 4 ,
37- #[ cfg( not( target_pointer_width = "64" ) ) ]
38- "exp10f" => 4 ,
39- _ => MUSL_DEFAULT_ULP ,
40- }
41- }
31+ ( _, Id :: Jn | Id :: Jnf ) => 1000 ,
4232
43- /// ULP allowed to differ from multiprecision results.
44- pub fn multiprec_allowed_ulp ( name : & str ) -> u32 {
45- // Consider overrides xfail
46- match name {
47- "asinh" | "asinhf" => 2 ,
48- "acoshf" => 4 ,
49- "atanh" | "atanhf" => 2 ,
50- "exp10" | "exp10f" => 3 ,
51- "j0" | "j0f" | "j1" | "j1f" => {
52- // Results seem very target-dependent
53- if cfg ! ( target_arch = "x86_64" ) { 4000 } else { 800_000 }
54- }
55- "jn" | "jnf" => 1000 ,
56- "lgamma" | "lgammaf" | "lgamma_r" | "lgammaf_r" => 16 ,
57- "sinh" | "sinhf" => 2 ,
58- "tanh" | "tanhf" => 2 ,
59- "tgamma" => 20 ,
60- _ => MULTIPREC_DEFAULT_ULP ,
33+ // Overrides for musl
34+ #[ cfg( x86_no_sse) ]
35+ ( Musl , Id :: Asinh | Id :: Asinhf ) => 6 ,
36+ #[ cfg( not( target_pointer_width = "64" ) ) ]
37+ ( Musl , Id :: Exp10 | Id :: Exp10f ) => 4 ,
38+ ( Musl , Id :: Lgamma | Id :: LgammaR | Id :: Lgammaf | Id :: LgammafR ) => 400 ,
39+ ( Musl , Id :: Sincosf ) => 500 ,
40+ ( Musl , Id :: Tanh | Id :: Tanhf ) => 4 ,
41+ ( Musl , Id :: Tgamma ) => 20 ,
42+
43+ // Overrides for MPFR
44+ ( Mpfr , Id :: Acoshf ) => 4 ,
45+ ( Mpfr , Id :: Asinh | Id :: Asinhf ) => 2 ,
46+ ( Mpfr , Id :: Atanh | Id :: Atanhf ) => 2 ,
47+ ( Mpfr , Id :: Exp10 | Id :: Exp10f ) => 3 ,
48+ ( Mpfr , Id :: Lgamma | Id :: LgammaR | Id :: Lgammaf | Id :: LgammafR ) => 16 ,
49+ ( Mpfr , Id :: Sinh | Id :: Sinhf ) => 2 ,
50+ ( Mpfr , Id :: Tanh | Id :: Tanhf ) => 2 ,
51+ ( Mpfr , Id :: Tgamma ) => 20 ,
52+
53+ // Defaults
54+ ( Musl , _) => MUSL_DEFAULT_ULP ,
55+ ( Mpfr , _) => MULTIPREC_DEFAULT_ULP ,
6156 }
6257}
6358
0 commit comments