[gambit-list] Proposed patch
Marc Feeley
feeley at iro.umontreal.ca
Tue Dec 10 09:38:36 EST 2013
On Dec 9, 2013, at 10:28 PM, Bradley Lucier <lucier at math.purdue.edu> wrote:
> I think we could have more discussion of proposed patches on this list, if we like.
>
> So here's a proposed patch for your consideration, with a real changelog entry ;-):
>
> lib/_num#.scm: Add (macro-inexact-+pi/4) and (macro-inexact-+3pi/4).
Fine.
> lib/_num.scm: Add ##flsquare, ##square, and square.
Is the naming consistent with other Schemes?
> Add ##exact-int.negative?
Fine.
> Use it in ##abs. Add functions from Kahan's paper: ##kahan.abs, ##kahan.arg,
> ##kahan.cssqs, ##kahan.csqrt, ##kahan.cacos, ##kahan.casin, ##kahan.casinh,
> ##kahan.catanh, ##kahan.ctanh, ##kahan.ctan; and constants ##kahan.omega,
> ##kahan.epsilon, ##kahan.lambda.
I dislike the naming. Is "kahan" the best prefix? In any case, for consistency with the rest, it should be "kahan-" not "kahan." because the prefix "T." is used to name functions related to type T. Kahan is not a type (or is it?).
> Add functions ##conjugate and conjugate.
Is the naming consistent with other Schemes?
> In ##log, use ##fllog1p for arguments near 1. In ##sin and ##cos, use real trigonometric
> and hyperbolic functions for complex arguments. In ##tan, use ##tanh for complex
> arguments. In ##casin, use ##kahan.casin. In ##acos, use ##kahan.acos. In
> ##atan, use ##atanh. In ##atan2, use Kahan's conventions for infinite arguments.
> ##sinh, sinh, ##cosh, cosh, ##tanh, tanh, ##asinh, asinh, ##acosh, acosh, ##atanh,
> atanh: New functions. In ##sqrt: Use ##kahan.csqrt for complex arguments. In
> ##magnitude: use ##exact-int.negative? for ratnum arguments and ##kahan.abs for
> complex arguments.
Fine.
> lib:gambit#.scm: Add entries for acosh, asinh, atanh, conjugate, cosh, sinh, square,
> and atanh.
Fine.
> Marc: I'd like to have the compiler recognize ##flsquare.
Easy.
> I'll attach the patch. I would really appreciate any comments.
What is missing for this patch is a bunch of unit tests. Each of the new inlined primitives should be tested for precision (after all, that is why they were added, so unit tests should verify this).
For example:
;;; flsinh.scm
(include "~~unit-testing/inlined-primitive.scm")
(check-equal? (##flsinh +0.0) +0.0)
(check-equal? (##flsinh -0.0) -0.0)
(check-equal? (##flsinh +inf.0) +inf.0)
(check-equal? (##flsinh -inf.0) -inf.0)
(check-= (##flsinh 1.0) 1.1752011936438014 2e-16)
We need thousands of unit tests like this for Gambit.
Marc
More information about the Gambit-list
mailing list