Exception in thread "main" java.lang.RuntimeException: Matrix is ​​singular

I'm just trying to create an inverse 3x3 matrix matrix after the JAMA documentation. But every time he gives me the following error -

Exception in thread "main" java.lang.RuntimeException: Matrix is singular

Can anyone help me in this regard?

+2
source share
3 answers

If you can calculate the determinant of your matrix, you will find that it is equal to zero (or close to it).

Perhaps you can tell by checking. If one row is proportional to another, your matrix is ​​not invertible.

3x3 is easy enough to invert manually. Try it and see where this happens.

Try the SVD solution. He will tell you what is the empty space for your matrix.

+1
source

Jama .

, , , Matrix.inverse() LUDecomposition.solve(...), :

  270      /** Solve A*X = B
  271      @param  B   A Matrix with as many rows as A and any number of columns.
  272      @return     X so that L*U*X = B(piv,:)
  273      @exception  IllegalArgumentException Matrix row dimensions must agree.
  274      @exception  RuntimeException  Matrix is singular.
  275      */
  277      public Matrix solve (Matrix B) {
  278         if (B.getRowDimension() != m) {
  279            throw new IllegalArgumentException("Matrix row dimensions must agree.");
  280         }
  281         if (!this.isNonsingular()) {
  282            throw new RuntimeException("Matrix is singular.");
  283         }

:

" n--n () A , n--n B , AB = BA = n > n n--1 , - ."

, .


JAMA, Apache Commons Maths, .

+2

, , : , , .

.

If you think that your matrix is ​​not the only one, send it and we will see.

+1
source

All Articles