Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp committed Jul 24, 2011
0 parents commit 1e49d64
Show file tree
Hide file tree
Showing 6 changed files with 1,299 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
*.fasl
*~
*.html
14 changes: 14 additions & 0 deletions Makefile
@@ -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)
19 changes: 19 additions & 0 deletions README.org
@@ -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.
10 changes: 10 additions & 0 deletions cl-rmath.asd
@@ -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")))
29 changes: 29 additions & 0 deletions cl-rmath.i
@@ -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";

0 comments on commit 1e49d64

Please sign in to comment.