Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 1e49d64401b0e263d6f9d989280d96aff02f064d @tpapp committed Jul 24, 2011
Showing with 1,299 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +14 −0 Makefile
  3. +19 −0 README.org
  4. +10 −0 cl-rmath.asd
  5. +29 −0 cl-rmath.i
  6. +1,224 −0 cl-rmath.lisp
@@ -0,0 +1,3 @@
+*.fasl
+*~
+*.html
@@ -0,0 +1,14 @@
+# Running this Makefile is only necessary when Rmath.h changes.
+
+RMATH_DIRECTORY=/usr/include/
+LISP_FILENAME=cl-rmath.lisp
+
+all: $(LISP_FILENAME)
+
+$(LISP_FILENAME): cl-rmath.i $(RMATH_DIRECTORY)/Rmath.h
+ swig2.0 -cffi -I$(RMATH_DIRECTORY) $<
+
+.PHONY: clean
+
+clean:
+ rm $(LISP_FILENAME)
@@ -0,0 +1,19 @@
+#+TITLE: A simple wrapper for libRmath
+
+This is a simple, autogenerated foreign interface for the standalone [[http://www.r-project.org][R]] API
+[[
+http://cran.r-project.org/doc/manuals/R-exts.html#The-R-API][libRmath]]. There has been no effort to provide a high-level interface for the original library, instead, this library is meant to serve as a building block for such an interface.
+
+The =libRmath= shared library has to be installed for this library to work. For example, on Debian/Ubuntu/..., you just need to
+#+BEGIN_EXAMPLE
+apt-get install r-mathlib
+#+END_EXAMPLE
+as root.
+
+The function names are preserved as they are. Packages should not use the =cl-rmath= package, but refer to symbols using the =cl-rmath= or =rmath= package qualifiers (in fact, =fround= is in both =cl= and =cl-rmath=, so useing the package would require shadowing).
+
+Functions using random number generators are not expected to work out of the box.
+
+It is only necessary to run =make= when =Rmath.h= changes.
+
+Bugs and issues should be reported using the Github issue tracker.
@@ -0,0 +1,10 @@
+;;;; cl-rmath.asd
+
+(asdf:defsystem #:cl-rmath
+ :description "A Common Lisp wrapper for the Rmath library."
+ :version "0.0.1"
+ :author "Tamas K. Papp"
+ :license "Boost Software License - Version 1.0"
+ :serial t
+ :depends-on (#:cffi)
+ :components ((:file "cl-rmath")))
@@ -0,0 +1,29 @@
+%module "cl-rmath"
+
+/* Everything ends up in a single file, since the package definition
+ does not contain the export list and reloading the library would
+ give errors otherwise because of symbols exported previously. */
+
+%insert("lisphead") %{
+(defpackage #:cl-rmath
+ (:use #:cl)
+ (:nicknames #:rmath)
+ (:shadow #:fround))
+
+(in-package :cl-rmath)
+
+(cffi:define-foreign-library librmath
+ (:unix "libRmath.so")
+ (t (:default "libRmath")))
+
+(cffi:use-foreign-library librmath)
+
+%}
+
+/* R_VERSION_STRING is ignored because SBCL's defconstant doesn't like
+ the redefinition of string constants. */
+
+%feature("export");
+%ignore R_VERSION_STRING;
+#define MATHLIB_STANDALONE
+%include "Rmath.h";
Oops, something went wrong.

0 comments on commit 1e49d64

Please sign in to comment.