BLAS and LAPACK are:
-
linear algebra packages
-
de-facto standards
-
non-parallel
-
originally written in Fortran
-
also have C interfaces available
It might be a good idea to understand how to interface Fortran with C before the C interfaces.
Many implementations have been made, so they may be considered interfaces derived from an initial implementation nowadays.
BLAS contains low level functions such as:
- vector norm
- vector sum
- vector scalar multiplication
- vector matrix multiplication
- matrix matrix multiplication
LAPACK uses BLAS
LAPACK contains higher level functions such as:
- solving linear systems
- least squares
- eigenvalue/eigenvector calculations
It now includes an official C interface called LAPACKE, which other implementations also implement.
http://www.netlib.org/scalapack/
Continuation of LAPACK.
Considers parallelism distributed across machines.
http://math-atlas.sourceforge.net/
Automatically tuned BLAS LAPACK. Not sure what this means, but sounds good!
Implements full BLAS, but only part of LAPACK.
Has C interface.
https://github.com/xianyi/OpenBLAS
https://en.wikipedia.org/wiki/PBLAS
Created and used by ScaLAPACK.
Intel's closed source implementation.
The BLAS project provides cblas.h
, which contains a C interface for BLAS (TODO but also an implementation?)
Via atlas:
sudo aptitude install libatlas-dev
gcc -lcblas
Via LAPACKE (libblas-dev
already contains cblas.h
):
sudo aptitude install liblapacke-dev
gcc -lblas
1: array array. ex: array sum. 2: matrix array. ex: solve linear system. 3: matrix matrix. ex: multiply two matrices.
http://www.netlib.org/lapack/lug/node24.html
The functions are named according to the pattern:
XYYZZZ
Where:
-
X
: data type:- S: single precision (C float)
- D: double precision
- C: complex
- Z: double complex
-
YY
: known type the type of input matrices:GE
: generalTR
: triangular
The more restrict the matrix type, the more efficient algorithms can be.
-
ZZ
: computation to be done:SV
: SolVe linear systemMM
: Matrix MultiplyLS
: Least Squares (overdetermined system)
-
function signatures: in source code olny http://www.netlib.org/lapack/double/
-
naming convention http://www.cs.rochester.edu/~bh/cs400/using_lapack.html
-
user's guide. algorithm info http://www.netlib.org/lapack/lug/
-
http://www.tat.physik.uni-tuebingen.de/~kley/lehre/ftn77/tutorial/blas.html
http://stackoverflow.com/questions/26875415/difference-between-lapacke-and-lapack