Every routine in the BLAS library comes in four flavors, each prefixed by the letters S, D, C, and Z, respectively. Each letter indicates the format of input data:
In addition, each BLAS routine in this egg comes in three flavors:
Safe routines check the sizes of their input arguments. For example, if a routine is supplied arguments that indicate that an input matrix is of dimensions M-by-N, then the argument corresponding to that matrix is checked that it is of size M * N.
Pure routines do not alter their arguments in any way. A new matrix or vector is allocated for the return value of the routine.
Safe routines check the sizes of their input arguments. For example, if a routine is supplied arguments that indicate that an input matrix is of dimensions M-by-N, then the argument corresponding to that matrix is checked that it is of size M * N.
Destructive routines can modify some or all of their arguments. They are given names ending in exclamation mark. Please consult the BLAS documentation to determine which functions modify their input arguments.
Unsafe routines do not check the sizes of their input arguments. They invoke the corresponding BLAS routines directly. Unsafe routines do not have pure variants.
For example, function xGEMM (matrix-matrix multiplication) comes in the following variants:
BLAS name | Safe, pure | Safe, destructive | Unsafe, destructive |
---|---|---|---|
SGEMM | blas:sgemm | blas:sgemm! | unsafe-blas:sgemm! |
DGEMM | blas:dgemm | blas:dgemm! | unsafe-blas:dgemm! |
CGEMM | blas:cgemm | blas:cgemm! | unsafe-blas:cgemm! |
ZGEMM | blas:zgemm | blas:zgemm! | unsafe-blas:zgemm! |
These procedures return a copy of given input SRFI-4 vector. The returned vector is allocated with the corresponding SRFI-4 constructor, and the input vector is copied to it by the corresponding BLAS copy procedure.
The BLAS level 1 procedures in this egg differ from the actual routines they invoke by the position of the vector increment arguments (INCX and INCY). In this egg, these arguments are optional; the default value of INCX and INCY is 1.
In the procedure signatures below, these optional arguments are indicated by [ and ] (square brackets).
xROT applies a plane rotation matrix to a sequence of ordered pairs: (x_i , y_i), for i = 1, 2, ..., n.
X and Y are vector of dimensions (N-1) * abs(incx) + 1 and (N-1) * abs(incy) + 1, respectively.
C and S are respectively the cosine and sine of the plane of rotation.
xSCAL scales a vector with a scalar: x := alpha * x.
xSWAP interchanges the elements of two vectors: x <-> y.
xDOT computes the dot product of two vectors of real values: dot := x'*y = \Sum_{i=1}^{n} (x_i * y_i).
xDOTU computes the dot product of two vectors of complex values: dotu := x'*y = \Sum_{i=1}^{n} (x_i * y_i).
xDOTC computes the dot product of the conjugates of two complex vectors: dotu := conjg(x')*y = \Sum_{i=1}^{n} (conjg(x_i) * y_i), for i = 1, 2, ..., n.
xAXPY adds a scalar multiple of a vector to another vector: y := alpha * x + y.
xIAXPY adds a scalar multiple of a vector to another vector, where the beginning of each vector argument can be offset: y[yofs:n] := alpha * x[xofs:n] + y[yofs:n].
xNRM2 computes the Euclidean (L2) norm of a vector.
xASUM sums the absolute values of the elements in a vector.
xAMAX searches a vector for the first occurrence of its maximum absolute value, and returns the index of that element.
The BLAS level 2 procedures in this egg differ from the actual routines they invoke by the position of the leading dimension argument (LDA) and the vector increment arguments (INCX and INCY). In this egg, these arguments are optional; the default value of LDAis the largest matrix dimension, depending on the semantics of the respective operation, and the default value of INCX and INCY is 1.
In the procedure signatures below, these optional arguments are indicated by [ and ] (square brackets).
Argument ORDER is one of blas:RowMajor or blas:ColMajor to indicate that the input and output matrices are in row-major or column-major form, respectively.
Where present, argument TRANS can be one of blas:NoTrans or blas:Trans to indicate whether the input matrix is to be transposed or not.
Where present, argument UPLO can be one of blas:Upper or blas:Lower to indicate whether the upper or lower triangular part of an input symmetric matrix is to referenced,or to specify the type of an input triangular matrix.
Where present, argument DIAG can be one of blas:NonUnit or blas:Unit to indicate whether an input triangular matrix is unit triangular or not.
xGEMV performs the matrix-vector multiply-add operation of the form y := alpha*op( A )*x + beta*y, where op( X ) is one of op( A ) = A or op( A ) = A'.
ALPHA and BETA are scalars, and A is an M x N matrix.
X is a vector of size (1 + ( N - 1 ) * abs(INCX)) when argument TRANS is blas:NoTrans, and (1 + ( M - 1 ) * abs(INCX)) otherwise. Y is a vector of size (1 + ( M - 1 ) * abs(INCY)) when argument TRANS is blas:NoTrans, and (1 + ( N - 1 ) * abs(INCY)) otherwise.
xGBMV performs the matrix-vector multiply-add operation of the form y := alpha*op( A )*x + beta*y, where op( X ) is one of op( A ) = A or op( A ) = A'.
ALPHA and BETA are scalars, and A is an M x N banded matrix, with KL sub-diagonals and KU super-diagonals.
X is a vector of size (1 + ( N - 1 ) * abs(INCX)) when argument TRANS is blas:NoTrans, and (1 + ( M - 1 ) * abs(INCX)) otherwise. Y is a vector of size (1 + ( M - 1 ) * abs(INCY)) when argument TRANS is blas:NoTrans, and (1 + ( N - 1 ) * abs(INCY)) otherwise.
xHEMV performs the matrix-vector multiply-add operation of the form y := alpha*op( A )*x + beta*y, where op( X ) is one of op( A ) = A or op( A ) = A'.
ALPHA and BETA are scalars, and A is an N x N Hermitian matrix.
X and Y are N element vectors.
xHBMV performs the matrix-vector multiply-add operation of the form y := alpha*op( A )*x + beta*y, where op( X ) is one of op( A ) = A or op( A ) = A'.
ALPHA and BETA are scalars, and A is an N x N Hermitian banded matrix, with K super-diagonals.
X and Y are N element vectors.
xSYMV performs matrix-vector multiply-add operation of the form y := alpha*A*x + beta*y.
ALPHA and BETA are scalars, and A is an N x N symmetric matrix.
X and Y are N element vectors.
xSBMV performs matrix-vector multiply-add operation of the form y := alpha*A*B + beta*y.
ALPHA and BETA are scalars, and A is an N x N symmetric banded matrix, with K super-diagonals.
X and Y are N element vectors.
xTRMV performs matrix-vector multiply-add operation of the form y := alpha*op( A )*x, where op ( A ) = A or op ( A ) = A'
ALPHA and BETA are scalars, and A is an N x N upper or lower triangular matrix.
X is a vector of length (1 + (n - 1) * abs(INCX)).
xTBMV performs matrix-vector multiply-add operation of the form y := alpha*A*B + beta*y, where op ( A ) = A or op ( A ) = A'
ALPHA and BETA are scalars, and A is an N x N upper or lower triangular banded matrix, with K+1 diagonals.
X is a vector of length (1 + (n - 1) * abs(INCX)).
xTRSV solves one of the systems of equations A*x = b or A'*x = b.
ALPHA and BETA are scalars, A is a upper or lower triangular matrix, and B is a N element vector.
xTBSV solves one of the systems of equations A*x = b or A'*x = b.
ALPHA and BETA are scalars, A is a upper or lower banded triangular matrix with K+1 diagonals, and B is a N element vector.
xGER performs the rank 1 operation A := alpha*x*y' + A.
ALPHA is a scalar, X is an M element vector, Y is an N element vector, and A is an M x N matrix.
xIGER performs the rank 1 operation A := alpha*x[xofs:M]*y'[yofs:N] + A.
ALPHA is a scalar, X is an M element vector, Y is an N element vector, and A is an M x N matrix.
xGERU performs the rank 1 operation A := alpha*x*y' + A.
ALPHA is a scalar, X is an M element vector, Y is an N element vector, and A is an M x N matrix.
xGERC performs the rank 1 operation A := alpha*x*conjg(y') + A.
ALPHA is a scalar, X is an M element vector, Y is an N element vector, and A is an M x N matrix.
xHER performs the Hermitian rank 1 operation A := alpha*x*conjg(x') + A.
ALPHA is a scalar, X is an N element vector, and A is an N x N Hermitian matrix.
xHER2 performs the Hermitian rank 2 operation A := alpha*x*conjg(y') + conjg(alpha)*y*conjg(x') + A.
ALPHA is a scalar, X and Y are N element vectors, and A is an N x N Hermitian matrix.
xSYR performs the symmetric rank 1 operation A := alpha*x*x' + A.
ALPHA is a scalar, X is an N element vector, and A is an N x N symmetric matrix.
xSYR2 performs the symmetric rank 2 operation A := alpha*x*y' + alpha*y*x' + A.
ALPHA is a scalar, X and Y are N element vectors, and A is an N x N symmetric matrix.
The BLAS level 3 procedures in this egg differ from the actual routines they invoke by the position of the leading dimension arguments (LDA, LDB, and LDC). In this egg, these arguments are optional, and their default values are set to the largest matrix dimension, depending on the semantics of the respective operation.
In the procedure signatures below, these optional arguments are indicated by [ and ] (square brackets).
Argument ORDER is one of blas:RowMajor or blas:ColMajor to indicate that the input and output matrices are in row-major or column-major form, respectively.
Where present, arguments TRANS, TRANSA, TRANSB can be one of blas:NoTrans or blas:Trans to indicate whether the respective input matrices are to be transposed or not.
Where present, argument SIDE can be one of blas:Left or blas:Right to indicate whether an input symmetric matrix appears on the left or right in the respective operation.
Where present, argument UPLO can be one of blas:Upper or blas:Lower to indicate whether the upper or lower triangular part of an input symmetric matrix is to referenced,or to specify the type of an input triangular matrix.
Where present, argument DIAG can be one of blas:NonUnit or blas:Unit to indicate whether an input triangular matrix is unit triangular or not.
xGEMM performs matrix-matrix multiply-add operation of the form C := alpha*op( A )*op( B ) + beta*C, where op( X ) is one of op( X ) = X or op( X ) = X'.
ALPHA and BETA are scalars, and A, B and C are matrices, with op( A ) an M x K matrix, op( B ) a K x N matrix and C an M x N matrix.
xSYMM performs matrix-matrix multiply-add operation of the form C := alpha*A*B + beta*C or C := alpha*B*A + beta*C.
ALPHA and BETA are scalars, A is a symmetric matrix, and B and C are M x N matrices.
xSYRK performs one of the symmetric rank k operations C := alpha*A*A' + beta*C or C := alpha*A'*A + beta*C.
ALPHA and BETA are scalars, A is an N x K or K x N matrix, and C is an N x N symmetric matrix.
xHERK performs one of the hermitian rank k operations C := alpha*A*conjg(A') + beta*C or C := alpha*conjg(A')*A + beta*C.
ALPHA and BETA are scalars, A is an N x K or K x N matrix, and C is an N x N hermitian matrix.
xSYR2K performs one of the symmetric rank 2k operations C := alpha*A*B' + beta*C or C := alpha*B'*A + beta*C.
ALPHA and BETA are scalars, A and B are N x K or K x N matrices, and C is an N x N symmetric matrix.
xHER2K performs one of the hermitian rank 2k operations C := alpha*A*conjg(B') + beta*C or C := alpha*conjg(B')*A + beta*C.
ALPHA and BETA are scalars, A and B are N x K or K x N matrices, and C is an N x N hermitian matrix.
xTRMM performs matrix-matrix multiply operation of the form B := alpha*op( A )*B or B := alpha*B*op( A ).
ALPHA is a scalar, A is an upper or lower triangular matrix, and B is an M x N matrix.
xTRSM solves one of the matrix equations op( A )*X = alpha*B or X*op( A ) = alpha*B.
op( A ) is one of op( A ) = A or op( A ) = A'.
ALPHA and BETA are scalars, A is a upper or lower triangular matrix, and B is a M x N matrix.
(require-extension srfi-4) (require-extension blas) (define order blas:ColMajor) (define transa blas:NoTrans) (define m 4) (define n 4) (define alpha 1) (define beta 0) (define a ; column-major order! (f64vector 1 2 3 4 1 1 1 1 3 4 5 6 5 6 7 8) ) (define x (f64vector 1 2 1 1)) (define y (f64vector 0 0 0 0)) (blas:dgemv! order transa m n alpha a x beta y) (print y)
Copyright (c) 2003-2006, Felix L. Winkelmann Copyright (c) 2007, Ivan Raikov All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.