Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Incorrect lwork assertion in f2py wrapper for LAPACK xGERQF #222

Merged
merged 1 commit into from May 20, 2012
Jump to file or symbol
Failed to load files and symbols.
+26 −4
Split
@@ -650,7 +650,7 @@ interface
<ftype> dimension(m,n),intent(in,out,copy,out=qr,aligned8) :: a
<ftype> dimension(MIN(m,n)),intent(out) :: tau
- integer optional,intent(in),depend(n),check(lwork>=n||lwork==-1) :: lwork=3*n
+ integer optional,intent(in),depend(n),check(lwork>=m||lwork==-1) :: lwork=3*m
<ftype> dimension(MAX(lwork,1)),intent(out),depend(lwork) :: work
integer intent(out) :: info
end subroutine <prefix>gerqf
@@ -769,7 +769,7 @@ interface
<ftype2> dimension(m,n),intent(in,out,copy,out=q) :: a
<ftype2> dimension(k),intent(in) :: tau
- integer optional,intent(in),depend(n),check(lwork>=n||lwork==-1) :: lwork=3*n
+ integer optional,intent(in),depend(n),check(lwork>=m||lwork==-1) :: lwork=3*m
<ftype2> dimension(MAX(lwork,1)),intent(out),depend(lwork) :: work
integer intent(out) :: info
end subroutine <prefix2>orgrq
@@ -791,7 +791,7 @@ interface
<ftype2c> dimension(m,n),intent(in,out,copy,out=q) :: a
<ftype2c> dimension(k),intent(in) :: tau
- integer optional,intent(in),depend(n),check(lwork>=n||lwork==-1) :: lwork=3*n
+ integer optional,intent(in),depend(n),check(lwork>=m||lwork==-1) :: lwork=3*m
<ftype2c> dimension(MAX(lwork,1)),intent(out),depend(lwork) :: work
integer intent(out) :: info
end subroutine <prefix2c>ungrq
@@ -4,13 +4,16 @@
#
from numpy.testing import TestCase, run_module_suite, assert_equal, \
- assert_array_almost_equal, assert_
+ assert_array_almost_equal, assert_, assert_raises
import numpy as np
from scipy.linalg import flapack, clapack
from scipy.linalg.lapack import get_lapack_funcs
+REAL_DTYPES = [np.float32, np.float64]
+COMPLEX_DTYPES = [np.complex64, np.complex128]
+DTYPES = REAL_DTYPES + COMPLEX_DTYPES
class TestFlapackSimple(TestCase):
@@ -81,6 +84,25 @@ def test_clapack(self):
#clapack module is empty
pass
+class TestRegression(TestCase):
+
+ def test_ticket_1645(self):
+ # Check that RQ routines have correct lwork
+ for dtype in DTYPES:
+ a = np.zeros((300, 2), dtype=dtype)
+
+ gerqf, = get_lapack_funcs(['gerqf'], [a])
+ assert_raises(Exception, gerqf, a, lwork=2)
+ rq, tau, work, info = gerqf(a)
+
+ if dtype in REAL_DTYPES:
+ orgrq, = get_lapack_funcs(['orgrq'], [a])
+ assert_raises(Exception, orgrq, rq[-2:], tau, lwork=1)
+ orgrq(rq[-2:], tau, lwork=2)
+ elif dtype in COMPLEX_DTYPES:
+ ungrq, = get_lapack_funcs(['ungrq'], [a])
+ assert_raises(Exception, ungrq, rq[-2:], tau, lwork=1)
+ ungrq(rq[-2:], tau, lwork=2)
if __name__ == "__main__":
run_module_suite()