| 1 |
#| |
| 2 |
Build and load this module with (compile-file "ecl.lsp" :load t) |
| 3 |
|# |
| 4 |
;; |
| 5 |
;; With this other statement, we import the C function sin(), which |
| 6 |
;; operates on IEEE doubles. Notice that we include the C header to |
| 7 |
;; get the full declaration. |
| 8 |
;; |
| 9 |
(defun c-sin (x) |
| 10 |
(ffi:clines "#include <math.h>") |
| 11 |
(ffi:c-inline (x) (:double) :double "sin(#0)" :one-liner t)) |
| 12 |
;; |
| 13 |
;; We now use this function and compare with the lisp version. |
| 14 |
;; |
| 15 |
(format t "~%Lisp sin:~t~d~%C sin:~t~d~%Difference:~t~d" |
| 16 |
(sin 1.0d0) (c-sin 1.0d0) (- (sin 1.0d0) (c-sin 1.0d0))) |