Package org.jblas
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 double
static float
static double
asum
(DoubleMatrix x) Compute || x ||_1 (1-norm, sum of absolute values)static float
asum
(FloatMatrix x) Compute || x ||_1 (1-norm, sum of absolute values)static DoubleMatrix
axpy
(double da, DoubleMatrix dx, DoubleMatrix dy) Compute y <- alpha * x + y (elementwise addition)static FloatMatrix
axpy
(float da, FloatMatrix dx, FloatMatrix dy) Compute y <- alpha * x + y (elementwise addition)static ComplexDoubleMatrix
axpy
(ComplexDouble da, ComplexDoubleMatrix dx, ComplexDoubleMatrix dy) static ComplexFloatMatrix
axpy
(ComplexFloat da, ComplexFloatMatrix dx, ComplexFloatMatrix dy) static ComplexDoubleMatrix
static ComplexFloatMatrix
static DoubleMatrix
copy
(DoubleMatrix x, DoubleMatrix y) Compute y <- x (copy a matrix)static FloatMatrix
copy
(FloatMatrix x, FloatMatrix y) Compute y <- x (copy a matrix)static double
dot
(DoubleMatrix x, DoubleMatrix y) Compute x^T * y (dot product)static float
dot
(FloatMatrix x, FloatMatrix y) Compute x^T * y (dot product)static ComplexDouble
Compute x^T * y (dot product)static ComplexFloat
Compute x^T * y (dot product)static ComplexDouble
Compute x^T * y (dot product)static ComplexFloat
Compute x^T * y (dot product)static int
geev
(char jobvl, char jobvr, DoubleMatrix A, DoubleMatrix WR, DoubleMatrix WI, DoubleMatrix VL, DoubleMatrix VR) static int
geev
(char jobvl, char jobvr, FloatMatrix A, FloatMatrix WR, FloatMatrix WI, FloatMatrix VL, FloatMatrix VR) static void
gelsd
(DoubleMatrix A, DoubleMatrix B) Generalized Least Squares via *GELSD.static void
gelsd
(FloatMatrix A, FloatMatrix B) Generalized Least Squares via *GELSD.static DoubleMatrix
gemm
(double alpha, DoubleMatrix a, DoubleMatrix b, double beta, DoubleMatrix c) Compute c <- a*b + beta * c (general matrix matrix multiplication)static FloatMatrix
gemm
(float alpha, FloatMatrix a, FloatMatrix b, float beta, FloatMatrix c) Compute c <- a*b + beta * c (general matrix matrix multiplication)static ComplexDoubleMatrix
gemm
(ComplexDouble alpha, ComplexDoubleMatrix a, ComplexDoubleMatrix b, ComplexDouble beta, ComplexDoubleMatrix c) static ComplexFloatMatrix
gemm
(ComplexFloat alpha, ComplexFloatMatrix a, ComplexFloatMatrix b, ComplexFloat beta, ComplexFloatMatrix c) 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)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)static void
geqrf
(DoubleMatrix A, DoubleMatrix tau) static void
geqrf
(FloatMatrix A, FloatMatrix tau) static DoubleMatrix
ger
(double alpha, DoubleMatrix x, DoubleMatrix y, DoubleMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update)static FloatMatrix
ger
(float alpha, FloatMatrix x, FloatMatrix y, FloatMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update)static ComplexDoubleMatrix
gerc
(ComplexDouble alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y, ComplexDoubleMatrix a) Compute A <- alpha * x * y^H + A (general rank-1 update)static ComplexFloatMatrix
gerc
(ComplexFloat alpha, ComplexFloatMatrix x, ComplexFloatMatrix y, ComplexFloatMatrix a) Compute A <- alpha * x * y^H + A (general rank-1 update)static ComplexDoubleMatrix
geru
(ComplexDouble alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y, ComplexDoubleMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update)static ComplexFloatMatrix
geru
(ComplexFloat alpha, ComplexFloatMatrix x, ComplexFloatMatrix y, ComplexFloatMatrix a) Compute A <- alpha * x * y^T + A (general rank-1 update)static DoubleMatrix
gesv
(DoubleMatrix a, int[] ipiv, DoubleMatrix b) LAPACKstatic FloatMatrix
gesv
(FloatMatrix a, int[] ipiv, FloatMatrix b) LAPACKstatic int
Compute index of element with largest absolute value (complex version).static int
Compute index of element with largest absolute value (complex version).static int
Compute index of element with largest absolute value (index of absolute value maximum)static int
iamax
(FloatMatrix x) Compute index of element with largest absolute value (index of absolute value maximum)static double
static float
static double
nrm2
(DoubleMatrix x) Compute || x ||_2 (2-norm)static float
nrm2
(FloatMatrix x) Compute || x ||_2 (2-norm)static void
orgqr
(int n, int k, DoubleMatrix A, DoubleMatrix tau) static void
orgqr
(int n, int k, FloatMatrix A, FloatMatrix tau) static void
ormqr
(char side, char trans, DoubleMatrix A, DoubleMatrix tau, DoubleMatrix C) static void
ormqr
(char side, char trans, FloatMatrix A, FloatMatrix tau, FloatMatrix C) static void
posv
(char uplo, DoubleMatrix A, DoubleMatrix B) static void
posv
(char uplo, FloatMatrix A, FloatMatrix B) static DoubleMatrix
scal
(double alpha, DoubleMatrix x) Compute x <- alpha * x (scale a matrix)static FloatMatrix
scal
(float alpha, FloatMatrix x) Compute x <- alpha * x (scale a matrix)static ComplexDoubleMatrix
scal
(ComplexDouble alpha, ComplexDoubleMatrix x) static ComplexFloatMatrix
scal
(ComplexFloat alpha, ComplexFloatMatrix x) static DoubleMatrix
swap
(DoubleMatrix x, DoubleMatrix y) Compute x <-> y (swap two matrices)static FloatMatrix
swap
(FloatMatrix x, FloatMatrix y) Compute x <-> y (swap two matrices)static int
syev
(char jobz, char uplo, DoubleMatrix a, DoubleMatrix w) static int
syev
(char jobz, char uplo, FloatMatrix a, FloatMatrix w) static int
syevd
(char jobz, char uplo, DoubleMatrix A, DoubleMatrix w) static int
syevd
(char jobz, char uplo, FloatMatrix A, FloatMatrix w) 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) 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) 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) 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) static int
sygvd
(int itype, char jobz, char uplo, DoubleMatrix A, DoubleMatrix B, DoubleMatrix W) static int
sygvd
(int itype, char jobz, char uplo, FloatMatrix A, FloatMatrix B, FloatMatrix W) 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) 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) static DoubleMatrix
sysv
(char uplo, DoubleMatrix a, int[] ipiv, DoubleMatrix b) static FloatMatrix
sysv
(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
-