1

I use EJML to solve a linear equation system.

EJML uses doubles. My inputs (and expected outputs) are integers. I will omit the .000 from the toString().

My Matrix A looks like this (though it is ~1000x1000):

1  0  0  0  0
1 -1  1  0  0
0  1 -1  1  0
0  0  1 -1  1
0  0  0  0  1

My b is just a vector with a value in the first and the last index, the rest is 0.

{-10 0 0 0 10}'

For size 5x5 I can use EJML just fine, but for my 1000x1000 Matrix I get a Solution contains uncountable numbers-Error.

The result looks like this:

{NaN NaN NaN ... NaN -Infinity -Infinity 1}'

My code looks like this (the matrices are correct, I checked that via Sysout and Debugger):

// Setup A
// Setup b
SimpleMatrix x = A.solve(b);

Now I assume my System somehow behaves badly. Sadly I'm not that much into matrices, so I assume I'm maybe using the wrong methods to solve this particular problem. The other thing I can think of is that double-precision gets in my way.

Is there anything I can do or is EJML simply not the right tool here?

JFBM
  • 944
  • 1
  • 11
  • 24
  • I've never used the tool but the *`NaN`* & *`Infinity`* come from *`1/0`* * *`0/0`*, this happens in the case of *zero determinant* , `D=0` , because the inverse of `A` is `A^-1 = 1/D x A` , the D is zero happened before jumping into `X = A^-1 B` process. – Plain_Dude_Sleeping_Alone Dec 22 '16 at 23:23
  • Try looking at the singular values for the matrix. I'm willing to bet there are some zeros in there. That means that it's a singular matrix. It lacks a unique solution. There are an infinite number of solutions actually. If that isn't a problem you can use SVD to select one of those many solutions. – lessthanoptimal Jan 09 '17 at 05:07

0 Answers0