summaryrefslogtreecommitdiff
path: root/numpy/linalg/linalg.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/linalg/linalg.py')
-rw-r--r--numpy/linalg/linalg.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index 79ff68ff3..60a69b9c8 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -1919,6 +1919,7 @@ def lstsq(a, b, rcond=-1):
if is_1d:
b = b[:, newaxis]
_assertRank2(a, b)
+ _assertNoEmpty2d(a, b) # TODO: relax this constraint
m = a.shape[0]
n = a.shape[1]
n_rhs = b.shape[1]
@@ -1933,6 +1934,14 @@ def lstsq(a, b, rcond=-1):
a, bstar = _fastCopyAndTranspose(t, a, bstar)
a, bstar = _to_native_byte_order(a, bstar)
s = zeros((min(m, n),), real_t)
+ # This line:
+ # * is incorrect, according to the LAPACK documentation
+ # * raises a ValueError if min(m,n) == 0
+ # * should not be calculated here anyway, as LAPACK should calculate
+ # `liwork` for us. But that only works if our version of lapack does
+ # not have this bug:
+ # http://icl.cs.utk.edu/lapack-forum/archives/lapack/msg00899.html
+ # Lapack_lite does have that bug...
nlvl = max( 0, int( math.log( float(min(m, n))/2. ) ) + 1 )
iwork = zeros((3*min(m, n)*nlvl+11*min(m, n),), fortran_int)
if isComplexType(t):