I’ve been doing some work that required some more heavy lifting from a Linear Algebra library than what Apache Commons or JAMA could offer me, and thanks to this extremely handy-dandy, but a bit out-dated website, I found out about JBLAS, a (mostly) JNI wrapper for the BLAS and LAPACK libraries.

I work on Fedora, and the currently supported versions are 26 and 27. The current version of JBLAS (1.2.4), or rather BLAS, has a dependency on libgfortran.so.3, but the libgfortran package included in the Fedora 26 distribution (as of this writing 7.2.1-2) only has libgfortran.so.4. What to do?

The solution is to install both the old and new libgfortran libraries side-by-side.

I downloaded the old rpm from rpmfind.net and with the command:

`sudo rpm -ihv --nodeps --force libgfortran-6.4.1-1.fc25.x86_64.rpm`

I was able to get the package installed and JBLAS to run expected.

java -server -jar jblas-1.2.4.jar

— 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 : 2.596 GFLOPS (6491027 iterations in 5.0 seconds)

n = 100 : 2.923 GFLOPS (7309 iterations in 5.0 seconds)

n = 1000 : 2.536 GFLOPS (7 iterations in 5.5 seconds)

Running benchmark “Java matrix multiplication, single precision”.

n = 10 : 2.482 GFLOPS (6206108 iterations in 5.0 seconds)

n = 100 : 2.408 GFLOPS (6022 iterations in 5.0 seconds)

n = 1000 : 2.381 GFLOPS (7 iterations in 5.9 seconds)

Running benchmark “native matrix multiplication, double precision”.

n = 10 : 1.934 GFLOPS (4835014 iterations in 5.0 seconds)

n = 100 : 8.372 GFLOPS (20931 iterations in 5.0 seconds)

n = 1000 : 12.484 GFLOPS (32 iterations in 5.1 seconds)

Running benchmark “native matrix multiplication, single precision”.

n = 10 : 2.034 GFLOPS (5084278 iterations in 5.0 seconds)

n = 100 : 14.752 GFLOPS (36880 iterations in 5.0 seconds)

n = 1000 : 24.376 GFLOPS (61 iterations in 5.0 seconds)

— org.jblas INFO Deleting /tmp/jblas4508559549457543065/libjblas.so

— org.jblas INFO Deleting /tmp/jblas4508559549457543065/libjblas_arch_flavor.so

— org.jblas INFO Deleting /tmp/jblas4508559549457543065