Java matrix libraries [closed]
Asked Answered
O

6

33

I was wondering whether any of the well-known matrix libraries for Java, such as Colt or EJML, actually provide similar functionality as MatLab? For instance, I can't seem to find anywhere in the definition of their API simple method to add or subtract two matrices/vectors by each other, which seems to be the most common operation used. Am I missing something?

Ovolo answered 30/5, 2012 at 11:36 Comment(0)
F
15

Try Apache Commons Math library. org.apache.commons.math3.linear package contains the functions that you want. Home page

Falsetto answered 30/5, 2012 at 11:47 Comment(1)
Yes, but that is probably less efficient then Colt or EJMLOvolo
S
42

Some Java libraries for linear algebra are:

EDIT maybe we can extend this list whenever one comes across and you know - the world keeps moving:

Note: Personally: I use Apache Commons Math and Colt in my own project (http://www.finmath.net). While commons math is actively developed, I found that Colt is still faster in some tasks (like Eigenvalue decomposition). For that reason I use some kind of wrapper which allows me to quickly switch the underlying library (I only need a few things like solving systems of equations and Eigenvalue decomposition).

Spook answered 5/5, 2013 at 19:55 Comment(3)
JEigen does not appear to implement solving sparse matrices so I did it myself.Zincography
jscience.org/api/org/jscience/mathematics/vector/… -- JScience also supports basic math operations on Matrices and VectorsAffright
github.com/BIDData/BIDMat might be a good addition as well.. (though I don't have experience with it)Loxodromic
F
15

Try Apache Commons Math library. org.apache.commons.math3.linear package contains the functions that you want. Home page

Falsetto answered 30/5, 2012 at 11:47 Comment(1)
Yes, but that is probably less efficient then Colt or EJMLOvolo
T
2

The interface for COLT gives you a generic OP: assign(matrix, function), which you can use to add or subtract matrices and vectors.

As the javadocs for assign() says:

Assigns the result of a function to each cell; x[row,col] =function(x[row,col],y[row,col]).

So by using using an addition function as function - you can add matrices.

Tacita answered 30/5, 2012 at 11:44 Comment(0)
C
2

There is also la4j library that supports functional programming features as functors. You can use transform() method with manual hi-order function.

Conic answered 28/12, 2012 at 7:44 Comment(0)
G
1

You can use this one. It is very simple and supply basic matrix operations.

You can add/substract/multiply etc 2d matrixes and vectors.

Gurdwara answered 30/5, 2012 at 11:42 Comment(0)
E
0

You may try my newly Java library (compatible with Java 6+) that can be used for all sorts of applications notably for performing multi-threaded matrix calculations (extending JAMA with multi-threading; currently 30% faster than the available open source libraries). You can check it out on GitHub:

https://github.com/b-io/io.barras/tree/master/java/jupiter

Note that each project is independent from each other and is under the very permissive MIT License.

Etch answered 2/12, 2019 at 0:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.