MTJ is a high-performance library for developing linear algebra applications.
MTJ uses the
netlib-java project as a backend,
which will automatically use machine-optimised natives, if they are available. Please read the
netlib-java documentation for the extra steps needed to ensure that you are getting the best performance for your system.
Performance to Other Libraries
The java-matrix-benchmark clearly shows MTJ to be the most performant Java library for large matrices:
A more complete breakdown is available: MTJ with system optimised natives wins almost every benchmark.
A variety of sparse matrix / vector storage classes are available:
LinkedSparseMatrix storage type is a novel storage type developed under this project. It maintains two tail links, one for the next matrix element by row order and another by column order. Lookups are kept into each row and column, making multiplication and transpose multiplication very fast.
The following charts compare the
DenseMatrix for increasing matrix size (
n x n) and number of non-zero elements,
m. Rainbow lines indicate
m varied from
100,000. Solid lines are for dense matrix, dashed lines are the sparse matrix.
The following is time to initialise the matrix:
The following is the memory consumption:
The following is the time to perform a multiplication with a dense matrix and output into a dense matrix:
In addition, implementations of the netlib Templates are available in the
Users may wish to look at Sparse Eigensolvers for Java for another solver.
- Copyright (C) 2003-2006 Bjørn-Ove Heimsund
- Copyright (C) 2006-2014 Samuel Halliday
This project was originally written by Bjørn-Ove Heimsund, who has taken a step back due to other commitments.
Releases are distributed on Maven central:
<dependency> <groupId>com.googlecode.matrix-toolkits-java</groupId> <artifactId>mtj</artifactId> <version>1.0.2</version> </dependency>
Snapshots may be distributed on Sonatype's Snapshot Repository (if you submit a pull request, a build will appear here when it is merged):
<dependency> <groupId>com.googlecode.matrix-toolkits-java</groupId> <artifactId>mtj</artifactId> <version>1.0.3-SNAPSHOT</version> </dependency>
Contributors are encouraged to fork this repository and issue pull requests. Contributors implicitly agree to assign an unrestricted licence to Sam Halliday, but retain the copyright of their code (this means we both have the freedom to update the licence for those contributions).