Matrix Storage Schemes for BLAS
Routines
Matrix arguments of BLAS
and CBLAS
routines can use the following
storage schemes:
- Full storage: a matrixAis stored in a two-dimensional arraya, with the matrix elementstored in the array elementAij.for column-major layout anda[i+j*lda]for row-major layout, wherea[j+i*lda]ldais the leading dimension for the array
- Packed storagescheme allows you to store symmetric, Hermitian, or triangular matrices more compactly. For column-major layout, the upper or lower triangle of the matrix is packed by columns in a one dimensional array. For row-major layout, the upper or lower triangle of the matrix is packed by rows in a one dimensional array.
- Band storage: a band matrix is stored compactly in a two-dimensional array.For column-major layout, columns of the matrix are stored in the corresponding columns of the array, and diagonals of the matrix are stored in a specific row of the array. For row-major layout, rows of the matrix are stored in the corresponding rows of the array, and diagonals of the matrix are stored in a specific column of the array.
For more information on matrix storage schemes, see
Matrix Arguments in
the
Appendix “Routine and Function
Arguments”
.
Row-Major and Column-Major Layout
The BLAS routines follow the Fortran convention of storing
two-dimensional arrays using column-major layout. When calling BLAS routines
from C, remember that they require arrays to be in column-major format, not the
row-major format that is the convention for C.
Unless otherwise specified, the
psuedo-code examples for the BLAS routines illustrate matrices stored using
column-major layout.
The CBLAS interface allows you to
specify either column-major or row-major layout for BLAS Level 2 and Level 3
routines, by setting the
layout
parameter to
CblasColMajor
or
CblasRowMajor
.