6

numpy.linalg.det is rasing some warning I dont understand. this does not happen every time, but it is raised with my example code below.

warning: "RuntimeWarning: invalid value encountered in det r = _umath_linalg.det(a, signature=signature)

matrix = np.array([[1, 1, 1], [3, 3, 3], [4, 4, 4]])
    a = np.linalg.det(matrix)
    print(a)

I have searched around, but didn't find a whole lot. This post talks about overflow problems from a large matrix, but I doubt that is the problem here.

Community
  • 1
  • 1
Jake
  • 101
  • 1
  • 5
  • 1
    I can't reproduce the behavior on my machine. Which version of numpy do you use ? Laybe related to this bug https://github.com/numpy/numpy/issues/8529 ? Also, try to call directly the function called inside numpy.linalg.det to see whether the warning still occurs : np.linalg._umath_linalg.det(matrix, signature='d->d') – Ben Mar 08 '17 at 11:20
  • Numpy version 1.12.0+mkl, python version 3.6.0. – Jake Mar 13 '17 at 11:54
  • I tried calling directly "np.linalg._umath_linalg.det(matrix, signature='d->d')", and I still got the warning. I checked out the link (github.com/numpy/numpy/issues/8529) and tested my code with a zero matrix and got the same error so it could be related. I don't understand what they mean by " the code should ignore fp exc raised by lapacks". Thank you for replying :-) – Jake Mar 13 '17 at 12:00
  • I have numpy 1.11.0 and no bug here. The issue linked before says it got introduced in numpy 1.11.3 ... Maybe try downgrading ? – Ben Mar 14 '17 at 13:05
  • As far as the exception goes, it is a floating point exception raised by the underlying library (Lapack, implemented in MKL). The exception is probably raised in the calculation of the determinant, due to an unexpected value in the computation (possibly linked with the fact that the output is 0 ?). It is passed along from MKL and output as a warning in numpy, and he is basically saying that it might either be a bug in MKL, or simply should be ignored by numpy. I'm can't tell if this is correct, though – Ben Mar 14 '17 at 13:10

0 Answers0