Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Incorrect lwork assertion in f2py wrapper for LAPACK xGERQF #222

Merged
merged 1 commit into from

2 participants

@pv
Owner
pv commented

From ticket http://projects.scipy.org/scipy/ticket/1645

Seems straightforward to me, re-verified the sizes from the lapack manpages.

@rgommers rgommers merged commit 63bb175 into from
@jnothman jnothman referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 20, 2012
  1. @pv

    BUG: linalg/flapackf: fix lwork size in gerqf/orgrq/ungrq

    pv authored
    Thanks to Mike Wimmer for the patch.
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 4 deletions.
  1. +3 −3 scipy/linalg/flapack.pyf.src
  2. +23 −1 scipy/linalg/tests/test_lapack.py
View
6 scipy/linalg/flapack.pyf.src
@@ -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
View
24 scipy/linalg/tests/test_lapack.py
@@ -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()
Something went wrong with that request. Please try again.