Use lifted Racket math definitions

Continue to provide the same definitions, but lift the Racket ones
rather than rewrite and redefine them.
This commit is contained in:
Patrick Mahoney 2012-08-21 14:34:57 -04:00 committed by Gregory Cooper
parent 65ace21d22
commit 4ecc0525e7

View File

@ -1,50 +1,18 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; math.rkt: some extra math routines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module math frtime/frtime-lang-only
(provide e
pi
sqr
sgn conjugate
sinh cosh)
(define (sqr z) (* z z))
;; circular constants and aliases
(define e (exp 1.0))
(define pi (atan 0 -1))
;; sgn function
(define sgn
(lambda (x)
(if (exact? x)
(cond
((< x 0) -1)
((> x 0) 1)
(else 0))
(cond
((< x 0.0) -1.0)
((> x 0.0) 1.0)
(else 0.0)))))
;; complex conjugate
(define conjugate
(lambda (z)
(make-rectangular
(real-part z)
(- (imag-part z)))))
;; real hyperbolic functions
(define sinh
(lambda (x)
(/
(- (exp x) (exp (- x)))
2.0)))
(define cosh
(lambda (x)
(/
(+ (exp x) (exp (- x)))
2.0))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; math.rkt: some extra math routines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module math frtime/frtime-lang-only
(require (only-in racket/math pi sqr sgn conjugate sinh cosh))
(provide (lifted
sqr
sgn conjugate
sinh cosh))
(provide pi e)
;; circular constants and aliases
(define e (exp 1.0)))