Home

Awesome

Lisp Linear Algebra — a linear algebra library for Common Lisp

Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.

This library is unsupported by me. A fork is maintained at https://github.com/Lisp-Stat/lla.

About

LLA is a high-level Common Lisp library built on on BLAS and LAPACK, but providing a much more abstract interface with the purpose of freeing the user from low-level concerns and reducing the number of bugs in numerical code.

Documentation is mostly in docstrings at the moment, but I plan to write a decent tutorial at some point. In the meantime, please look at the unit tests.

Objectives

Configuration

Certain features of LLA can be configured before loading using the plist *lla-configuration* in the CL-USER package (for example, on SBCL you would do it in your ~/.sbclrc). The following properties are supported:

Libraries

Dependencies and configuration

LLA needs BLAS and LAPACK shared libraries to work. When it comes to loading libraries, LLA tries to pick a sensible default for each platform, but in case it fails, you need to tell LLA where the libraries are before loading.

You can do this by putting something like this in your startup script (eg ~/.sbclrc, the symbol needs to be in the package cl-user):

(defvar *lla-configuration*
  '(:libraries ("/usr/lib/atlas-base/atlas/libblas.so.3gf"
                "/usr/lib/atlas-base/libatlas.so.3gf")))

Debian

On Debian-based distributions, it is very likely that LLA will work out of the box if you just install ATLAS, eg

apt-get install libatlas3gf-base

However, you may want to build a version optimized for your architecture.

Building ATLAS on Debian

Prepare the build (as root):

apt-get build-dep atlas
apt-get install fakeroot devscripts
cpufreq-set -g performance -c 0   # do this for all CPUs

Then as a regular user,

apt-get source atlas
cd atlas-[fill in your version here]/
fakeroot debian/rules custom

Then install the .deb files that were created.

Selecting the right linear algebra library

update-alternatives --config libblas.so.3
update-alternatives --config liblapack.so.3

Intel MKL on Linux

In /etc/ld.so.conf.d/, create a file that contains the paths, eg

/opt/intel/mkl/lib/intel64
/opt/intel/composerxe/lib/intel64

Then the configuration

(defvar *lla-configuration*
  '("libgomp.so.1" "libiomp5.so" "libmkl_rt" "libpthread.so.0" "libpthread"))

should work.

Acknowledgements

LLA was inspired by packages written by AJ Rossini, Rif, Mark Hoemmen and others. I have borrowed code (whenever allowed by their licenses) and ideas freely from all of them.

Gábor Melis made substantial contributions to the library, especially the low-level pinning interface and the destructive BLAS routines.

Suggested editor settings for code contributions

No line breaks in (doc)strings, otherwise try to keep it within 80 columns. Remove trailing whitespace. 'modern' coding style. Suggested Emacs snippet:

(set-fill-column 9999)
(font-lock-add-keywords nil
                        '(("\\<\\(FIXME\\|TODO\\|QUESTION\\|NOTE\\)"
                        1 font-lock-warning-face t)))
(setq show-trailing-whitespace t)
(add-hook 'write-file-hooks
          '(lambda()
             (save-excursion
               (delete-trailing-whitespace))
             nil))
(visual-line-mode 1)
(setq slime-net-coding-system 'utf-8-unix)
(setq lisp-lambda-list-keyword-parameter-alignment t)
(setq lisp-lambda-list-keyword-alignment t)
(setq common-lisp-style-default 'modern)

Things to do (roughly in order of priority)