Class SimpleBlas
java.lang.Object
org.jblas.SimpleBlas
This class provides a cleaner direct interface to the BLAS routines by extracting the parameters of the matrices from the matrices itself.
For example, you can just pass the vector and do not have to pass the length, corresponding DoubleBuffer, offset and step size explicitly.
Currently, all the general matrix routines are implemented.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublestatic floatstatic doubleasum(DoubleMatrix x) Compute || x ||_1 (1-norm, sum of absolute values)static floatasum(FloatMatrix x) Compute || x ||_1 (1-norm, sum of absolute values)static DoubleMatrixaxpy(double da, DoubleMatrix dx, DoubleMatrix dy) Compute y <- alpha * x + y (elementwise addition)static FloatMatrixaxpy(float da, FloatMatrix dx, FloatMatrix dy) Compute y <- alpha * x + y (elementwise addition)static ComplexDoubleMatrixaxpy(ComplexDouble da, ComplexDoubleMatrix dx, ComplexDoubleMatrix dy) static ComplexFloatMatrixaxpy(ComplexFloat da, ComplexFloatMatrix dx, ComplexFloatMatrix dy) static ComplexDoubleMatrixstatic ComplexFloatMatrixstatic DoubleMatrixcopy(DoubleMatrix x, DoubleMatrix y) Compute y <- x (copy a matrix)static FloatMatrixcopy(FloatMatrix x, FloatMatrix y) Compute y <- x (copy a matrix)static doubledot(DoubleMatrix x, DoubleMatrix y) Compute x^T * y (dot product)static floatdot(FloatMatrix x, FloatMatrix y) Compute x^T * y (dot product)static ComplexDoubleCompute x^T * y (dot product)static ComplexFloatCompute x^T * y (dot product)static ComplexDoubleCompute x^T * y (dot product)static ComplexFloatCompute x^T * y (dot product)static intgeev(char jobvl, char jobvr, DoubleMatrix A, DoubleMatrix WR, DoubleMatrix WI, DoubleMatrix VL, DoubleMatrix VR) static intgeev(char jobvl, char jobvr, FloatMatrix A, FloatMatrix WR, FloatMatrix WI, FloatMatrix VL, FloatMatrix VR) static voidgelsd(DoubleMatrix A, DoubleMatrix B) Generalized Least Squares via *GELSD.static voidgelsd(FloatMatrix A, FloatMatrix B) Generalized Least Squares via *GELSD.static DoubleMatrixgemm(double alpha, DoubleMatrix a, DoubleMatrix b, double beta, DoubleMatrix c) Compute c <- a*b + beta * c (general matrix matrix multiplication)static FloatMatrixgemm(float alpha, FloatMatrix a, FloatMatrix b, float beta, FloatMatrix c) Compute c <- a*b + beta * c (general matrix matrix multiplication)static ComplexDoubleMatrixgemm(ComplexDouble alpha, ComplexDoubleMatrix a, ComplexDoubleMatrix b, ComplexDouble beta, ComplexDoubleMatrix c) static ComplexFloatMatrixgemm(ComplexFloat alpha, ComplexFloatMatrix a, ComplexFloatMatrix b, ComplexFloat beta, ComplexFloatMatrix c) static DoubleMatrixgemv(double alpha, DoubleMatrix a, DoubleMatrix x, double beta, DoubleMatrix y) Compute y <- alpha*op(a)*x + beta * y (general matrix vector multiplication)static FloatMatrixgemv(float alpha, FloatMatrix a, FloatMatrix x, float beta, FloatMatrix y) Compute y <- alpha*op(a)*x + beta * y (general matrix vector multiplication)static voidgeqrf(DoubleMatrix A, DoubleMatrix tau) static voidgeqrf(FloatMatrix A, FloatMatrix tau) static DoubleMatrixger(double alpha, DoubleMatrix x, DoubleMatrix y, DoubleMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update)static FloatMatrixger(float alpha, FloatMatrix x, FloatMatrix y, FloatMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update)static ComplexDoubleMatrixgerc(ComplexDouble alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y, ComplexDoubleMatrix a) Compute A <- alpha * x * y^H + A (general rank-1 update)static ComplexFloatMatrixgerc(ComplexFloat alpha, ComplexFloatMatrix x, ComplexFloatMatrix y, ComplexFloatMatrix a) Compute A <- alpha * x * y^H + A (general rank-1 update)static ComplexDoubleMatrixgeru(ComplexDouble alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y, ComplexDoubleMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update)static ComplexFloatMatrixgeru(ComplexFloat alpha, ComplexFloatMatrix x, ComplexFloatMatrix y, ComplexFloatMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update)static DoubleMatrixgesv(DoubleMatrix a, int[] ipiv, DoubleMatrix b) LAPACKstatic FloatMatrixgesv(FloatMatrix a, int[] ipiv, FloatMatrix b) LAPACKstatic intCompute index of element with largest absolute value (complex version).static intCompute index of element with largest absolute value (complex version).static intCompute index of element with largest absolute value (index of absolute value maximum)static intiamax(FloatMatrix x) Compute index of element with largest absolute value (index of absolute value maximum)static doublestatic floatstatic doublenrm2(DoubleMatrix x) Compute || x ||_2 (2-norm)static floatnrm2(FloatMatrix x) Compute || x ||_2 (2-norm)static voidorgqr(int n, int k, DoubleMatrix A, DoubleMatrix tau) static voidorgqr(int n, int k, FloatMatrix A, FloatMatrix tau) static voidormqr(char side, char trans, DoubleMatrix A, DoubleMatrix tau, DoubleMatrix C) static voidormqr(char side, char trans, FloatMatrix A, FloatMatrix tau, FloatMatrix C) static voidposv(char uplo, DoubleMatrix A, DoubleMatrix B) static voidposv(char uplo, FloatMatrix A, FloatMatrix B) static DoubleMatrixscal(double alpha, DoubleMatrix x) Compute x <- alpha * x (scale a matrix)static FloatMatrixscal(float alpha, FloatMatrix x) Compute x <- alpha * x (scale a matrix)static ComplexDoubleMatrixscal(ComplexDouble alpha, ComplexDoubleMatrix x) static ComplexFloatMatrixscal(ComplexFloat alpha, ComplexFloatMatrix x) static DoubleMatrixswap(DoubleMatrix x, DoubleMatrix y) Compute x <-> y (swap two matrices)static FloatMatrixswap(FloatMatrix x, FloatMatrix y) Compute x <-> y (swap two matrices)static intsyev(char jobz, char uplo, DoubleMatrix a, DoubleMatrix w) static intsyev(char jobz, char uplo, FloatMatrix a, FloatMatrix w) static intsyevd(char jobz, char uplo, DoubleMatrix A, DoubleMatrix w) static intsyevd(char jobz, char uplo, FloatMatrix A, FloatMatrix w) static intsyevr(char jobz, char range, char uplo, DoubleMatrix a, double vl, double vu, int il, int iu, double abstol, DoubleMatrix w, DoubleMatrix z, int[] isuppz) static intsyevr(char jobz, char range, char uplo, FloatMatrix a, float vl, float vu, int il, int iu, float abstol, FloatMatrix w, FloatMatrix z, int[] isuppz) static intsyevx(char jobz, char range, char uplo, DoubleMatrix a, double vl, double vu, int il, int iu, double abstol, DoubleMatrix w, DoubleMatrix z) static intsyevx(char jobz, char range, char uplo, FloatMatrix a, float vl, float vu, int il, int iu, float abstol, FloatMatrix w, FloatMatrix z) static intsygvd(int itype, char jobz, char uplo, DoubleMatrix A, DoubleMatrix B, DoubleMatrix W) static intsygvd(int itype, char jobz, char uplo, FloatMatrix A, FloatMatrix B, FloatMatrix W) static intsygvx(int itype, char jobz, char range, char uplo, DoubleMatrix A, DoubleMatrix B, double vl, double vu, int il, int iu, double abstol, int[] m, DoubleMatrix W, DoubleMatrix Z) static intsygvx(int itype, char jobz, char range, char uplo, FloatMatrix A, FloatMatrix B, float vl, float vu, int il, int iu, float abstol, int[] m, FloatMatrix W, FloatMatrix Z) static DoubleMatrixsysv(char uplo, DoubleMatrix a, int[] ipiv, DoubleMatrix b) static FloatMatrixsysv(char uplo, FloatMatrix a, int[] ipiv, FloatMatrix b)
-
Constructor Details
-
SimpleBlas
public SimpleBlas()
-
-
Method Details
-
swap
Compute x <-> y (swap two matrices) -
scal
Compute x <- alpha * x (scale a matrix) -
scal
-
copy
Compute y <- x (copy a matrix) -
copy
-
axpy
Compute y <- alpha * x + y (elementwise addition) -
axpy
public static ComplexDoubleMatrix axpy(ComplexDouble da, ComplexDoubleMatrix dx, ComplexDoubleMatrix dy) -
dot
Compute x^T * y (dot product) -
dotc
Compute x^T * y (dot product) -
dotu
Compute x^T * y (dot product) -
nrm2
Compute || x ||_2 (2-norm) -
nrm2
-
asum
Compute || x ||_1 (1-norm, sum of absolute values) -
asum
-
iamax
Compute index of element with largest absolute value (index of absolute value maximum) -
iamax
Compute index of element with largest absolute value (complex version).- Parameters:
x- matrix- Returns:
- index of element with largest absolute value.
-
gemv
public static DoubleMatrix gemv(double alpha, DoubleMatrix a, DoubleMatrix x, double beta, DoubleMatrix y) Compute y <- alpha*op(a)*x + beta * y (general matrix vector multiplication) -
ger
Compute A <- alpha * x * y^T + A (general rank-1 update) -
geru
public static ComplexDoubleMatrix geru(ComplexDouble alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y, ComplexDoubleMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update) -
gerc
public static ComplexDoubleMatrix gerc(ComplexDouble alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y, ComplexDoubleMatrix a) Compute A <- alpha * x * y^H + A (general rank-1 update) -
gemm
public static DoubleMatrix gemm(double alpha, DoubleMatrix a, DoubleMatrix b, double beta, DoubleMatrix c) Compute c <- a*b + beta * c (general matrix matrix multiplication) -
gemm
public static ComplexDoubleMatrix gemm(ComplexDouble alpha, ComplexDoubleMatrix a, ComplexDoubleMatrix b, ComplexDouble beta, ComplexDoubleMatrix c) -
gesv
LAPACK -
sysv
-
syev
-
syevx
public static int syevx(char jobz, char range, char uplo, DoubleMatrix a, double vl, double vu, int il, int iu, double abstol, DoubleMatrix w, DoubleMatrix z) -
syevd
-
syevr
public static int syevr(char jobz, char range, char uplo, DoubleMatrix a, double vl, double vu, int il, int iu, double abstol, DoubleMatrix w, DoubleMatrix z, int[] isuppz) -
posv
-
geev
public static int geev(char jobvl, char jobvr, DoubleMatrix A, DoubleMatrix WR, DoubleMatrix WI, DoubleMatrix VL, DoubleMatrix VR) -
sygvd
public static int sygvd(int itype, char jobz, char uplo, DoubleMatrix A, DoubleMatrix B, DoubleMatrix W) -
sygvx
public static int sygvx(int itype, char jobz, char range, char uplo, DoubleMatrix A, DoubleMatrix B, double vl, double vu, int il, int iu, double abstol, int[] m, DoubleMatrix W, DoubleMatrix Z) -
gelsd
Generalized Least Squares via *GELSD. Note that B must be padded to contain the solution matrix. This occurs when A has fewer rows than columns. For example: in A * X = B, A is (m,n), X is (n,k) and B is (m,k). Now if m < n, since B is overwritten to contain the solution (in classical LAPACK style), B needs to be padded to be an (n,k) matrix. Likewise, if m > n, the solution consists only of the first n rows of B.- Parameters:
A- an (m,n) matrixB- an (max(m,n), k) matrix (well, at least)
-
geqrf
-
ormqr
-
orgqr
-
swap
Compute x <-> y (swap two matrices) -
scal
Compute x <- alpha * x (scale a matrix) -
scal
-
copy
Compute y <- x (copy a matrix) -
copy
-
axpy
Compute y <- alpha * x + y (elementwise addition) -
axpy
public static ComplexFloatMatrix axpy(ComplexFloat da, ComplexFloatMatrix dx, ComplexFloatMatrix dy) -
dot
Compute x^T * y (dot product) -
dotc
Compute x^T * y (dot product) -
dotu
Compute x^T * y (dot product) -
nrm2
Compute || x ||_2 (2-norm) -
nrm2
-
asum
Compute || x ||_1 (1-norm, sum of absolute values) -
asum
-
iamax
Compute index of element with largest absolute value (index of absolute value maximum) -
iamax
Compute index of element with largest absolute value (complex version).- Parameters:
x- matrix- Returns:
- index of element with largest absolute value.
-
gemv
public static FloatMatrix gemv(float alpha, FloatMatrix a, FloatMatrix x, float beta, FloatMatrix y) Compute y <- alpha*op(a)*x + beta * y (general matrix vector multiplication) -
ger
Compute A <- alpha * x * y^T + A (general rank-1 update) -
geru
public static ComplexFloatMatrix geru(ComplexFloat alpha, ComplexFloatMatrix x, ComplexFloatMatrix y, ComplexFloatMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update) -
gerc
public static ComplexFloatMatrix gerc(ComplexFloat alpha, ComplexFloatMatrix x, ComplexFloatMatrix y, ComplexFloatMatrix a) Compute A <- alpha * x * y^H + A (general rank-1 update) -
gemm
public static FloatMatrix gemm(float alpha, FloatMatrix a, FloatMatrix b, float beta, FloatMatrix c) Compute c <- a*b + beta * c (general matrix matrix multiplication) -
gemm
public static ComplexFloatMatrix gemm(ComplexFloat alpha, ComplexFloatMatrix a, ComplexFloatMatrix b, ComplexFloat beta, ComplexFloatMatrix c) -
gesv
LAPACK -
sysv
-
syev
-
syevx
public static int syevx(char jobz, char range, char uplo, FloatMatrix a, float vl, float vu, int il, int iu, float abstol, FloatMatrix w, FloatMatrix z) -
syevd
-
syevr
public static int syevr(char jobz, char range, char uplo, FloatMatrix a, float vl, float vu, int il, int iu, float abstol, FloatMatrix w, FloatMatrix z, int[] isuppz) -
posv
-
geev
public static int geev(char jobvl, char jobvr, FloatMatrix A, FloatMatrix WR, FloatMatrix WI, FloatMatrix VL, FloatMatrix VR) -
sygvd
public static int sygvd(int itype, char jobz, char uplo, FloatMatrix A, FloatMatrix B, FloatMatrix W) -
sygvx
public static int sygvx(int itype, char jobz, char range, char uplo, FloatMatrix A, FloatMatrix B, float vl, float vu, int il, int iu, float abstol, int[] m, FloatMatrix W, FloatMatrix Z) -
gelsd
Generalized Least Squares via *GELSD. Note that B must be padded to contain the solution matrix. This occurs when A has fewer rows than columns. For example: in A * X = B, A is (m,n), X is (n,k) and B is (m,k). Now if m < n, since B is overwritten to contain the solution (in classical LAPACK style), B needs to be padded to be an (n,k) matrix. Likewise, if m > n, the solution consists only of the first n rows of B.- Parameters:
A- an (m,n) matrixB- an (max(m,n), k) matrix (well, at least)
-
geqrf
-
ormqr
-
orgqr
-