sloisel / numeric

Numerical analysis in Javascript
http://www.numericjs.com/
Other
1.42k stars 176 forks source link

Singular case not handled #85

Open kriffe opened 5 years ago

kriffe commented 5 years ago

For some inputs to eig solver the QR francis results in an error. See failing example below

const matrix = [
      [0, 0, 1, 0],
      [0, 0, 0, 1],
      [-1.0000000000000002, -0, -0, -0],
      [-0, -1.0000000000000002, -0, -0],
    ]
const result = numeric.eig(matrix)

Results in internal error: eig: internal error thrown at https://github.com/sloisel/numeric/blob/master/src/numeric.js#L1361

Solvability in wolframalpha: https://www.wolframalpha.com/input/?i=eigenvalue++%5B+%5B0,+0,+1,+0%5D,+%5B0,+0,+0,+1%5D,+%5B-1.0000000000000002,+-0,+-0,+-0%5D,+%5B-0,+-1.0000000000000002,+-0,+-0%5D%5D