Universal Java Matrix Package
The Universal Java Matrix Package (UJMP) is an open source Java library that provides sparse and dense matrix classes, as well as a large number of calculations for linear algebra like matrix multiplication or matrix inverse. Operations such as mean, correlation, standard deviation, replacement of missing values or the calculation of mutual information are supported, too.
Quick LinksDocumentation Download Request Professional Support
The Universal Java Matrix Package provides various visualization methods, import and export filters for a large number of file formats, and even the possibility to link to JDBC databases. Multi-dimensional matrices as well as generic matrices with a specified object type are supported and very large matrices can be handled even when they do not fit into memory. Find out more and take a look at the feature list or compare it to other Java matrix libraries. We have also done a benchmark for matrix multiplication and matrix transposition which can be found here.
A central concept of UJMP is the separation of interfaces, abstract classes and their implementations, which makes it very easy to exchange the underlying data storage Thus, a matrix in our framework can be an array of values in main memory, a file on disk or a table in an SQL database. In fact, the actual storage implementation becomes secondary and UJMP can even integrate other matrix libraries such as Jama or Colt, making UJMP's visualization and import and export filters available to these libraries.
UJMP can decide to redirect calculations to other matrix libraries, depending on matrix size and computer hardware. UJMP uses multiple threads for calculations, which results in much better performance compared to JAMA or Colt on modern hardware.
UJMP also includes interfaces to Matlab, Octave and R, which makes it easy to perform calculations not available in Java.
UJMP is the mathematical back-end of the Java Data Mining Package (JDMP), which is our second open source Java project. While UJMP provides basic operations for processing matrices, JDMP concentrates on "higher-level" objects, such as Samples, DataSets and Algorithms for machine learning, e.g. clustering, classification and optimization. JDMP's central philosophy is that everything is a matrix (or can be converted into a matrix), which makes it possible to benefit a lot from UJMP's features. E.g. it becomes feasible to analyze data that does not fit into main memory, since UJMP can link to files on disk or databases. Like UJMP, also JDMP makes use of interfaces and abstract classes to allow for easy integration of other libraries like Weka or Mallet.
To find out if UJMP is the right choice for you, take a look at the feature list:
Matrix classes for different data types
Generic Matrix class
GenericMatrix<T>to specify the object type that is stored.
You can create matrices with any number of dimensions with
Matrix.Factory.sparse(rows, columns, size3, size4, ...)
Storage of more data than fits into memory
Matrices can be mapped to hard disk or databases.
Store up to 263-1 elements along one axis in a matrix
longvalues for indices instead of
Link to JDBC data sources
Work directly with your database:
Matrix.Factory.linkToJDBC(host, port, db, table, user, password)
Store meta-data for all matrices
It is easy to label a matrix or give names to the rows and columns.
Interact with other matrix libraries
Use Colt or Jama inside UJMP. In fact, you can tell UJMP to prefer a specific matrix implementation over its own classes.
Interfaces to other mathematical software
Execute complex computations in Matlab, Octave, R or GnuPlot. You can use these software packages as computing or visualization engines in UJMP.
Import and export filters for many different file types
TXT, CSV, HTML, XLS, XLSX, PDF, TEX (Latex), MAT (Matlab), MDB (MS Access), and many more.
Link to huge CSV files without loading them into memory
This is useful when your CSV file will not fit into your machine´s memory. Use
Additional collection classes
SoftHashMapwhich can be very helpful.
SerializedObjectMap to store more Objects than fit into memory
This Map stores all Objects on disk, but you can use it like a normal
Mapping of collection classes
Java collection classes like
Setcan be used as UJMP matrices, which makes it easy to perform calculations. E.g. you can calculate sum, average or standard deviation of a list of values in an
ArrayList. Use this to convert it to a UJMP matrix:
Heatmap, line plot, scatter plot, histogram and many more. Just use
myMatrix.showGUI()to bring it on the screen. Take a look at the screenshots for examples.
Licensed under LGPL
you can use it in commercial applications.
Depending on your needs, you can either download jar packages of the latest release of UJMP, or check out the latest source code via SVN, if you want to stay on the edge.
Download JAR Packages
The easiest way to get started with UJMP is to download ujmp-complete.jar from SourceForge.
This package contains ujmp-core, the main part of the Universal Java Matrix Package, as well as additional features such as visualization
and interfaces to other libraries, SQL databases, and a lot more. If you are new to this library, you should invoke the
main() method in
org.ujmp.core.UJMP to get a glimpse on UJMP:
java -jar ujmp-complete.jar
Then click on “Tools – UJMP Plugins” in the menu bar and see what third party libraries are supported. Chose the tool you want, add the necessary dependencies to the class path and restart UJMP.
Download SVN Source Code
The source code of UJMP is available via anonymous SVN from Sourceforge, and you can view the SVN repository in your web browser, if you like.
As you can see, there are many sub-projects in the repository, but probably you don’t need all of them.
You should check out ujmp-core and ujmp-gui first, the other projects are needed only, if you want to use other libraries together with UJMP.
E.g. if you want to use JAMA, you would have to check out the ujmp-jama project.
If you use Maven for software development, you should also check
out the ujmp project, which provides the parent pom files for all sub-projects.
All projects provide a
.project file for Eclipse, which makes it easy to download them into this IDE.
Here is the command line instruction set to get the basic version of UJMP:
svn co https://svn.code.sf.net/p/ujmp/code/trunk/ujmp-core ujmp-core svn co https://svn.code.sf.net/p/ujmp/code/trunk/ujmp-gui ujmp-gui
If you use Maven, check out this project, too:
svn co https://svn.code.sf.net/p/ujmp/code/trunk/ujmp ujmp
What It's Not
While some parts of UJMP are already pretty stable, a lot of development is still going on in other parts. There is no guarantee that everything will be working as expected.
Not well documented
Since many things are going to change anyway, I didn't bother much to write comments for functions or JavaDoc for parameters.
Not a lightweight matrix library
If you just need linear algebra for double matrices, there are probably better choices, such as EJML or Ojalgo. UJMP is rather a swiss army knife for data processing. It will help you when you want to find all Excel files which contain the text "Invoice", extract the total amount, and show a nice overview. UJMP can do this with 8 lines of code.
There are many matrix packages available for Java. If you are interested in alternative matrix packages, this table may be helpful.