[Numpy-discussion] svd error checking vs. speed

alex argriffi at ncsu.edu
Thu Feb 20 13:24:36 EST 2014

On Mon, Feb 17, 2014 at 1:24 PM, Sturla Molden wrote:
> Sturla Molden wrote:
>> Dave Hirschfeld wrote:
>>> Even if lapack_lite always performed the isfinite check and threw a python
>>> error if False, it would be much better than either hanging or segfaulting and
>>> people who care about the isfinite cost probably would be linking to a fast
>>> lapack anyway.
>> +1 (if I have a vote)
>> Correctness is always more important than speed. Segfaulting or hanging
>> while burning the CPU is not something we should allow "by design". And
>> those who need speed should in any case use a different lapack library
>> instead. The easiest place to put a finiteness test is the check_object
>> function here:
>> https://github.com/numpy/numpy/blob/master/numpy/linalg/lapack_litemodule.c
>> But in that case we should probably use a macro guard to leave it out if
>> any other LAPACK than the builtin f2c version is used.
> It seems even the more recent (3.4.x) versions of LAPACK have places where
> NANs can cause infinite loops. As long as this is an issue it might perhaps
> be worth checking everywhere.
> http://www.netlib.org/lapack/bug_list.html
> The semi-official C interface LAPACKE implements NAN checking as well:
> http://www.netlib.org/lapack/lapacke.html#_nan_checking
> If Intel's engineers put NAN checking inside LAPACKE it probably were for a
> good reason.

As more evidence that checking isfinite could be important for
stability even for non-lapack-lite LAPACKs, MKL docs currently include
the following warning:

LAPACK routines assume that input matrices do not contain IEEE 754
special values such as INF
or NaN values. Using these special values may cause LAPACK to return
unexpected results or
become unstable.

More information about the NumPy-Discussion mailing list