Next: , Previous: Sorting, Up: Top


12 BLAS Support

The Basic Linear Algebra Subprograms (blas) define a set of fundamental operations on vectors and matrices which can be used to create optimized higher-level linear algebra functionality.

The library provides a low-level layer which corresponds directly to the C-language blas standard, referred to here as “cblas”, and a higher-level interface for operations on GSL vectors and matrices. Users who are interested in simple operations on GSL vector and matrix objects should use the high-level layer, which is declared in the file gsl_blas.h. This should satisfy the needs of most users. Note that GSL matrices are implemented using dense-storage so the interface only includes the corresponding dense-storage blas functions. The full blas functionality for band-format and packed-format matrices is available through the low-level cblas interface.

The interface for the gsl_cblas layer is specified in the file gsl_cblas.h. This interface corresponds to the blas Technical Forum's draft standard for the C interface to legacy blas implementations. Users who have access to other conforming cblas implementations can use these in place of the version provided by the library. Note that users who have only a Fortran blas library can use a cblas conformant wrapper to convert it into a cblas library. A reference cblas wrapper for legacy Fortran implementations exists as part of the draft cblas standard and can be obtained from Netlib. The complete set of cblas functions is listed in an appendix (see GSL CBLAS Library).

There are three levels of blas operations,

Level 1
Vector operations, e.g. y = \alpha x + y
Level 2
Matrix-vector operations, e.g. y = \alpha A x + \beta y
Level 3
Matrix-matrix operations, e.g. C = \alpha A B + C

Each routine has a name which specifies the operation, the type of matrices involved and their precisions. Some of the most common operations and their names are given below,

DOT
scalar product, x^T y
AXPY
vector sum, \alpha x + y
MV
matrix-vector product, A x
SV
matrix-vector solve, inv(A) x
MM
matrix-matrix product, A B
SM
matrix-matrix solve, inv(A) B

The types of matrices are,

GE
general
GB
general band
SY
symmetric
SB
symmetric band
SP
symmetric packed
HE
hermitian
HB
hermitian band
HP
hermitian packed
TR
triangular
TB
triangular band
TP
triangular packed

Each operation is defined for four precisions,

S
single real
D
double real
C
single complex
Z
double complex

Thus, for example, the name sgemm stands for “single-precision general matrix-matrix multiply” and zgemm stands for “double-precision complex matrix-matrix multiply”.