Ndarray java

Kragen Javier Sitaker, 2015-05-28 (1 minute)

Different libraries for n-dimensional arrays in Java. None seem to support memory-mapping the arrays to files. What I really want is a minimal-overhead way to randomly access a giant column of index values written out by a now-dead process.

http://www.kdgregory.com/?page=java.byteBuffer explains how to use java.nio.MappedByteBuffer.

Vectorz

https://github.com/mikera/vectorz

“designed to allow the maximum performance possible for vector maths on the JVM”

Vector3 v=Vector3.of(1.0,2.0,3.0);      
v.normalise();                       // normalise v to a unit vector
Vector3 d=Vector3.of(10.0,0.0,0.0);     
d.addMultiple(v, 5.0);               // d = d + (v * 5)

1 billion vector operations per second. Has a Clojure interface.

Colt

http://dst.lbl.gov/ACSSoftware/colt/api/cern/colt/matrix/package-summary.html#Overview

“an infrastructure for scalable scientific and technical computing in Java. It is particularly useful in the domain of High Energy Physics at CERN”

double[] v1 = {0, 1, 2, 3}; 
DoubleMatrix1D matrix = new DenseDoubleMatrix1D(v1);
cern.jet.math.Functions F = cern.jet.math.Functions.functions;
// Sum( x[i]*x[i] ) 
System.out.println(matrix.aggregate(F.plus, F.square));

"...LU, QR, Cholesky, Eigenvalue, Singular value..."

ND4J

http://nd4j.org/

“a scientific computing library for the JVM. It is meant to be used in production environments rather than as a research tool...CUDA...API mimics the semantics of Numpy [and] Matlab”

INDArray arr1 = Nd4j.create(new float[]{1,2,3,4},new int[]{2,2}); INDArray arr2 = ND4j.create(new float[]{5,6,7,8},new int[]{2,2}); arr1.addi(arr2); System.out.println(arr1);

Apparently this is the library used by DeepLearning4J.

LArray

https://github.com/Ponnie/larray

Safely-unmappable memory-mapped files, including >2GB, as arrays in Java, with map, filter, reduce, zip, etc. But no n-dimensional arrays.

util-mmap

http://engineering.indeed.com/blog/2015/02/memory-mapping-with-util-mmap/

This is a replacement for java.nio.MappedByteBuffer that overcomes its 2GB limit. Also, supports little-endian.

Topics