File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Expand file tree Collapse file tree 4 files changed +18
-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)))
318320 mpfr-cbrt!
319321 mpfr-neg!
320322 mpfr-abs!
323+ mpfr-cmpabs
321324 mpfr-asin!
322325 mpfr-acos!
323326 mpfr-atan!
Original file line number Diff line number Diff line change 159159(define (ival-hypot! out x y)
160160 (define err? (or (ival-err? x) (ival-err? y)))
161161 (define err (or (ival-err x) (ival-err y)))
162- (match-define (ival (endpoint xlo xlo!) (endpoint xhi xhi!) _ _ ) (ival-exact -fabs x))
163- (match-define (ival (endpoint ylo ylo!) (endpoint yhi yhi!) _ _ ) (ival-exact -fabs y))
162+ (match-define (ival (endpoint xlo xlo!) (endpoint xhi xhi!) _ _ ) (ival-pre -fabs x))
163+ (match-define (ival (endpoint ylo ylo!) (endpoint yhi yhi!) _ _ ) (ival-pre -fabs y))
164164 (define-values (lo lo!) (eplinear! (ival-lo-val out) mpfr-hypot! xlo xlo! ylo ylo! 'down ))
165165 (define-values (hi hi!) (eplinear! (ival-hi-val out) mpfr-hypot! xhi xhi! yhi yhi! 'up ))
166166 (ival (endpoint lo lo!) (endpoint hi hi!) err? 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?
385386 (define abs-hi (epunary! tmp2 mpfr-abs! (ival-hi x) 'up ))
386387 (ival (endpoint (bf 0 ) (and xlo! xhi!)) (endpoint-max2 abs-lo abs-hi 'up ) xerr? xerr)]))
387388
389+ (define (ival-pre-fabs x)
390+ (match-define (ival xlo xhi xerr? xerr) x)
391+ (match (classify-ival x)
392+ [1 x]
393+ [-1 (ival xhi xlo xerr? xerr)]
394+ [0
395+ (ival (endpoint 0.bf (and (endpoint-immovable? xlo) (endpoint-immovable? xhi)))
396+ (if (> (mpfr-cmpabs (endpoint-val xlo) (endpoint-val xhi)) 0 ) xlo xhi)
397+ xerr?
398+ xerr)]))
399+
388400;; These functions execute ival-fabs and ival-neg with input's precision
389401(define (ival-max-prec x)
390402 (max (bigfloat-precision (ival-lo-val x)) (bigfloat-precision (ival-hi-val x))))
Original file line number Diff line number Diff line change 153153 (ival-then (ival-assert ival-maybe) (ival-union (ival-neg pospow) pospow)))))
154154
155155(define (ival-pow2 x)
156- ((monotonic->ival (lambda (x) (bfmul x x))) (ival-exact -fabs x)))
156+ ((monotonic->ival (lambda (x) (bfmul x x))) (ival-pre -fabs x)))
157157
158158(define (ival-pow x y)
159159 (cond
You can’t perform that action at this time.
0 commit comments