Fork me on GitHub

by mikiobraun

Linear Algebra for Java (Current Version: V1.2.4)

jblas is a fast linear algebra library for Java. jblas is based on BLAS and LAPACK, the de-facto industry standard for matrix computations, and uses state-of-the-art implementations like ATLAS for all its computational routines, making jBLAS very fast.

jblas can is essentially a light-wight wrapper around the BLAS and LAPACK routines. These packages have originated in the Fortran community which explains their often archaic API. On the other hand modern implementations are hard to beat performance wise. jblas aims to make this functionality available to Java programmers such that they do not have to worry about writing JNI interfaces and calling conventions of Fortran code.

jblas depends on an implementation of the LAPACK and BLAS routines. Currently it is tested with ATLAS (http://math-atlas.sourceforge.net/) and BLAS/LAPACK (http://www.netlib.org/lapack)

jblas - Fast matrix computations for Java

Download the examples from the slides here.

Getting Started

You have three options:

jblas is hosted on github.

Currently, Linux (i386/amd64), Mac OS X (i386/x86_64) and Windows (i386) are covered. Currently, only limited support for amd64 on Windows (full functionality, but not the same performance). Read here why.

For instructions on compiling everything yourself, see INSTALL.

If you download the prepackaged file, you can run it with java -server -jar jblas-1.2.4.jar

to check the basic install and get some performance number. On my laptop (Linux, i386, Core2Duo 2Ghz), I get the following:
-- org.jblas INFO jblas version is 1.2.4
Simple benchmark for jblas

Running sanity benchmarks.

checking vector addition... ok
-- org.jblas CONFIG BLAS native library not found in path. Copying native library from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH).
-- org.jblas CONFIG ArchFlavor native library not found in path. Copying native library libjblas_arch_flavor from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH).
-- org.jblas CONFIG Loading libjblas_arch_flavor.so from /lib/static/Linux/amd64/, copying to libjblas_arch_flavor.so.
-- org.jblas CONFIG Loading libjblas.so from /lib/static/Linux/amd64/sse3/, copying to libjblas.so.
checking matrix multiplication... ok
checking existence of dsyev...... ok
[-0.210656, -0.640445, -0.451188; -0.509085, -0.116445, 0.796815; -0.807515, 0.407556, -0.398408; 0.210656, 0.640445, -0.052780]
[17.233688; 1.414214; 0.000000]
[-0.470605, 0.782218, 0.408248; -0.571449, 0.082339, -0.816497; -0.672293, -0.617540, 0.408248]
[17.233688; 1.414214; 0.000000]
checking existence of dgesvd...... ok
Checking complex return values... (z = -21.0 + 88.0i)
Check whether we're catching XERBLA errors. If you see something like "** On entry to DGEMM  parameter number  4 had an illegal value", it didn't work!
checking XERBLA... ok
Sanity checks passed.

Each benchmark will take about 5 seconds...

Running benchmark "Java matrix multiplication, double precision".
n = 10   :  1.530 GFLOPS (3825688 iterations in 5.0 seconds)
n = 100  :  2.107 GFLOPS (5268 iterations in 5.0 seconds)
n = 1000 :  1.122 GFLOPS (3 iterations in 5.3 seconds)

Running benchmark "Java matrix multiplication, single precision".
n = 10   :  1.356 GFLOPS (3391101 iterations in 5.0 seconds)
n = 100  :  1.669 GFLOPS (4174 iterations in 5.0 seconds)
n = 1000 :  1.447 GFLOPS (4 iterations in 5.5 seconds)

Running benchmark "ATLAS matrix multiplication, double precision".
n = 10   :  1.475 GFLOPS (3686332 iterations in 5.0 seconds)
n = 100  :  5.408 GFLOPS (13523 iterations in 5.0 seconds)
n = 1000 :  8.076 GFLOPS (21 iterations in 5.2 seconds)

Running benchmark "ATLAS matrix multiplication, single precision".
n = 10   :  1.510 GFLOPS (3774883 iterations in 5.0 seconds)
n = 100  : 10.400 GFLOPS (26001 iterations in 5.0 seconds)
n = 1000 : 16.668 GFLOPS (42 iterations in 5.0 seconds)
    

Other sources of information:

Documentation

A good starting point are the API Documentations.

If you have more questions, go to the jblas-users mailing list .

Some info has been collected in the jblas wiki.

Finally, you might want to check out the issue tracker to check whether a bug is already known.

License

BSD Revised (see COPYING)

Authors

Mikio L. Braun, Johannes Schaback, Matthias L. Jugel, Nicolas Oury, and many more... .

Getting the Sources

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone https://github.com/mikiobraun/jblas.git