Math::BLAS - basic linear algebra subroutines
use Math::BLAS;
The following notation is used in this document.
The problem size is specified by the integral numbers m and n. For vector operations, argument n is the number of vector elements. For matrix operations, m is the number of matrix rows and n is the number of matrix columns. For square matrix operations, n is the number of matrix rows and matrix columns.
Size arguments which are not integral numbers are truncated to the next integral number using Perl's built-in procedure int
.
A scalar operand is a Perl scalar value. Scalar operands are specified as properties with appropriate default values.
A vector operand x is specified by three arguments. Required argument x is a Perl array reference. The corresponding array index property x_ind specifies the Perl array index of the first vector element. The default value for the array index property is zero. Vectors are permitted to have spacing between elements. This spacing is specified by the Perl array index increment property x_incr. The default value for the array index increment property is one.
A matrix operand A is specified by three arguments. Required argument a is a Perl array reference. The corresponding array index property a_ind specifies the Perl array index of the first matrix element. The default value for the array index property is zero. Matrices are permitted to have more rows and/or columns than specified by the problem size. The actual number of columns is specified by the Perl array index increment property a_incr. The default value for the array index increment property is derived from the problem size.
blas_dot
(n, x, y, ...)Dot product.
The dot
function adds the scaled dot product of two vectors x and y into a scaled scalar r.
The scale factor for the dot product. Default value is one.
The scale factor for the scalar operand. Default value is zero.
The scalar operand. Value is either a scalar value or an array reference. Default value is zero.
The Perl array index of the array element for the array r. This property is only evaluated if r is an array reference. Default value is zero.
Arguments x and y are only evaluated if alpha is not equal to zero and if n is greater than zero. Argument r is only evaluated if beta is not equal to zero.
Return value is the result of the form. If n is less than zero, the function returns immediately with a return value of undef
.
blas_norm
(n, x, ...)Vector norms.
r ← ∑ |x|
r² ← ∑ x²
r ← max |x|
The norm
function computes either the one-norm, two-norm (that is Euclidean norm), or infinity-norm of a vector x.
The type of vector norm. Value is either BLAS_ONE_NORM
, BLAS_TWO_NORM
(or BLAS_FROBENIUS_NORM
), or BLAS_INF_NORM
. Default is to compute the one-norm.
Argument x is only evaluated if n is greater than zero.
Return value is the vector norm. If n is less than or equal to zero, the function returns immediately with a return value of zero.
blas_sum
(n, x, ...)Sum of vector elements.
The sum
function computes the sum of the elements of a vector x.
Argument x is only evaluated if n is greater than zero.
Return value is the result of the form. If n is less than or equal to zero, the function returns immediately with a return value of zero.
blas_min_val
(n, x, ...)blas_amin_val
(n, x, ...)blas_max_val
(n, x, ...)blas_amax_val
(n, x, ...)Minimum/maximum value and location.
k, r ← min x
k, r ← min |x|
k, r ← max x
k, r ← max |x|
The min_val
function finds the smallest element of a vector. The amin_val
function finds the smallest element of a vector with respect to the absolute value. The max_val
function finds the largest element of a vector. The amax_val
function finds the largest element of a vector with respect to the absolute value.
Argument x is only evaluated if n is greater than zero.
Return value is a list with two elements. First element is the index offset of the vector element. Second element is the value of the corresponding vector element. If argument n is less than or equal to zero, the function returns immediately with an index offset of undef
and an element value of zero.
If you are only interested in one of the return values, either assign the unwanted return value to undef
or directly subscribe the returned list. Say, for example
(undef, $val) = blas_min_val ($n, $x);
or
$val = (blas_min_val ($n, $x))[1];
blas_sumsq
(n, x, ...)Sum of squares.
The sumsq
function computes the scaled sum of squares s and the scale factor t.
Arguments x, sumsq, and scale are only evaluated if n is greater than zero.
Return value is a list with two elements. First element is the scaled sum of squares. Second element is the scale factor. If n is less than or equal to zero, the function returns immediately with the unchanged values of sumsq and scale.
blas_rscale
(n, x, ...)Reciprocal scale.
The rscale
function divides the elements of the vector x by the real scalar α. The scalar α is expected to be non-zero.
The reciprocal scale factor for the vector operand. Default value is one.
Argument x is only evaluated if alpha is not equal to one.
The procedure returns immediately if n is less than or equal to zero.
blas_axpby
(n, x, y, ...)Scaled vector accumulation.
The axpby
function adds the scaled vector x into the scaled vector y.
Argument x is only evaluated if alpha is not equal to zero.
The procedure returns immediately if n is less than or equal to zero.
blas_waxpby
(n, x, y, w, ...)Scaled vector addition.
The waxpby
function adds two scaled vectors x and y and stores the result in the vector w.
Argument x is only evaluated if alpha is not equal to zero. Argument y is only evaluated if beta is not equal to zero.
The procedure returns immediately if n is less than or equal to zero.
blas_copy
(n, x, y, ...)Copy vector elements.
The copy
function assigns the elements of the vector x to the elements of the vector y.
The procedure returns immediately if n is less than or equal to zero.
blas_swap
(n, x, y, ...)Interchange vector elements.
The swap
function interchanges the elements of the vector x with the elements of the vector y.
The procedure returns immediately if n is less than or equal to zero.
blas_gemv
(m, n, a, x, y, ...)General matrix/vector multiplication.
The gemv
function multiplies the matrix A with the vector x and adds the scaled product into the scaled vector y. If op(A) = A, A is a (m, n) matrix. If op(A) = A', A is a (n, m) matrix. Operand x is a vector with n elements and y is a vector with m elements.
The procedure returns immediately if m or n is less than or equal to zero.
blas_gemm
(m, n, k, a, b, c, ...)General matrix/matrix multiplication.
The gemm
function multiplies the matrix A with the matrix B and adds the scaled product into the scaled (m, n) matrix C. If op(A) = A, A is a (m, k) matrix. If op(A) = A', A is a (k, m) matrix. If op(B) = B, B is a (k, n) matrix. If op(B) = B', B is a (n, k) matrix.
The transpose flag for the matrix A. Value is either BLAS_NO_TRANS
or BLAS_TRANS
. Default is to not transpose the matrix A.
The transpose flag for the matrix B. Value is either BLAS_NO_TRANS
or BLAS_TRANS
. Default is to not transpose the matrix B.
The scale factor for the matrix/matrix product. Default value is one.
The scale factor for the result matrix. Default value is zero.
The procedure returns immediately if m or n is less than or equal to zero.
Math::BLAS::Enum, Math::BLAS::Legacy
http://www.netlib.org/blas/blast-forum/
Ralph Schleicher <rs@ralph-schleicher.de>