Skip to content

Commit 50cbae1

Browse files
committed
Rename epfn1/2 to epunary/binary
1 parent e0df50e commit 50cbae1

File tree

4 files changed

+31
-45
lines changed

4 files changed

+31
-45
lines changed

ops/core.rkt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
mk-big-ival
1515
new-ival
1616
ival-maybe
17-
epfn1
18-
epfn2
17+
epunary
18+
epbinary
1919
split-ival
2020
ival-max-prec
2121
ival-exact-neg
@@ -241,13 +241,12 @@
241241
(or xerr? yerr?)
242242
(and xerr yerr))]))
243243

244-
245244
;; These functions compute and propagate the immovable? flag for endpoints
246-
(define (epfn1 op arg)
245+
(define (epunary op arg)
247246
(define-values (result exact?) (bf-return-exact? op (list (endpoint-val arg))))
248247
(endpoint result (and (endpoint-immovable? arg) exact?)))
249248

250-
(define (epfn2 op arg0 arg1)
249+
(define (epbinary op arg0 arg1)
251250
(define-values (result exact?) (bf-return-exact? op (list (endpoint-val arg0) (endpoint-val arg1))))
252251
(endpoint result (and (endpoint-immovable? arg0) (endpoint-immovable? arg1) exact?)))
253252

@@ -294,11 +293,11 @@
294293

295294
(define ((monotonic bffn) x)
296295
(match-define (ival lo hi err? err) x)
297-
(ival (rnd 'down epfn1 bffn lo) (rnd 'up epfn1 bffn hi) err? err))
296+
(ival (rnd 'down epunary bffn lo) (rnd 'up epunary bffn hi) err? err))
298297

299298
(define ((comonotonic bffn) x)
300299
(match-define (ival lo hi err? err) x)
301-
(ival (rnd 'down epfn1 bffn hi) (rnd 'up epfn1 bffn lo) err? err))
300+
(ival (rnd 'down epunary bffn hi) (rnd 'up epunary bffn lo) err? err))
302301

303302
(define ((close-enough->ival bffn) x)
304303
(match-define (ival (endpoint lo lo!) (endpoint hi hi!) err? err) x)
@@ -390,7 +389,6 @@
390389
(define abs-hi (epunary! tmp2 mpfr-abs! (ival-hi x) 'up))
391390
(ival (endpoint (bf 0) (and xlo! xhi!)) (endpoint-max2 abs-lo abs-hi 'up) xerr? xerr)]))
392391

393-
394392
;; These functions execute ival-fabs and ival-neg with input's precision
395393
(define (ival-max-prec x)
396394
(max (bigfloat-precision (ival-lo-val x)) (bigfloat-precision (ival-hi-val x))))
@@ -665,8 +663,8 @@
665663
(define err? (or (ival-err? y) xerr?))
666664
(define err (or (ival-err y) xerr))
667665
(match* (can-neg can-pos)
668-
[(#t #t) (ival (rnd 'down epfn1 bfneg xhi) (rnd 'up epfn1 bfcopy xhi) err? err)]
669-
[(#t #f) (ival (rnd 'down epfn1 bfneg xhi) (rnd 'up epfn1 bfneg xlo) err? err)]
666+
[(#t #t) (ival (rnd 'down epunary bfneg xhi) (rnd 'up epunary bfcopy xhi) err? err)]
667+
[(#t #f) (ival (rnd 'down epunary bfneg xhi) (rnd 'up epunary bfneg xlo) err? err)]
670668
[(#f #t) (ival xlo xhi err? err)]
671669
[(#f #f)
672670
(unless (ival-err y)

ops/gamma.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
; Purely decreasing
4545
[(bflt? (endpoint-val hi) xmin) ((comonotonic->ival fn) i)]
4646
[else
47-
(ival-union (ival (endpoint ymin #f) (rnd 'up epfn1 fn lo) err? err)
48-
(ival (endpoint ymin #f) (rnd 'up epfn1 fn hi) err? err))]))
47+
(ival-union (ival (endpoint ymin #f) (rnd 'up epunary fn lo) err? err)
48+
(ival (endpoint ymin #f) (rnd 'up epunary fn hi) err? err))]))
4949

5050
; Optimized version of `ival-lgamma-basin` for positive values, adds a cache
5151
(define lgamma-pos-xmin #f)

ops/trig.rkt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
[1 ((comonotonic->ival (curry bfcosu n)) x)]
4343
[else
4444
(ival (rnd 'down
45-
epfn2
45+
epbinary
4646
bfmin2
47-
(epfn1 (curry bfcosu n) (ival-lo x))
48-
(epfn1 (curry bfcosu n) (ival-hi x)))
47+
(epunary (curry bfcosu n) (ival-lo x))
48+
(epunary (curry bfcosu n) (ival-hi x)))
4949
(endpoint 1.bf #f)
5050
(ival-err? x)
5151
(ival-err x))])]
@@ -59,18 +59,18 @@
5959
[(and (bf=? (bfsub b a) 1.bf) (bfeven? a))
6060
(ival (endpoint -1.bf #f)
6161
(rnd 'up
62-
epfn2
62+
epbinary
6363
bfmax2
64-
(epfn1 (curry bfcosu n) (ival-lo x))
65-
(epfn1 (curry bfcosu n) (ival-hi x)))
64+
(epunary (curry bfcosu n) (ival-lo x))
65+
(epunary (curry bfcosu n) (ival-hi x)))
6666
(ival-err? x)
6767
(ival-err x))]
6868
[(and (bf=? (bfsub b a) 1.bf) (bfodd? a))
6969
(ival (rnd 'down
70-
epfn2
70+
epbinary
7171
bfmin2
72-
(epfn1 (curry bfcosu n) (ival-lo x))
73-
(epfn1 (curry bfcosu n) (ival-hi x)))
72+
(epunary (curry bfcosu n) (ival-lo x))
73+
(epunary (curry bfcosu n) (ival-hi x)))
7474
(endpoint 1.bf #f)
7575
(ival-err? x)
7676
(ival-err x))]
@@ -86,7 +86,7 @@
8686
[-1 ((monotonic->ival bfcos) x)]
8787
[1 ((comonotonic->ival bfcos) x)]
8888
[else
89-
(ival (rnd 'down epfn2 bfmin2 (epfn1 bfcos (ival-lo x)) (epfn1 bfcos (ival-hi x)))
89+
(ival (rnd 'down epbinary bfmin2 (epunary bfcos (ival-lo x)) (epunary bfcos (ival-hi x)))
9090
(endpoint 1.bf #f)
9191
(ival-err? x)
9292
(ival-err x))])]
@@ -99,11 +99,11 @@
9999
[(and (bf=? a b) (bfodd? a)) ((monotonic->ival bfcos) x)]
100100
[(and (bf=? (bfsub b a) 1.bf) (bfeven? a))
101101
(ival (endpoint -1.bf #f)
102-
(rnd 'up epfn2 bfmax2 (epfn1 bfcos (ival-lo x)) (epfn1 bfcos (ival-hi x)))
102+
(rnd 'up epbinary bfmax2 (epunary bfcos (ival-lo x)) (epunary bfcos (ival-hi x)))
103103
(ival-err? x)
104104
(ival-err x))]
105105
[(and (bf=? (bfsub b a) 1.bf) (bfodd? a))
106-
(ival (rnd 'down epfn2 bfmin2 (epfn1 bfcos (ival-lo x)) (epfn1 bfcos (ival-hi x)))
106+
(ival (rnd 'down epbinary bfmin2 (epunary bfcos (ival-lo x)) (epunary bfcos (ival-hi x)))
107107
(endpoint 1.bf #f)
108108
(ival-err? x)
109109
(ival-err x))]
@@ -126,18 +126,18 @@
126126
[(and (bf=? (bfsub b a) 1.bf) (bfodd? a))
127127
(ival (endpoint -1.bf #f)
128128
(rnd 'up
129-
epfn2
129+
epbinary
130130
bfmax2
131-
(epfn1 (curry bfsinu n) (ival-lo x))
132-
(epfn1 (curry bfsinu n) (ival-hi x)))
131+
(epunary (curry bfsinu n) (ival-lo x))
132+
(epunary (curry bfsinu n) (ival-hi x)))
133133
(ival-err? x)
134134
(ival-err x))]
135135
[(and (bf=? (bfsub b a) 1.bf) (bfeven? a))
136136
(ival (rnd 'down
137-
epfn2
137+
epbinary
138138
bfmin2
139-
(epfn1 (curry bfsinu n) (ival-lo x))
140-
(epfn1 (curry bfsinu n) (ival-hi x)))
139+
(epunary (curry bfsinu n) (ival-lo x))
140+
(epunary (curry bfsinu n) (ival-hi x)))
141141
(endpoint 1.bf #f)
142142
(ival-err? x)
143143
(ival-err x))]
@@ -159,11 +159,11 @@
159159
[(and (bf=? a b) (bfeven? a)) ((monotonic->ival bfsin) x)]
160160
[(and (bf=? (bfsub b a) 1.bf) (bfodd? a))
161161
(ival (endpoint -1.bf #f)
162-
(rnd 'up epfn2 bfmax2 (epfn1 bfsin (ival-lo x)) (epfn1 bfsin (ival-hi x)))
162+
(rnd 'up epbinary bfmax2 (epunary bfsin (ival-lo x)) (epunary bfsin (ival-hi x)))
163163
(ival-err? x)
164164
(ival-err x))]
165165
[(and (bf=? (bfsub b a) 1.bf) (bfeven? a))
166-
(ival (rnd 'down epfn2 bfmin2 (epfn1 bfsin (ival-lo x)) (epfn1 bfsin (ival-hi x)))
166+
(ival (rnd 'down epbinary bfmin2 (epunary bfsin (ival-lo x)) (epunary bfsin (ival-hi x)))
167167
(endpoint 1.bf #f)
168168
(ival-err? x)
169169
(ival-err x))]

test.rkt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@
33
(require racket/math
44
math/base
55
math/flonum
6-
(only-in math/bigfloat
7-
bf>
8-
bf<
9-
bf=
10-
bf>=
11-
bf<=
12-
bf-
13-
bf+
14-
bf*
15-
bf/
16-
bfmin
17-
bfmax
18-
bfshift))
6+
(only-in math/bigfloat bf> bf< bf= bf>= bf<= bf- bf+ bf* bf/ bfmin bfmax bfshift))
197
(require rackunit)
208
(require "main.rkt"
219
"mpfr.rkt")

0 commit comments

Comments
 (0)