Linear Algebra

Linear algebra is the foundation ojAlgo is built on. The optimisation solvers, the neural networks, the statistics and the finance code all sit on top of it — and it is the part with the longest independent track record.

ojAlgo is the fastest pure Java linear algebra library available. That is not our own benchmark: it is the Java Matrix Benchmark, a third-party independent comparison written by nobody associated with ojAlgo.

Pure Java, zero dependencies. No BLAS to install, no LAPACK to link, no native binaries to package per platform, no JNI boundary to debug. It runs anywhere the JVM runs.

Matrices and decompositions

ojAlgo implements the standard matrix decompositions, each with dense implementations and, where it matters, sparse ones:

Cholesky symmetric positive-definite systems
LU / LDL / LDU general square systems, with sparse SparseLU and SparseQDLDL variants
QR least squares and over-determined systems
Singular Value SVD — rank, pseudo-inverse, low-rank approximation
Eigenvalue general, Hermitian and generalised problems
Bidiagonal, Hessenberg, Tridiagonal the reductions the above are built from, exposed directly

On top of those sit task-level abstractions — solve a system, invert a matrix, compute a determinant — which pick a suitable decomposition for the matrix you actually have rather than making you choose one up front.

New to this? Start with the Linear Algebra Introduction.

The array layer underneath

The matrices are built on a collection of array classes, and those are worth knowing about in their own right. They can be:

  • sparse or dense, and arbitrarily large
  • used as 1-, 2- or N-dimensional structures
  • filled with a range of number types — not only double and float, but complex numbers, rational numbers and quaternions
  • allocated on heap, off heap, or in a file, so problem size is not bounded by what fits in the JVM heap

This is what makes ojAlgo fast: the library is machine-aware and resource-efficient, and that is what enables scaling up rather than out.

Further reading: Working With Arrays, Sparse and Special Structure Matrices, and The Memory Estimator.

Performance

Beyond the Java Matrix Benchmark, there is a long record of measurement published here — including how ojAlgo behaves across JVM implementations, which turns out to matter more than most people expect:

What people build with it

Linear algebra is rarely the goal in itself. Some worked examples from the blog:

Get started

Add ojAlgo as a single Maven dependency — see the home page for the current coordinates — and read the source. For a library this size the code answers questions faster than prose can, and the repository is at github.com/optimatika/ojAlgo.