Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions scipy/linalg/flapack.pyf.src
Expand Up @@ -650,7 +650,7 @@ interface
<ftype> dimension(m,n),intent(in,out,copy,out=qr,aligned8) :: a <ftype> dimension(m,n),intent(in,out,copy,out=qr,aligned8) :: a
<ftype> dimension(MIN(m,n)),intent(out) :: tau <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 <ftype> dimension(MAX(lwork,1)),intent(out),depend(lwork) :: work
integer intent(out) :: info integer intent(out) :: info
end subroutine <prefix>gerqf end subroutine <prefix>gerqf
Expand Down Expand Up @@ -769,7 +769,7 @@ interface
<ftype2> dimension(m,n),intent(in,out,copy,out=q) :: a <ftype2> dimension(m,n),intent(in,out,copy,out=q) :: a
<ftype2> dimension(k),intent(in) :: tau <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 <ftype2> dimension(MAX(lwork,1)),intent(out),depend(lwork) :: work
integer intent(out) :: info integer intent(out) :: info
end subroutine <prefix2>orgrq end subroutine <prefix2>orgrq
Expand All @@ -791,7 +791,7 @@ interface
<ftype2c> dimension(m,n),intent(in,out,copy,out=q) :: a <ftype2c> dimension(m,n),intent(in,out,copy,out=q) :: a
<ftype2c> dimension(k),intent(in) :: tau <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 <ftype2c> dimension(MAX(lwork,1)),intent(out),depend(lwork) :: work
integer intent(out) :: info integer intent(out) :: info
end subroutine <prefix2c>ungrq end subroutine <prefix2c>ungrq
Expand Down
24 changes: 23 additions & 1 deletion scipy/linalg/tests/test_lapack.py
Expand Up @@ -4,13 +4,16 @@
# #


from numpy.testing import TestCase, run_module_suite, assert_equal, \ 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 import numpy as np


from scipy.linalg import flapack, clapack from scipy.linalg import flapack, clapack
from scipy.linalg.lapack import get_lapack_funcs 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): class TestFlapackSimple(TestCase):


Expand Down Expand Up @@ -81,6 +84,25 @@ def test_clapack(self):
#clapack module is empty #clapack module is empty
pass 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__": if __name__ == "__main__":
run_module_suite() run_module_suite()