5.17 BLAS Library - naver/lispe GitHub Wiki

This library encapsulates instructions from the BLAS library (Basic Linear Algebra Subprogram)

(deflib blas_asum(x (incx 1)) "Computes the sum of absolute values of elements in vector x 
with stride incx" ) 

(deflib blas_axpy(x y (incx 1) (incy 1)) "Performs y <- alpha*x + y, where x, 
y are vectors with stride incx and incy respectively, and alpha is a scalar" ) 


(deflib blas_dot(x y (incx 1) (incy 1)) "Computes the dot product of vectors x and 
y with strides incx and incy respectively" ) 

(deflib blas_dotu(x y (incx 1) (incy 1)) "Computes the dot product of complex vectors x 
and y with strides incx and incy respectively" ) 

(deflib blas_iamax(x (incx 1)) "Returns the index of the first element with maximum absolute value 
in vector x with stride incx" ) 

(deflib blas_nrm2(x (incx 1)) "Computes the 2-norm (Euclidean length) of vector x with stride incx" 
) 

(deflib blas_scal(x scale (incx 1)) "Performs x <- scale*x, where x is a vector with 
stride incx, and scale is a scalar" ) 

(deflib blas_gemv(A m n lda x incx y incy (alpha 1) (beta 1) (layout true) 
(trans 0)) "Performs y <- alpha*A*x + beta*y, where A is a matrix with leading 
dimension lda, x and y are vectors with strides incx and incy respectively, and alpha 
and beta are scalars. The operation on A is transposed if trans is non-zero." ) 


(deflib blas_ger(A m n lda x incx y incy (alpha 1) (layout true)) "Performs A 
<- alpha*x*y^T + A, where A is a matrix with leading dimension lda, x and 
y are vectors with strides incx and incy respectively, and alpha is a scalar. The 
operation on x and y is not transposed." ) 

(deflib blas_geru(A m n lda x incx y incy (alpha 1) (layout true)) "Performs A 
<- alpha*x*y^T + A, where A is a matrix with leading dimension lda, x and 
y are vectors with strides incx and incy respectively, and alpha is a scalar. The 
operation on x is not transposed, but the operation on y is transposed." ) 

(deflib blas_hemv(A n lda x incx y incy (alpha 1) (beta 1) (layout true) (uplo 
true)) "Performs y <- alpha*A*x + beta*y, where A is a Hermitian matrix with leading 
dimension lda, x and y are vectors with strides incx and incy respectively, and alpha 
and beta are scalars. Only the upper or lower triangular part of A is accessed, 
as specified by uplo." ) 

(deflib blas_symv(A n lda x incx y incy (alpha 1) (beta 1) (layout true) (uplo 
true)) "Performs y <- alpha*A*x + beta*y, where A is a symmetric matrix with leading 
dimension lda, x and y are vectors with strides incx and incy respectively, and alpha 
and beta are scalars. Only the upper or lower triangular part of A is accessed, 
as specified by uplo." ) 

(deflib blas_her(A n lda x incx (alpha 1) (layout true) (uplo true)) "Performs A <- 
alpha*x*x^H + A, where A is a Hermitian matrix with leading dimension lda, x is 
a vector with stride incx, and alpha is a scalar. Only the upper or lower 
triangular part of A is accessed, as specified by uplo." ) 

(deflib blas_syr(A n lda x incx (alpha 1) (layout true) (uplo true)) "Performs A <- 
alpha*x*x^T + A, where A is a symmetric matrix with leading dimension lda, x is 
a vector with stride incx, and alpha is a scalar. Only the upper or lower 
triangular part of A is accessed, as specified by uplo." ) 

(deflib blas_her2(A n lda x incx y incy (alpha 1) (layout true) (uplo true)) "Performs 
A <- alpha*x*y^H + A, where A is a Hermitian matrix with leading dimension lda, 
x and y are vectors with strides incx and incy respectively, and alpha is a 
scalar. Only the upper or lower triangular part of A is accessed, as specified by 
uplo." ) 

(deflib blas_syr2(A n lda x incx y incy (alpha 1) (layout true) (uplo true)) "Performs 
A <- alpha*x*y^T + A, where A is a symmetric matrix with leading dimension lda, 
x and y are vectors with strides incx and incy respectively, and alpha is a 
scalar. Only the upper or lower triangular part of A is accessed, as specified by 
uplo." ) 

(deflib blas_trmv(A n lda x incx (layout true) (uplo true) (trans 0) (diag true)) "Performs 
x <- A*x, where A is a triangular matrix with leading dimension lda, x is 
a vector with stride incx, and the operation on A is not transposed. If uplo 
is true, only the upper triangular part of A is accessed, otherwise only the lower 
triangular part is accessed. If diag is true, the diagonal elements of A are not 
overwritten, otherwise they are overwritten with 1." ) 

(deflib blas_trsv(A n lda x incx (layout true) (uplo true) (trans 0) (diag true)) "Performs 
x <- A\*x, where A is a triangular matrix with leading dimension lda, x is 
a vector with stride incx, and the operation on A is not transposed. If uplo 
is true, only the upper triangular part of A is accessed, otherwise only the lower 
triangular part is accessed. If diag is true, the diagonal elements of A are not 
overwritten, otherwise they are overwritten with 1." ) 

(deflib blas_gemm(A m n k lda B ldb C ldc (alpha 1) (beta 1) (layout 
true) (transA 0) (transB 0)) "Performs C <- alpha*A*B + beta*C, where A is a 
matrix with leading dimension lda, B is a matrix with leading dimension ldb, and C 
is a matrix with leading dimension ldc. The dimensions of A, B, and C are 
m x k, k x n, and m x n respectively. The operation on A 
and B is transposed if transA and transB are non-zero, respectively." ) 

(deflib blas_hemm(A m n lda B ldb C ldc (alpha 1) (beta 1) (layout true) 
(side true) (uplo true)) "Performs C <- alpha*A*B + beta*C, where A is a Hermitian 
matrix with leading dimension lda, B is a matrix with leading dimension ldb, and C 
is a matrix with leading dimension ldc. The dimensions of A, B, and C are 
m x m, m x n, and m x n respectively. The operation on A 
is transposed if side is true, and only the upper or lower triangular part of 
A is accessed, as specified by uplo." ) 

(deflib blas_symm(A m n lda B ldb C ldc (alpha 1) (beta 1) (layout true) 
(side true) (uplo true)) "Performs C <- alpha*A*B + beta*C, where A is a symmetric 
matrix with leading dimension lda, B is a matrix with leading dimension ldb, and C 
is a matrix with leading dimension ldc. The dimensions of A, B, and C are 
m x m, m x n, and m x n respectively. The operation on A 
is transposed if side is true, and only the upper or lower triangular part of 
A is accessed, as specified by uplo." ) 

(deflib blas_herk(A n k lda C ldc (alpha 1) (beta 1) (layout true) (uplo true) 
(trans 0) "Performs a rank k update of a Hermitian matrix.") 

(deflib blas_syrk(A n k lda C ldc (alpha 1) (beta 1) (layout true) (uplo true) 
(trans 0)) "Performs a rank k update of a symmetric matrix.") 

(deflib blas_her2k(A n k lda B ldb C ldc (alpha 1) (beta 1) (layout true) 
(uplo true) (trans 0)) "Performs a rank k update of a Hermitian matrix with another 
Hermitian matrix") 

(deflib blas_syr2k(A n k lda B ldb C ldc (alpha 1) (beta 1) (layout true) 
(uplo true) (trans 0)) "Performs a rank k update of a symmetric matrix with another 
symmetric matrix.") 

(deflib blas_trmm(A m n lda B ldb (alpha 1) (layout true) (side true) (uplo true) 
(trans 0) (diag true)) "Performs a triangular matrix-matrix multiplication.") 

(deflib blas_trsm(A m n lda B ldb (alpha 1) (layout true) (side true) (uplo true) 
(trans 0) (diag true)) "Solves a triangular system of equations with a matrix on the 
right-hand side.") 


Examples:

(use "lispe_blas")
(setq v1 (iota 100))
(println (blas_asum v1))

(setq v2 (iota 100))
(println (blas_axpy v1 v2))

(setq d1 (range 1 100 1.0))
(setq d2 (range 2 200 2.0))
(println (blas_dot d1 d2 1 1))
(println (blas_dotu d1 d2 1 1))

(println (blas_iamax d1))
(println (blas_nrm2 d2))

(println (blas_scal d1 2.1))

(setq A (numbers 1 2 3 4 5 6))
(setq x (numbers 9 10 11)) 
(setq y (numbers 7 8))

(println (blas_gemv A 2 3 2 x 1 y 1))