-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Big-Float constructors for variable prec constants #1024
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a little repetitive. How about something like
(define (mpfr-of bf)
(match bf
((BFValue v) v)
((BFConst f) (f))))
With this, something like ==
would be:
(define (== a b)
(== (mpfr-of a) (mpfr-of b)))
without all of the case analysis. Unary functions are easier:
(define (lift f x)
(nest BFValue f mpfr-of x))
so you have
(define (sin x) (lift sin x))
Note that this approach does lead to some nonintuitive behavior. Some values are "privileged" while others are not. So something like
(define pi-1 (* 4 (atan 1))
(define pi-2 pi)
(set precision)
(== pi pi-2) ==> false
happens. I'm not sure if this is ok or not.
I don't agree with this solution. It adds additional overhead to all bigfloat computations. Pi and E should be made methods so that they alone incur the overhead. |
Would that be as simple as changing the class definitions from (:a) to (unit -> :a) and making sure it works for each type? If so I can throw together that alternative. |
the only "problem" with this, which may be minor, is that idk any programming language where something that looks like a constant is a function.
is just non-intuitive, since nobody would imagine pi to be a function or method, and there's no visual indication as such. FWIW, I don't think big float speed will be dominated by the cost of a few extra pattern matches. With that said, there's definitely a more fundamental problem here. |
Another option: Have both This would allow |
f12e0fa
to
03ccb89
Compare
I updated Big-Float according to the initial review |
785fbd5
to
0f135fd
Compare
0f135fd
to
fcc2d48
Compare
This addresses issue #1013
I've renamed the existing
sb-mpfr
compatibleBig-Float
type toMPFR-Float
type, and added a newBig-Float
type with two constructors:(BFValue MPFR-Float)
and(BFConst (:a -> MPFR-Float))
.This allows for constants to readjust to current precision.