|
17 | 17 | epfn |
18 | 18 | split-ival |
19 | 19 | ival-max-prec |
| 20 | + ival-exact-neg |
| 21 | + ival-exact-fabs |
20 | 22 | bf-return-exact? |
21 | 23 | ival-lo-fixed? |
22 | 24 | ival-hi-fixed? |
|
191 | 193 | (define (endpoint-min2 e1 e2 rnd) |
192 | 194 | (match-define (endpoint x x!) e1) |
193 | 195 | (match-define (endpoint y y!) e2) |
194 | | - (define out |
195 | | - (parameterize ([bf-precision (bf-precision)]) |
196 | | - (bf 0))) |
| 196 | + (define out (bf 0)) |
197 | 197 | (mpfr-min! out x y rnd) |
198 | 198 | (endpoint out (or (and (bf=? out x) x!) (and (bf=? out y) y!)))) |
199 | 199 |
|
200 | 200 | (define (endpoint-max2 e1 e2 rnd) |
201 | 201 | (match-define (endpoint x x!) e1) |
202 | 202 | (match-define (endpoint y y!) e2) |
203 | | - (define out |
204 | | - (parameterize ([bf-precision (bf-precision)]) |
205 | | - (bf 0))) |
| 203 | + (define out (bf 0)) |
206 | 204 | (mpfr-max! out x y rnd) |
207 | 205 | (endpoint out (or (and (bf=? out x) x!) (and (bf=? out y) y!)))) |
208 | 206 |
|
|
349 | 347 | (define (ival-max-prec x) |
350 | 348 | (max (bigfloat-precision (ival-lo-val x)) (bigfloat-precision (ival-hi-val x)))) |
351 | 349 |
|
| 350 | +(define (ival-exact-fabs x) |
| 351 | + (parameterize ([bf-precision (ival-max-prec x)]) |
| 352 | + (ival-fabs x))) |
| 353 | + |
| 354 | +(define (ival-exact-neg x) |
| 355 | + (parameterize ([bf-precision (ival-max-prec x)]) |
| 356 | + (ival-neg x))) |
| 357 | + |
352 | 358 | ;; Since MPFR has a cap on exponents, no value can be more than twice MAX_VAL |
353 | 359 | (define exp-overflow-threshold (bfadd (bflog (bfprev +inf.bf)) 1.bf)) |
354 | 360 | (define exp2-overflow-threshold (bfadd (bflog2 (bfprev +inf.bf)) 1.bf)) |
|
369 | 375 | (define* ival-log2 (compose (monotonic-mpfr mpfr-log2!) (clamp-strict 0.bf +inf.bf))) |
370 | 376 | (define* ival-log10 (compose (monotonic-mpfr mpfr-log10!) (clamp-strict 0.bf +inf.bf))) |
371 | 377 | (define* ival-log1p (compose (monotonic-mpfr mpfr-log1p!) (clamp-strict -1.bf +inf.bf))) |
372 | | -[define* ival-logb (compose ival-floor ival-log2 ival-fabs)] |
| 378 | +[define* ival-logb (compose ival-floor ival-log2 ival-exact-fabs)] |
373 | 379 |
|
374 | 380 | (define* ival-sqrt (compose (monotonic-mpfr mpfr-sqrt!) (clamp 0.bf +inf.bf))) |
375 | 381 | (define* ival-cbrt (monotonic-mpfr mpfr-cbrt!)) |
|
427 | 433 | (compose (overflows-at (monotonic-mpfr mpfr-cosh!) |
428 | 434 | (bfneg acosh-overflow-threshold) |
429 | 435 | acosh-overflow-threshold) |
430 | | - ival-fabs)) |
| 436 | + ival-exact-fabs)) |
431 | 437 | (define* |
432 | 438 | ival-sinh |
433 | 439 | (overflows-at (monotonic-mpfr mpfr-sinh!) (bfneg sinh-overflow-threshold) sinh-overflow-threshold)) |
|
0 commit comments