File tree Expand file tree Collapse file tree 3 files changed +18
-13
lines changed Expand file tree Collapse file tree 3 files changed +18
-13
lines changed Original file line number Diff line number Diff line change 4040
4141(define (shift bits fn)
4242 (define shift-val (expt 2 bits))
43- (λ (x) (fn (- x shift-val) )))
43+ (λ (x) (+ (fn x) shift-val)))
4444
4545(define (unshift bits fn)
4646 (define shift-val (expt 2 bits))
47- (λ (x) (+ (fn x) shift-val)))
47+ (λ (x) (fn (- x shift-val) )))
4848
4949(define-representation (binary64 real)
5050 bigfloat->flonum
5151 bf
52- (shift 63 ordinal->flonum)
53- (unshift 63 flonum->ordinal)
52+ (unshift 63 ordinal->flonum)
53+ (shift 63 flonum->ordinal)
5454 64
5555 '(+nan.0 +inf.0 -inf.0 ))
5656
Original file line number Diff line number Diff line change 1414
1515(define (fpcore->string core)
1616 (match-define (list 'FPCore args props ... expr) core)
17- (define props*
18- (for/list ([val (apply dict-set* '() props)])
17+ (define props* ; make sure each property (name, value) gets put on the same line
18+ (for/list ([val (apply dict-set* '() props)]) ; how to make a list of pairs from a list
1919 (format "~a ~a " (car val) (cdr val))))
20- (with-output-to-string
21- (λ () (pretty-display `(,(format "FPCore ~a " args) ,@props* ,expr)))))
20+ (pretty-format `(,(format "FPCore ~a " args) ,@props* ,expr) #:mode 'display ))
2221
2322(define/contract (render-menu sections links)
2423 (-> (listof (cons/c string? string?)) (listof (cons/c string? string?)) xexpr?)
Original file line number Diff line number Diff line change 245245 (if (number? axis)
246246 (λ x (list-ref x axis))
247247 (eval-prog `(λ ,vars ,axis) 'fl )))
248+
249+ ; works for binary64, binary32 (probably not for posits)
250+ (define-values (maxbound minbound)
251+ (let ([hi (sub1 ((representation-repr->ordinal repr) (fl->repr +inf.0 repr)))]
252+ [lo (add1 ((representation-repr->ordinal repr) (fl->repr -inf.0 repr)))])
253+ (values ((representation-ordinal->repr repr) hi)
254+ ((representation-ordinal->repr repr) lo))))
255+
248256 (define eby (errors-by get-coord errs pts))
249257 (define histogram-f (histogram-function eby #:bin-size bin-size))
250258 (define (avg-fun x)
251259 (define h (histogram-f x))
252260 (/ (apply + (vector->list h)) (vector-length h)))
253- (define-values (min max) ; plot requires rational bounds
261+ (define-values (min* max* ) ; plot requires finite bounds
254262 (match* ((car (first eby)) (car (last eby)))
255263 [(x x) (values #f #f )]
256- [(x y)
257- (values (flmax (flnext -inf.0 ) (repr->fl x repr)) ; hence this trick
258- (flmin (flprev +inf.0 ) (repr->fl y repr)))]))
259- (function avg-fun min max #:width 2 #:color (color-theme-fit color)))
264+ [(x y) (values (max minbound x) (min maxbound y))])) ; hence this
265+ (function avg-fun min* max* #:width 2 #:color (color-theme-fit color)))
260266
261267(define (error-mark x-val)
262268 (inverse (const x-val) #:color "gray " #:width 3 ))
You can’t perform that action at this time.
0 commit comments