[Scipy-svn] r6854 - trunk/scipy/sparse/linalg/eigen/arpack

scipy-svn@scip... scipy-svn@scip...
Sat Oct 23 09:42:01 CDT 2010


Author: ptvirtan
Date: 2010-10-23 09:42:01 -0500 (Sat, 23 Oct 2010)
New Revision: 6854

Modified:
   trunk/scipy/sparse/linalg/eigen/arpack/arpack.py
Log:
BUG: sparse/arpack: fix off-by-two in check for ncv

Modified: trunk/scipy/sparse/linalg/eigen/arpack/arpack.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/arpack/arpack.py	2010-10-23 14:41:40 UTC (rev 6853)
+++ trunk/scipy/sparse/linalg/eigen/arpack/arpack.py	2010-10-23 14:42:01 UTC (rev 6854)
@@ -82,9 +82,6 @@
             ncv = 2 * k + 1
         ncv = min(ncv, n)
 
-        if ncv > n or ncv < k:
-            raise ValueError("ncv must be k<=ncv<=n, ncv=%s" % ncv)
-
         self.v = np.zeros((n, ncv), tp) # holds Ritz vectors
         self.iparam = np.zeros(11, "int")
 
@@ -119,6 +116,9 @@
         _ArpackParams.__init__(self, n, k, tp, matvec, sigma,
                  ncv, v0, maxiter, which, tol)
 
+        if self.ncv > n or self.ncv <= k:
+            raise ValueError("ncv must be k<ncv<=n, ncv=%s" % self.ncv)
+
         self.workd = np.zeros(3 * n, self.tp)
         self.workl = np.zeros(self.ncv * (self.ncv + 8), self.tp)
 
@@ -182,6 +182,9 @@
         _ArpackParams.__init__(self, n, k, tp, matvec, sigma,
                  ncv, v0, maxiter, which, tol)
 
+        if self.ncv > n or self.ncv <= k+1:
+            raise ValueError("ncv must be k+1<ncv<=n, ncv=%s" % self.ncv)
+
         self.workd = np.zeros(3 * n, self.tp)
         self.workl = np.zeros(3 * self.ncv * self.ncv + 6 * self.ncv, self.tp)
 



More information about the Scipy-svn mailing list