|
35 | 35 | (or (ival-err x) (ival-err y)))) |
36 | 36 |
|
37 | 37 | (define (ival-add x y) |
38 | | - (ival-add! (new-ival) x y)) |
| 38 | + (ival-add! (new-ival (bf-precision)) x y)) |
39 | 39 |
|
40 | 40 | (define (ival-sub! out x y) |
41 | 41 | (ival (eplinear! (ival-lo-val out) mpfr-sub! (ival-lo x) (ival-hi y) 'down) |
|
44 | 44 | (or (ival-err x) (ival-err y)))) |
45 | 45 |
|
46 | 46 | (define (ival-sub x y) |
47 | | - (ival-sub! (new-ival) x y)) |
| 47 | + (ival-sub! (new-ival (bf-precision)) x y)) |
48 | 48 |
|
49 | 49 | (define (epmul! out a-endpoint b-endpoint a-class b-class) |
50 | 50 | (match-define (endpoint a a!) a-endpoint) |
|
66 | 66 | (and b! (bfinfinite? b) (not (= a-class 0)))))) |
67 | 67 |
|
68 | 68 | (define (ival-mult x y) |
69 | | - (ival-mult! (new-ival) x y)) |
| 69 | + (ival-mult! (new-ival (bf-precision)) x y)) |
70 | 70 |
|
71 | | -(define extra-mult-ival (new-ival)) |
| 71 | +(define extra-mult-ival-prec (*rival-max-precision*)) |
| 72 | +(define extra-mult-ival (new-ival extra-mult-ival-prec)) |
72 | 73 |
|
73 | 74 | (define (ival-mult! out x y) |
74 | 75 | (match-define (ival xlo xhi xerr? xerr) x) |
|
96 | 97 | ;; Here, the two branches of the union are meaningless on their own; |
97 | 98 | ;; however, both branches compute possible lo/hi's to min/max together |
98 | 99 | [(0 0) |
| 100 | + (when (< extra-mult-ival-prec (*rival-max-precision*)) |
| 101 | + (set! extra-mult-ival-prec (*rival-max-precision*)) |
| 102 | + (set! extra-mult-ival (new-ival extra-mult-ival-prec))) |
99 | 103 | (match-define (ival (endpoint lo lo!) (endpoint hi hi!) err? err) |
100 | 104 | (ival-union (mkmult extra-mult-ival xhi ylo xlo ylo) (mkmult out xlo yhi xhi yhi))) |
101 | 105 | (mpfr-set! (ival-lo-val out) lo 'down) ; should be exact |
|
145 | 149 | [(0 -1) (mkdiv xhi yhi xlo yhi)])) |
146 | 150 |
|
147 | 151 | (define (ival-div x y) |
148 | | - (ival-div! (new-ival) x y)) |
| 152 | + (ival-div! (new-ival (bf-precision)) x y)) |
149 | 153 |
|
150 | 154 | (define (ival-fma a b c) |
151 | 155 | (ival-add (ival-mult a b) c)) |
|
0 commit comments