Permalink
Browse files

BUG: linalg: fix invalid rwork size in svd (#1580)

  • Loading branch information...
1 parent 6907a2b commit d064c357c8b90b45c594b133bb0e6c25d65229c7 @pv pv committed Feb 5, 2012
Showing with 10 additions and 1 deletion.
  1. +1 −1 scipy/linalg/flapack.pyf.src
  2. +9 −0 scipy/linalg/tests/test_decomp.py
@@ -427,7 +427,7 @@ interface
<ftype2c> dimension(u0,u1),intent(out),depend(u0,u1) :: u
<ftype2c> dimension(vt0,vt1),intent(out),depend(vt0,vt1) :: vt
<ftype2c> dimension(lwork),intent(hide,cache),depend(lwork) :: work
- <ftype2> dimension((compute_uv?5*minmn*minmn+7*minmn:5*minmn)),intent(hide,cache),depend(minmn,compute_uv) :: rwork
+ <ftype2> dimension((compute_uv?minmn*MAX(5*minmn+7, 2*MAX(m,n)+2*minmn+1):5*minmn)),intent(hide,cache),depend(minmn,compute_uv) :: rwork
integer optional,intent(in),depend(minmn,compute_uv) &
:: lwork = (compute_uv?2*minmn*minmn+MAX(m,n)+2*minmn:2*minmn+MAX(m,n))
check(lwork>=(compute_uv?2*minmn*minmn+MAX(m,n)+2*minmn:2*minmn+MAX(m,n))) :: lwork
@@ -808,6 +808,15 @@ def test_random_complex(self):
for i in range(len(s)): sigma[i,i] = s[i]
assert_array_almost_equal(dot(dot(u,sigma),vh),a)
+ def test_crash_1580(self):
+ sizes = [(13, 23), (30, 50), (60, 100)]
+ np.random.seed(1234)
+ for sz in sizes:
+ for dt in [np.float32, np.float64, np.complex64, np.complex128]:
+ a = np.random.rand(*sz).astype(dt)
+ # should not crash
+ svd(a)
+
class TestSVDVals(TestCase):
def test_simple(self):

0 comments on commit d064c35

Please sign in to comment.