I would like to calculate an inverse of matrix in java. Are there any already existing packages which calculate inverse of matrix. I found similar question, but the answers in the questions are not so strongly recommending to use anyof the packages. Even i could not follow the method they are using. I have a large matrix of 10000s of rows and columns. I would like to calculate inverse of it.
Asked
Active
Viewed 1.5k times
4 Answers
2
I think you should give a shot to JAMA
The documentation presents an inverse function for matrices http://math.nist.gov/javanumerics/jama/doc/
Seeing the size of your matrix though, You WILL have to factorize it first .

jlengrand
- 12,152
- 14
- 57
- 87
-
I believe jama is discontinued, last release was on 2005-07-13 – JustDanyul May 21 '12 at 13:38
-
1Yep, saw it too. I didn't know about Apache lib. Thanks for letting us know – jlengrand May 21 '12 at 13:46
1
The la4j (Linear Algebra for Java) library supports matrix inversion. Here is the short example:
Matrix a = new Basic2DMatrix(new double[][]{
{ 1.0, 2.0, 3.0 },
{ 4.0, 5.0, 6.0 },
{ 7.0, 8.0. 9.0 }
});
Matrix b = a.invert(Matrices.DEFAULT_INVERTOR); // uses Gaussian Elimination

Vladimir Kostyukov
- 2,492
- 3
- 21
- 30
-1
there is a example in github used Linear Algebra for Java
Matrix a =
factory.createMatrix(new RandomMatrixSource(SIZE,SIZE));
MatrixInverter inverter = a.withInverter(LinearAlgebra.GAUSS_JORDAN);
Matrix e = inverter.inverse(factory);

xingfe123
- 79
- 3