[Numpy-discussion] SVD does not converge on "clean" matrix

Nadav Horesh nadavh@visionsense....
Fri Aug 12 12:23:53 CDT 2011

I tested all the the result 3 matrices with alltrue(infinite(mat)) and got True answer for all of them.


From: numpy-discussion-bounces@scipy.org [numpy-discussion-bounces@scipy.org] On Behalf Of Warren Weckesser [warren.weckesser@enthought.com]
Sent: 12 August 2011 16:33
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] SVD does not converge on "clean" matrix

On Fri, Aug 12, 2011 at 4:03 AM, Charanpal Dhanjal <dhanjal@telecom-paristech.fr<mailto:dhanjal@telecom-paristech.fr>> wrote:
Thank Nadav for testing out the matrix. I wonder if you had a chance to
check if the resulting decomposition contained NaN or Inf values?

As far I understood, numpy.linalg.svd uses routines in LAPACK and ATLAS
(if available) to compute the corresponding SVD. I did some
complementary tests on Debian Squeeze on an Intel Xeon W3550 CPU and the
call to numpy.linalg.svd results in the LinAlgError "SVD did not
converge", however the test leading to results containing NaN values ran
on Debian Lenny on an Intel Core 2 Quad. In both of these situations we
use Python 2.7.1 and numpy 1.5.1 (without ATLAS), and so the reasons for
the differences seem to be OS or processor dependent. Any ideas?


Date: Thu, 11 Aug 2011 07:21:09 -0700
 From: Nadav Horesh <nadavh@visionsense.com<mailto:nadavh@visionsense.com>>
Subject: Re: [Numpy-discussion] SVD does not converge on "clean"
To: Discussion of Numerical Python <numpy-discussion@scipy.org<mailto:numpy-discussion@scipy.org>>

Content-Type: text/plain; charset="us-ascii"

> Had no problem on a gentoo 64 bit machine using atlas 3.8.0 (Core I7,
> python 2.7.2, numpy versions1.60 and 1.6.1)

Another data point: on Mac OS X, with Python 2.7.2 and numpy 1.6.0 (using EPD 7.1), I get the error:

$ ipython --pylab
Enthought Python Distribution -- www.enthought.com<http://www.enthought.com>

Python 2.7.2 |EPD 7.1-1 (32-bit)| (default, Jul  3 2011, 15:40:35)
Type "copyright", "credits" or "license" for more information.

IPython 0.11.rc1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

Welcome to pylab, a matplotlib-based Python environment [backend: WXAgg].
For more information, type 'help(pylab)'.

In [1]: numpy.__version__
Out[1]: '1.6.0'

In [2]: arr = load('matrix_leading_to_bad_SVD.npz')['arr_0']

In [3]: np.linalg.svd(arr)
LinAlgError                               Traceback (most recent call last)
/Users/warren/tmp/<ipython-input-3-e475bd6de739> in <module>()
----> 1 np.linalg.svd(arr)

/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/numpy/linalg/linalg.py in svd(a, full_matrices, compute_uv)
   1319                                  work, lwork, iwork, 0)
   1320     if results['info'] > 0:
-> 1321         raise LinAlgError, 'SVD did not converge'
   1322     s = s.astype(_realType(result_t))
   1323     if compute_uv:

LinAlgError: SVD did not converge


>  Nadav

>On Thu, 11 Aug 2011 15:23:22 +0200, dhanjal@telecom-paristech.fr<mailto:dhanjal@telecom-paristech.fr>
> wrote:
>> Hi all,
>> I get an error message "numpy.linalg.linalg.LinAlgError: SVD did not
>> converge" when calling numpy.linalg.svd on a "clean" matrix of size
>> (1952,
>> 895). The matrix is clean in the sense that it contains no NaN or
>> Inf
>> values. The corresponding npz file is available here:
>> https://docs.google.com/leaf?id=0Bw0NXKxxc40jMWEyNTljMWUtMzBmNS00NGZmLThhZWUtY2I2MWU2MGZiNDgx&hl=fr
>> Here is some information about my setup: I use Python 2.7.1 on
>> Ubuntu
>> 11.04 with numpy 1.6.1. Furthermore, I thought the problem might be
>> solved
>> by recompiling numpy with my local ATLAS library (version 3.8.3),
>> and this
>> didn't seem to help. On another machine with Python 2.7.1 and numpy
>> 1.5.1
>> the SVD does converge however it contains 1 NaN singular value and 3
>> negative singular values of the order -10^-1 (singular values should
>> always be non-negative).
>> I also tried computing the SVD of the matrix using Octave 3.2.4 and
>> Matlab
>> (R2010a) 64-bit (glnxa64) and there were no problems. Any
>> help
>> is greatly appreciated.
>> Thanks in advance,
>> Charanpal

NumPy-Discussion mailing list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110812/f655b4b5/attachment.html 

More information about the NumPy-Discussion mailing list