Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

EJML (Efficient Java Matrix Library) is a free, Apache 2.0-licensed Java library for working with real and complex, dense and sparse matrices. It supports common matrix operations and major decompositions such as SVD and eigenvalue decomposition, with three APIs for different coding styles: procedural Operations, fluent SimpleMatrix, and expression-oriented Equations.

What is EJML?

EJML is a linear algebra library for manipulating real, complex, dense, and sparse matrices. The project describes it as “free, written in 100% Java” and released under the Apache 2.0 license. Its goals are to provide computational and memory efficiency across small and large matrices while remaining approachable to both novice and experienced users. See the EJML project site.

It is a Java library rather than a standalone application: you add its artifacts to a Java project and call its APIs. Its formats include fixed-size matrices, dense row-major and block matrices, dense complex matrices, and compressed-column sparse real matrices. EJML provides both float (32-bit) and double (64-bit) variants.

Which EJML API should you use?

EJML offers three ways to express matrix work. The best fit depends on whether you value direct control, concise object-oriented code, or formulas that read like mathematical expressions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
API Best fit Trade-offs
Procedural Operations Code needing fine control over memory creation, speed, and algorithm selection. It exposes the broad capability set and offers control, but requires more explicit, lower-level code.
SimpleMatrix Readable, fluent, object-oriented matrix code. It is a smaller API inspired by Jama and easier to read, but creates and discards more objects than low-level procedural code.
Equations Compact expressions that closely follow matrix formulas. Its symbolic-style syntax resembles Matlab-style expressions; choose another API when you need its particular level of memory or algorithm control.

These are interface trade-offs, not a universal speed ranking. EJML says it uses internal benchmarks and the Java Matrix Benchmark to assess speed, but the project information cited here does not establish comparable numeric results for these APIs. Choose based on code clarity and control needs, then benchmark your own workload if performance is decisive. The EJML documentation provides API guidance.

What can EJML do?

For dense matrix work, EJML covers everyday arithmetic as well as solving and analysis. Its functionality includes:

  • Matrix arithmetic, extraction, insertion, and combination.
  • Linear-system and least-squares solvers.
  • LU, QR, and Cholesky decompositions.
  • Singular value decomposition (SVD) and eigenvalue decompositions.
  • Matrix-property checks, random matrix generation, and unit-testing support.

Complex matrices are supported in dense formats. Sparse support includes compressed-column sparse real matrices, but the project’s capability information indicates that sparse coverage is strongest for basic operations. Do not assume every dense solver or decomposition has an equivalent sparse implementation; check the specific operation and matrix type in the documentation before designing around it.

How to add EJML to Maven or Gradle

The project recommends using prebuilt artifacts from Maven Central rather than building EJML from source for ordinary use. The repository provides an aggregate artifact, org.ejml:ejml-all, as well as individual modules. The following snippets use Maven Central coordinates; select a version published in Maven Central and keep it consistent across EJML dependencies.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Maven: aggregate dependency

<dependency>
  <groupId>org.ejml</groupId>
  <artifactId>ejml-all</artifactId>
  <version>YOUR_VERSION</version>
</dependency>

Gradle: aggregate dependency

dependencies {
    implementation("org.ejml:ejml-all:YOUR_VERSION")
}

Replace YOUR_VERSION with the version you select from the published artifact metadata; it is not a literal version. The aggregate is convenient when you want broad EJML coverage. If you want narrower dependency scope, use only the required modules. The repository lists ejml-core, ejml-ddense, ejml-fdense, ejml-cdense, ejml-zdense, ejml-dsparse, ejml-fsparse, and ejml-simple. Confirm module dependencies and coordinates for your chosen release in the EJML repository and Maven Central.

Java module-path projects

If your application uses the Java Platform Module System (JPMS), use the aggregated ejml-java9module on the module path. The README warns that combining individual EJML modules there can cause split-package errors. This advice concerns JPMS module-path use; it is distinct from adding dependencies to the ordinary classpath.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Java version and version selection

Separate the Java version needed to build EJML from the bytecode target: the repository README says building EJML requires Java 17 or higher, while generated bytecode targets Java 11. Those facts do not by themselves guarantee that every EJML release or build setup will suit a particular application, so check the release notes and artifact metadata against your project’s Java version.

Version listings can differ by artifact and page. The EJML project page reports v0.45.0 dated May 15, 2026, while Sonatype Central lists org.ejml:ejml-core version 0.46.1. These are not necessarily contradictory: one is a project-page release listing and the other is a version for a particular Maven artifact. Use the metadata for the exact coordinate you plan to depend on, and verify it when configuring a project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

License and performance expectations

EJML is free software under the Apache 2.0 license. The project reports using internal benchmarks and the Java Matrix Benchmark to assess speed, but no specific comparable benchmark figure is established here. Performance depends on the operation, matrix dimensions and format, API, and workload; measure your application’s representative cases rather than treating the library’s name or design goals as a performance guarantee.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.