Skip to content

thomashoullier/sbcl-lapack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SBCL BLAS/LAPACK bindings

This is a set of (very few) SBCL bindings for BLAS/LAPACK. I just add whatever I need manually. This should be mostly for tests, so as not to make libraries reliant on SBCL-specific code.

Functions

List

  • dgemm
  • dgesv

Description

dgemm a b &key transa transb alpha beta c => x

Perform dgemm, double-float matrix multiplication: $X = \alpha \cdot A.B + \beta \cdot C$.

  • a, b, c: Native 2D Common Lisp matrices of double-float elements. The rows and columns are multiplied as expected in matrix multiplication.
  • transa, transb: Case-insensitive. Can be "n" for no transposition to apply. "t" or "c" to apply a transposition.
  • alpha, beta: double-float scalars.
  • x: Result matrix.

dgesv a b => x

Perform dgesv. Solve the linear system of equations for x: $Ax = B$ using LU decomposition. x is the matrix of solution corresponding to the right-hand sides in B. An error is emitted if the operation was impossible: eg. when A is degenerate.

  • a, b: Native 2D matrices of double-float elements. a is necessarily square. b can have as many columns as right-hand sides.
  • x: The sets of solutions, in columns, same indices as right-hand sides in b.

dgetrf a => lu ipiv

Perform dgetrf. LUP decomposition of matrix A. Returns L and U stored in a single matrix lu with the unit elements of L omitted. ipiv is the row swap vector to apply in sequence to lu in order to find A. We retrieve A with A = P.L.U. Error whenever A is (exactly) singular.

  • a: Native 2D matrices of double-float elements. a is necessarily square and non-singular.
  • lu: L and U matrices stored as a single square matrix.
  • ipiv: Row permutations sequence.

Dependencies

LAPACK and BLAS should be installed on the system.

sbcl-lapack:

sbcl-lapack/test:

Run tests

(asdf:test-system "sbcl-lapack")

Choices

As far as possible, I try to:

  • Use functional calls.
  • Hide the return codes, turn them into errors and warnings.

Caveats

  • The results are put in matrices with copying. Performance could be marginally improved.
  • It is possible to make the system crash by providing wrong user inputs. I try to catch the most common mistakes though.

References

About

SBCL bindings for LAPACK/BLAS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published