File tree Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 8585
8686(define mpfr-abs! (get-mpfr-fun 'mpfr_abs (_fun _mpfr-pointer _mpfr-pointer _rnd_t -> _int)))
8787
88+ (define mpfr-cmpabs (get-mpfr-fun 'mpfr_cmpabs (_fun _mpfr-pointer _mpfr-pointer -> _int)))
89+
8890(define mpfr-asin! (get-mpfr-fun 'mpfr_asin (_fun _mpfr-pointer _mpfr-pointer _rnd_t -> _int)))
8991
9092(define mpfr-acos! (get-mpfr-fun 'mpfr_acos (_fun _mpfr-pointer _mpfr-pointer _rnd_t -> _int)))
316318 mpfr-cbrt!
317319 mpfr-neg!
318320 mpfr-abs!
321+ mpfr-cmpabs
319322 mpfr-asin!
320323 mpfr-acos!
321324 mpfr-atan!
Original file line number Diff line number Diff line change 161161(define (ival-hypot! out x y)
162162 (define err? (or (ival-err? x) (ival-err? y)))
163163 (define err (or (ival-err x) (ival-err y)))
164- (define x* (ival-exact -fabs x))
165- (define y* (ival-exact -fabs y))
164+ (define x* (ival-pre -fabs x))
165+ (define y* (ival-pre -fabs y))
166166 (ival (eplinear! (ival-lo-val out) mpfr-hypot! (ival-lo x*) (ival-lo y*) 'down )
167167 (eplinear! (ival-hi-val out) mpfr-hypot! (ival-hi x*) (ival-hi y*) 'up )
168168 err?
Original file line number Diff line number Diff line change 1919 ival-max-prec
2020 ival-exact-neg
2121 ival-exact-fabs
22+ ival-pre-fabs
2223 bf-return-exact?
2324 ival-lo-fixed?
2425 ival-hi-fixed?
343344 (define abs-hi (epunary! tmp2 mpfr-abs! (ival-hi x) 'up ))
344345 (ival (endpoint (bf 0 ) (and xlo! xhi!)) (endpoint-max2 abs-lo abs-hi 'up ) xerr? xerr)]))
345346
347+ (define (ival-pre-fabs x)
348+ (match-define (ival xlo xhi xerr? xerr) x)
349+ (define match-result
350+ (match (classify-ival x)
351+ [1 x]
352+ [-1 (ival xhi xlo xerr? xerr)]
353+ [0
354+ (ival (endpoint 0.bf (and (endpoint-immovable? xlo) (endpoint-immovable? xhi)))
355+ (if (= (mpfr-cmpabs (endpoint-val xlo) (endpoint-val xhi)) 1 ) xlo xhi)
356+ xerr?
357+ xerr)]))
358+ match-result)
359+
346360;; These functions execute ival-fabs and ival-neg with input's precision
347361(define (ival-max-prec x)
348362 (max (bigfloat-precision (ival-lo-val x)) (bigfloat-precision (ival-hi-val x))))
Original file line number Diff line number Diff line change 139139 (ival-then (ival-assert ival-maybe) (ival-union (ival-neg pospow) pospow)))))
140140
141141(define (ival-pow2 x)
142- ((monotonic->ival (lambda (x) (bfmul x x))) (ival-exact -fabs x)))
142+ ((monotonic->ival (lambda (x) (bfmul x x))) (ival-pre -fabs x)))
143143
144144(define (ival-pow x y)
145145 (cond
You can’t perform that action at this time.
0 commit comments