Skip to content

Commit

Permalink
slight changes to make code look better + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
AYadrov committed Jan 21, 2025
1 parent 39a4b18 commit d371c13
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 57 deletions.
1 change: 0 additions & 1 deletion src/core/sampling.rkt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#lang racket
(require math/bigfloat
math/flonum
rival
math/base
(only-in fpbench interval range-table-ref condition->range-table [expr? fpcore-expr?]))
Expand Down
12 changes: 7 additions & 5 deletions src/core/searchreals.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@
(+ 1 (- (->ordinal (ival-hi interval)) (->ordinal (ival-lo interval)))))))

(define (search-step compiler space split-var)
(define (drop-hints-from-rects rect)
(match rect
[(cons _ rect*) rect*]
[_ rect]))

(define vars (real-compiler-vars compiler))
(define reprs (real-compiler-var-reprs compiler))
(match-define (search-space true false other) space)
(define-values (true* false* other*)
(for/fold ([true* true]
[false* false]
[other* '()])
([rect (in-list other)])
; if a rect has a hint stored already then drop that hint
(when (not (equal? (length vars) (length rect)))
(set! rect (rest rect)))

([rect (in-list (map drop-hints-from-rects other))])
(match-define (list (ival err err?) hint converged?)
(real-compiler-analyze compiler (list->vector rect)))
(when (eq? err 'unsamplable)
Expand Down Expand Up @@ -72,6 +73,7 @@

(define (make-sampling-table reprs true false other)
(define denom (total-weight reprs))
; map rest = drop hint
(define true-weight (apply + (map (curryr hyperrect-weight reprs) (map rest true))))
(define false-weight (apply + (map (curryr hyperrect-weight reprs) false)))
(define other-weight (apply + (map (curryr hyperrect-weight reprs) (map rest other))))
Expand Down
113 changes: 62 additions & 51 deletions src/syntax/syntax.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -94,65 +94,76 @@
;; Rival-supported operators

; real constants (encoded as nullary operators)
(define-operators [PI : -> real] [E : -> real] [INFINITY : -> real] [NAN : -> real])
(define-operators
[PI : -> real]
[E : -> real]
[INFINITY : -> real]
[NAN : -> real])

; boolean constants (encoded as nullary operators)
(define-operators [TRUE : -> bool] [FALSE : -> bool])
(define-operators
[TRUE : -> bool]
[FALSE : -> bool])

; boolean operators
(define-operators [not : bool -> bool] [and : bool bool -> bool] [or : bool bool -> bool])
(define-operators
[not : bool -> bool]
[and : bool bool -> bool]
[or : bool bool -> bool])

; real-boolean operators
(define-operators [== : real real -> bool]
[!= : real real -> bool]
[< : real real -> bool]
[> : real real -> bool]
[<= : real real -> bool]
[>= : real real -> bool])
(define-operators
[== : real real -> bool]
[!= : real real -> bool]
[< : real real -> bool]
[> : real real -> bool]
[<= : real real -> bool]
[>= : real real -> bool])

; real operators
(define-operators [acos : real -> real]
[acosh : real -> real]
[asin : real -> real]
[asinh : real -> real]
[atan : real -> real]
[atanh : real -> real]
[cbrt : real -> real]
[ceil : real -> real]
[cos : real -> real]
[cosh : real -> real]
[erf : real -> real]
[exp : real -> real]
[exp2 : real -> real]
[fabs : real -> real]
[floor : real -> real]
[lgamma : real -> real]
[log : real -> real]
[log10 : real -> real]
[log2 : real -> real]
[logb : real -> real]
[neg : real -> real]
[rint : real -> real]
[round : real -> real]
[sin : real -> real]
[sinh : real -> real]
[sqrt : real -> real]
[tan : real -> real]
[tanh : real -> real]
[tgamma : real -> real]
[trunc : real -> real]
[+ : real real -> real]
[- : real real -> real]
[* : real real -> real]
[/ : real real -> real]
[atan2 : real real -> real]
[copysign : real real -> real]
[fdim : real real -> real]
[fmax : real real -> real]
[fmin : real real -> real]
[fmod : real real -> real]
[pow : real real -> real]
[remainder : real real -> real])
(define-operators
[acos : real -> real]
[acosh : real -> real]
[asin : real -> real]
[asinh : real -> real]
[atan : real -> real]
[atanh : real -> real]
[cbrt : real -> real]
[ceil : real -> real]
[cos : real -> real]
[cosh : real -> real]
[erf : real -> real]
[exp : real -> real]
[exp2 : real -> real]
[fabs : real -> real]
[floor : real -> real]
[lgamma : real -> real]
[log : real -> real]
[log10 : real -> real]
[log2 : real -> real]
[logb : real -> real]
[neg : real -> real]
[rint : real -> real]
[round : real -> real]
[sin : real -> real]
[sinh : real -> real]
[sqrt : real -> real]
[tan : real -> real]
[tanh : real -> real]
[tgamma : real -> real]
[trunc : real -> real]
[+ : real real -> real]
[- : real real -> real]
[* : real real -> real]
[/ : real real -> real]
[atan2 : real real -> real]
[copysign : real real -> real]
[fdim : real real -> real]
[fmax : real real -> real]
[fmin : real real -> real]
[fmod : real real -> real]
[pow : real real -> real]
[remainder : real real -> real])

(module+ test
; check expected number of operators
Expand Down

0 comments on commit d371c13

Please sign in to comment.