Package org.jblas
Class SimpleBlas
- java.lang.Object
-
- org.jblas.SimpleBlas
-
public class SimpleBlas extends java.lang.ObjectThis 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 Constructor Description SimpleBlas()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleasum(ComplexDoubleMatrix x)static floatasum(ComplexFloatMatrix x)static 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)private static voidcheckInfo(java.lang.String name, int info)static ComplexDoubleMatrixcopy(ComplexDoubleMatrix x, ComplexDoubleMatrix y)static ComplexFloatMatrixcopy(ComplexFloatMatrix x, ComplexFloatMatrix y)static 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 ComplexDoubledotc(ComplexDoubleMatrix x, ComplexDoubleMatrix y)Compute x^T * y (dot product)static ComplexFloatdotc(ComplexFloatMatrix x, ComplexFloatMatrix y)Compute x^T * y (dot product)static ComplexDoubledotu(ComplexDoubleMatrix x, ComplexDoubleMatrix y)Compute x^T * y (dot product)static ComplexFloatdotu(ComplexFloatMatrix x, ComplexFloatMatrix y)Compute 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 intiamax(ComplexDoubleMatrix x)Compute index of element with largest absolute value (complex version).static intiamax(ComplexFloatMatrix x)Compute index of element with largest absolute value (complex version).static intiamax(DoubleMatrix x)Compute 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 doublenrm2(ComplexDoubleMatrix x)static floatnrm2(ComplexFloatMatrix x)static 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)
-
-
-
Method Detail
-
swap
public static DoubleMatrix swap(DoubleMatrix x, DoubleMatrix y)
Compute x <-> y (swap two matrices)
-
scal
public static DoubleMatrix scal(double alpha, DoubleMatrix x)
Compute x <- alpha * x (scale a matrix)
-
scal
public static ComplexDoubleMatrix scal(ComplexDouble alpha, ComplexDoubleMatrix x)
-
copy
public static DoubleMatrix copy(DoubleMatrix x, DoubleMatrix y)
Compute y <- x (copy a matrix)
-
copy
public static ComplexDoubleMatrix copy(ComplexDoubleMatrix x, ComplexDoubleMatrix y)
-
axpy
public static DoubleMatrix axpy(double da, DoubleMatrix dx, DoubleMatrix dy)
Compute y <- alpha * x + y (elementwise addition)
-
axpy
public static ComplexDoubleMatrix axpy(ComplexDouble da, ComplexDoubleMatrix dx, ComplexDoubleMatrix dy)
-
dot
public static double dot(DoubleMatrix x, DoubleMatrix y)
Compute x^T * y (dot product)
-
dotc
public static ComplexDouble dotc(ComplexDoubleMatrix x, ComplexDoubleMatrix y)
Compute x^T * y (dot product)
-
dotu
public static ComplexDouble dotu(ComplexDoubleMatrix x, ComplexDoubleMatrix y)
Compute x^T * y (dot product)
-
nrm2
public static double nrm2(DoubleMatrix x)
Compute || x ||_2 (2-norm)
-
nrm2
public static double nrm2(ComplexDoubleMatrix x)
-
asum
public static double asum(DoubleMatrix x)
Compute || x ||_1 (1-norm, sum of absolute values)
-
asum
public static double asum(ComplexDoubleMatrix x)
-
iamax
public static int iamax(DoubleMatrix x)
Compute index of element with largest absolute value (index of absolute value maximum)
-
iamax
public static int iamax(ComplexDoubleMatrix x)
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
public static DoubleMatrix ger(double alpha, DoubleMatrix x, DoubleMatrix y, DoubleMatrix a)
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
public static DoubleMatrix gesv(DoubleMatrix a, int[] ipiv, DoubleMatrix b)
LAPACK
-
checkInfo
private static void checkInfo(java.lang.String name, int info)
-
sysv
public static DoubleMatrix sysv(char uplo, DoubleMatrix a, int[] ipiv, DoubleMatrix b)
-
syev
public static int syev(char jobz, char uplo, DoubleMatrix a, DoubleMatrix w)
-
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
public static int syevd(char jobz, char uplo, DoubleMatrix A, DoubleMatrix w)
-
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
public static void posv(char uplo, DoubleMatrix A, DoubleMatrix B)
-
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
public static void gelsd(DoubleMatrix A, DoubleMatrix B)
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
public static void geqrf(DoubleMatrix A, DoubleMatrix tau)
-
ormqr
public static void ormqr(char side, char trans, DoubleMatrix A, DoubleMatrix tau, DoubleMatrix C)
-
orgqr
public static void orgqr(int n, int k, DoubleMatrix A, DoubleMatrix tau)
-
swap
public static FloatMatrix swap(FloatMatrix x, FloatMatrix y)
Compute x <-> y (swap two matrices)
-
scal
public static FloatMatrix scal(float alpha, FloatMatrix x)
Compute x <- alpha * x (scale a matrix)
-
scal
public static ComplexFloatMatrix scal(ComplexFloat alpha, ComplexFloatMatrix x)
-
copy
public static FloatMatrix copy(FloatMatrix x, FloatMatrix y)
Compute y <- x (copy a matrix)
-
copy
public static ComplexFloatMatrix copy(ComplexFloatMatrix x, ComplexFloatMatrix y)
-
axpy
public static FloatMatrix axpy(float da, FloatMatrix dx, FloatMatrix dy)
Compute y <- alpha * x + y (elementwise addition)
-
axpy
public static ComplexFloatMatrix axpy(ComplexFloat da, ComplexFloatMatrix dx, ComplexFloatMatrix dy)
-
dot
public static float dot(FloatMatrix x, FloatMatrix y)
Compute x^T * y (dot product)
-
dotc
public static ComplexFloat dotc(ComplexFloatMatrix x, ComplexFloatMatrix y)
Compute x^T * y (dot product)
-
dotu
public static ComplexFloat dotu(ComplexFloatMatrix x, ComplexFloatMatrix y)
Compute x^T * y (dot product)
-
nrm2
public static float nrm2(FloatMatrix x)
Compute || x ||_2 (2-norm)
-
nrm2
public static float nrm2(ComplexFloatMatrix x)
-
asum
public static float asum(FloatMatrix x)
Compute || x ||_1 (1-norm, sum of absolute values)
-
asum
public static float asum(ComplexFloatMatrix x)
-
iamax
public static int iamax(FloatMatrix x)
Compute index of element with largest absolute value (index of absolute value maximum)
-
iamax
public static int iamax(ComplexFloatMatrix x)
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
public static FloatMatrix ger(float alpha, FloatMatrix x, FloatMatrix y, FloatMatrix a)
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
public static FloatMatrix gesv(FloatMatrix a, int[] ipiv, FloatMatrix b)
LAPACK
-
sysv
public static FloatMatrix sysv(char uplo, FloatMatrix a, int[] ipiv, FloatMatrix b)
-
syev
public static int syev(char jobz, char uplo, FloatMatrix a, FloatMatrix w)
-
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
public static int syevd(char jobz, char uplo, FloatMatrix A, FloatMatrix w)
-
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
public static void posv(char uplo, FloatMatrix A, FloatMatrix B)
-
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
public static void gelsd(FloatMatrix A, FloatMatrix B)
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
public static void geqrf(FloatMatrix A, FloatMatrix tau)
-
ormqr
public static void ormqr(char side, char trans, FloatMatrix A, FloatMatrix tau, FloatMatrix C)
-
orgqr
public static void orgqr(int n, int k, FloatMatrix A, FloatMatrix tau)
-
-