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.1
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,
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,
The types of matrices are,
Each operation is defined for four precisions,
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).
[1] 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.