Efficient Java Matrix Library

Last updated
Efficient Java Matrix Library
Original author Peter Abeles
Stable release
0.41.1 / December 4, 2022;3 years ago (2022-12-04)
Repository
Operating system Cross-platform
Type Library
License Apache License
Website ejml.org

Efficient Java Matrix Library (EJML) is a linear algebra library for manipulating real/complex/dense/sparse matrices. Its design goals are; 1) to be as computationally and memory efficient as possible for both small and large matrices, and 2) to be accessible to both novices and experts. These goals are accomplished by dynamically selecting the best algorithms to use at runtime, clean API, and multiple interfaces. EJML is free, written in 100% Java and has been released under an Apache v2.0 license.

Contents

EJML has three distinct ways to interact with it: 1) Procedural, 2) SimpleMatrix, and 3) Equations. The procedural style provides all capabilities of EJML and almost complete control over matrix creation, speed, and specific algorithms. The SimpleMatrix style provides a simplified subset of the core capabilities in an easy to use flow-styled object-oriented API, inspired by JAMA. The Equations style provides a symbolic interface, similar in spirit to Matlab and other CAS, that provides a compact way of writing equations. [1]

Capabilities

EJML provides the following capabilities for dense matrices.

Usage examples

Equation style

Computing the Kalman gain:

eq.process("K = P*H'*inv( H*P*H' + R )");

Procedural style

Computing Kalman gain:

mult(H,P,c);multTransB(c,H,S);addEquals(S,R);if(!invert(S,S_inv))thrownewRuntimeException("Invert failed");multTransA(H,S_inv,d);mult(P,d,K);

SimpleMatrix style

Example of singular value decomposition (SVD):

SimpleSVDs=matA.svd();SimpleMatrixU=s.getU();SimpleMatrixW=s.getW();SimpleMatrixV=s.getV();

Example of matrix multiplication:

SimpleMatrixresult=matA.mult(matB);

DecompositionFactory

Use of a DecompositionFactory to compute a Singular Value Decomposition with a Dense Double Row Major matrix (DDRM): [2]

SingularValueDecomposition_F64<DenseMatrix64F>svd=DecompositionFactory_DDRM.svd(true,true,true);if(!DecompositionFactory.decomposeSafe(svd,matA))thrownewDetectedException("Decomposition failed.");DenseMatrix64FU=svd.getU(null,false);DenseMatrix64FS=svd.getW(null);DenseMatrix64FV=svd.getV(null,false);

Example of matrix multiplication:

CommonOps_DDRM.mult(matA,matB,result);

See also

References

  1. "EJML Project Page". EJML. Peter Abeles. Retrieved Jan 21, 2019.
  2. "Matrix Decompositions - Efficient Java Matrix Library". ejml.org. Retrieved 2021-04-24.