File tree Expand file tree Collapse file tree 2 files changed +5
-16
lines changed Expand file tree Collapse file tree 2 files changed +5
-16
lines changed Original file line number Diff line number Diff line change 6060;; Maximum MPFR precision allowed during exact evaluation
6161(define *max-mpfr-prec* (make-parameter 10000 ))
6262
63- ;; When doing a binary search in regime inference,
64- ;; this is the fraction of the gap between two points that the search must reach
65- (define *epsilon-fraction* (/ 1 200 ))
66-
6763;; In periodicity analysis,
6864;; this is how small the period of a function must be to count as periodic
6965(define *max-period-coeff* 20 )
7369
7470(define *binary-search-test-points* (make-parameter 16 ))
7571
72+ ;; How accurate to make the binary search
73+ (define *binary-search-accuracy* (make-parameter 48 ))
74+
7675;;; About Herbie:
7776(define (run-command cmd)
7877 (parameterize ([current-error-port (open-output-nowhere)])
Original file line number Diff line number Diff line change 6464 (critical-subexpression? prog-body expr)))
6565 expr))
6666
67- (define basic-point-search (curry binary-search (λ (p1 p2)
68- (if (for/and ([val1 p1] [val2 p2])
69- (> *epsilon-fraction* (abs (- val1 val2))))
70- p1
71- (for/list ([val1 p1] [val2 p2])
72- (/ (+ val1 val2) 2 ))))))
73-
7467(define (used-alts splitpoints all-alts)
7568 (let ([used-indices (remove-duplicates (map sp-cidx splitpoints))])
7669 (map (curry list-ref all-alts) used-indices)))
131124;; (pred p1) and (not (pred p2))
132125(define (binary-search-floats pred p1 p2)
133126 (let ([midpoint (midpoint-float p1 p2)])
134- (cond [(= p1 p2) p1]
135- [(= p1 midpoint) p1]
136- [(= midpoint p2) p1]
127+ (cond [(< (bit-difference p1 p2) 48 ) midpoint]
137128 [(pred midpoint) (binary-search-floats pred midpoint p2)]
138- [#t (binary-search-floats pred p1 midpoint)])))
129+ [else (binary-search-floats pred p1 midpoint)])))
139130
140131;; Accepts a list of sindices in one indexed form and returns the
141132;; proper splitpoints in float form. A crucial constraint is that the
157148 [alt2 (list-ref alts (si-cidx next-sidx))]
158149 [p1 (eval-expr (list-ref points (si-pidx sidx)))]
159150 [p2 (eval-expr (list-ref points (sub1 (si-pidx sidx))))]
160- [eps (* (abs (ulp-difference p2 p1)) *epsilon-fraction*)]
161151 [pred (λ (v)
162152 (let* ([start-prog* (replace-expression (*start-prog*) expr v)]
163153 [prog1* (replace-expression (alt-program alt1) expr v)]
You can’t perform that action at this time.
0 commit comments