[Numpy-discussion] svd error checking vs. speed

alex argriffi at ncsu.edu
Sat Feb 15 17:46:54 EST 2014

On Sat, Feb 15, 2014 at 5:08 PM,  <josef.pktd at gmail.com> wrote:
> On Sat, Feb 15, 2014 at 4:56 PM, Sebastian Berg
> <sebastian at sipsolutions.net> wrote:
>> On Sa, 2014-02-15 at 16:37 -0500, alex wrote:
>>> Hello list,
>>> Here's another idea resurrection from numpy github comments that I've
>>> been advised could be posted here for re-discussion.
>>> The proposal would be to make np.linalg.svd more like scipy.linalg.svd
>>> with respect to input checking.  The argument against the change is
>>> raw speed; if you know that you will never feed non-finite input to
>>> svd, then np.linalg.svd is a bit faster than scipy.linalg.svd.  An
>>> argument for the change could be to avoid issues reported on github
>>> like crashes, hangs, spurious non-convergence exceptions, etc. from
>>> the undefined behavior of svd of non-finite input.
>> +1, unless this is a huge speed penalty, correctness (and decent error
>> messages) should come first in my opinion, this is python after all. If
>> this is a noticable speed difference, a kwarg may be an option (but
>> would think about that some more).
> maybe -1
> statsmodels is using np.linalg.pinv which uses svd
> I never ran heard of any crash (*), and the only time I compared with
> scipy I didn't like the slowdown.

Although numpy.linalg.pinv uses svd, scipy.linalg.pinv uses least
squares with an rhs identity matrix.  The scipy.linalg function that
uses svd for pseudoinverse is pinv2.  These connect to different
LAPACK functions.  Also I noticed that these scipy functions all have
redundant finiteness checking which I've fixed in a PR.


More information about the NumPy-Discussion mailing list