Next: , Previous: Sorting, Up: Top   [Index]


13 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 described in this chapter. The functions are declared in the file gsl_blas.h and 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. Similarly, GSL vectors are restricted to positive strides, whereas the low-level CBLAS interface supports negative strides as specified in the BLAS standard.12

The interface for the gsl_cblas layer is specified in the file gsl_cblas.h. This interface corresponds to the BLAS Technical Forum’s 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 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”.

Note that the vector and matrix arguments to BLAS functions must not be aliased, as the results are undefined when the underlying arrays overlap (see Aliasing of arrays).


Footnotes

(12)

In the low-level CBLAS interface, a negative stride accesses the vector elements in reverse order, i.e. the i-th element is given by (N-i)*|incx| for incx < 0.


Next: , Previous: Sorting, Up: Top   [Index]