-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rkt
47 lines (39 loc) · 1.61 KB
/
main.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#lang racket/base
(require herbie/plugin
ffi/unsafe)
(eprintf "Loading fdlibm-accelerators...\n")
(module test racket/base)
(define log.fdlibm (get-ffi-obj "log" "fdlibm-pieces" (_fun _double -> _double)))
(define log1p.fdlibm (get-ffi-obj "log1p" "fdlibm-pieces" (_fun _double -> _double)))
(define log1pmd.fdlibm (get-ffi-obj "log1pmd" "fdlibm-pieces" (_fun _double -> _double)))
(when log.fdlibm
(define-accelerator (acc-log real) real (lambda (x) (log x)))
(define-accelerator-impl acc-log log.fdlibm (binary64) binary64 log.fdlibm))
(when log1p.fdlibm
(define-accelerator-impl log1p log1p.fdlibm (binary64) binary64 log1p.fdlibm))
(when log1pmd.fdlibm
(define-accelerator (log1pmd real) real (lambda (x) (- (log1p x) (log1p (neg x)))))
(define-accelerator-impl log1pmd log1pmd.fdlibm (binary64) binary64 log1pmd.fdlibm))
(module+ main
(writeln (log.fdlibm 1.1))
(writeln (log1p.fdlibm 0.1))
(writeln (log1pmd.fdlibm 0.1)))
;; Notice
;; To install (from within the package directory):
;; $ raco pkg install
;; To install (once uploaded to pkgs.racket-lang.org):
;; $ raco pkg install <<name>>
;; To uninstall:
;; $ raco pkg remove <<name>>
;; To view documentation:
;; $ raco docs <<name>>
;;
;; For your convenience, we have included LICENSE-MIT and LICENSE-APACHE files.
;; If you would prefer to use a different license, replace those files with the
;; desired license.
;;
;; Some users like to add a `private/` directory, place auxiliary files there,
;; and require them in `main.rkt`.
;;
;; See the current version of the racket style guide here:
;; http://docs.racket-lang.org/style/index.html