Matrix operations in Java

Aleksandar picture Aleksandar · Feb 26, 2014 · Viewed 9.2k times · Source

I looked for this everywhere, but I am wrong somewhere. In my Java program, I created few 2D Arrays. Now, I need to form new 2D arrays with previous, like, inverse, transpose, multiplying , LEFT DIVISION and maybe even more. Some of them (simple) I created myself, but left division, right division, inverse I didn't.

By using libs like Jama, some problem appears.

java.lang.RuntimeException: Matrix is rank deficient.

And I code it like this:

Matrix Am=new Matrix(A);
Am=Am.inverse();

A is 2D Array (m x n), and Am is new matrix created from 2DArray A.

I tried to do this to get left division, but I cannot solve matrix inverse first.

Where is my mistake? Does someone know another library to convert from 2DArray to Matrix, and then do harder matrix operations (left div, inv...) with it?

EDIT

I use inverse on this matrix to get A\P (can be computed as inverse(A)*P as I saw somewhere). Do you know how to get A\P with Jama? This is my primary probleb, left division.

Answer

Asqan picture Asqan · Feb 26, 2014

For matrix libraries, you can check this question:

But for code you wrote, no one can say anything, you have to include the code itself to see where the problem is.