|
10 | 10 |
|
11 | 11 | ;; WARNING: These aren't treated as preconditions, they are only used for range inference |
12 | 12 | (define *conditions* |
13 | | - `([acosh-def . (>= x 1)] |
14 | | - [atanh-def . (< (fabs x) 1)] |
15 | | - [asin-acos . (<= -1 x 1)] |
16 | | - [acos-asin . (<= -1 x 1)] |
17 | | - [acosh-2 . (>= x 1)] |
18 | | - [asinh-2 . (>= x 0)] |
19 | | - [sinh-acosh . (> (fabs x) 1)] |
20 | | - [sinh-atanh . (< (fabs x) 1)] |
21 | | - [cosh-atanh . (< (fabs x) 1)] |
22 | | - [tanh-acosh . (> (fabs x) 1)] |
23 | | - ;; These next three unquote the pi computation so that range analysis will work |
24 | | - [asin-sin-s . (<= (fabs x) ,(/ pi 2))] |
25 | | - [acos-cos-s . (<= 0 x ,pi)] |
26 | | - [atan-tan-s . (<= (fabs x) ,(/ pi 2))])) |
| 13 | + `([asinh-2 . (>= x 0)] |
| 14 | + ;; These next three approximate pi so that range analysis will work |
| 15 | + [asin-sin-s . (<= (fabs x) 1.5708)] |
| 16 | + [acos-cos-s . (<= 0 x 3.1415)] |
| 17 | + [atan-tan-s . (<= (fabs x) 1.5708)])) |
27 | 18 |
|
28 | 19 | (define (ival-ground-truth fv p repr) |
29 | | - (λ (x) (ival-eval (eval-prog `(λ ,fv ,p) 'ival repr) x repr))) |
| 20 | + (define prog (eval-prog `(λ ,fv ,p) 'ival repr)) |
| 21 | + (λ (x) (ival-eval prog x repr))) |
30 | 22 |
|
31 | 23 | (define ((with-hiprec f) x) |
32 | 24 | (parameterize ([bf-precision 2000]) (apply f x))) |
|
41 | 33 | (define repr (get-representation* otype)) |
42 | 34 |
|
43 | 35 | (define make-point |
44 | | - (let ([sample (make-sampler |
45 | | - repr |
46 | | - `(λ ,fv ,(dict-ref *conditions* name 'TRUE)) |
47 | | - `(λ ,fv ,p1) |
48 | | - `(λ ,fv ,p2))]) |
49 | | - (λ () |
50 | | - (if (dict-has-key? *conditions* name) |
51 | | - (sample) |
52 | | - (for/list ([v fv] [i (in-naturals)]) |
53 | | - (match (dict-ref (rule-itypes test-rule) v) |
54 | | - ['real (sample-double)] |
55 | | - ['complex (make-rectangular (sample-double) (sample-double))] |
56 | | - [rname (random-generate (get-representation rname))])))))) |
| 36 | + (make-sampler |
| 37 | + repr |
| 38 | + `(λ ,fv ,(dict-ref *conditions* name 'TRUE)) |
| 39 | + `(λ ,fv ,p1) |
| 40 | + `(λ ,fv ,p2))) |
57 | 41 |
|
58 | 42 | (define points (for/list ([n (in-range num-test-points)]) (make-point))) |
59 | 43 | (define prog1 (ground-truth fv p1 repr)) |
|
71 | 55 | (with-check-info (['point (map cons fv pt)] ['method (object-name ground-truth)] |
72 | 56 | ['input v1] ['output v2]) |
73 | 57 | (check-eq? (ulp-difference v1 v2 repr) 1)))) |
74 | | - (when (< (length errs) (/ num-test-points 10)) |
75 | | - (fail-check "Not enough points sampled to test rule"))) |
| 58 | + (define usable-fraction (/ (length errs) num-test-points)) |
| 59 | + (cond |
| 60 | + [(< usable-fraction 1/10) |
| 61 | + (fail-check "Not enough points sampled to test rule")] |
| 62 | + [(< usable-fraction 8/10) |
| 63 | + (eprintf "~a: ~a% of points usable\n" name |
| 64 | + (~r (* 100 usable-fraction) #:precision '(= 1)))])) |
76 | 65 |
|
77 | 66 | (define (check-rule-fp-safe test-rule) |
78 | 67 | (match-define (rule name p1 p2 itypes otype) test-rule) |
|
0 commit comments