Permalink
Browse files

TST: fix arpack test failure. Closes #1503.

Using tol == machine precision is unneccessary and caused one test to fail.  An
extra factor of 2 makes the test pass.
  • Loading branch information...
rgommers committed Aug 28, 2011
1 parent 75f4256 commit fda88cf4a73eefd06e3b71933f733c63339ab073
Showing with 13 additions and 13 deletions.
  1. +13 −13 scipy/sparse/linalg/eigen/arpack/arpack.py
@@ -894,10 +894,10 @@ def __init__(self, M):
self.isreal = not np.issubdtype(self.dtype, np.complexfloating)
def _matvec(self, x):
- # careful here: splu.solve will throw away imaginary
+ # careful here: splu.solve will throw away imaginary
# part of x if M is real
if self.isreal and np.issubdtype(x.dtype, np.complexfloating):
- return (self.M_lu.solve(np.real(x))
+ return (self.M_lu.solve(np.real(x))
+ 1j * self.M_lu.solve(np.imag(x)))
else:
return self.M_lu.solve(x)
@@ -926,7 +926,7 @@ def __init__(self, M, ifunc=gmres, tol=0):
if tol <= 0:
# when tol=0, ARPACK uses machine tolerance as calculated
# by LAPACK's _LAMCH function. We should match this
- tol = np.finfo(M.dtype).eps
+ tol = 2 * np.finfo(M.dtype).eps
self.M = M
self.ifunc = ifunc
self.tol = tol
@@ -956,7 +956,7 @@ def __init__(self, A, M, sigma, ifunc=gmres, tol=0):
if tol <= 0:
# when tol=0, ARPACK uses machine tolerance as calculated
# by LAPACK's _LAMCH function. We should match this
- tol = np.finfo(A.dtype).eps
+ tol = 2 * np.finfo(A.dtype).eps
self.A = A
self.M = M
self.sigma = sigma
@@ -1116,7 +1116,7 @@ def eigs(A, k=6, M=None, sigma=None, which='LM', v0=None,
- 'LI' : largest imaginary part
- 'SI' : smallest imaginary part
When sigma != None, 'which' refers to the shifted eigenvalues w'[i]
- (see discussion in 'sigma', above). ARPACK is generally better
+ (see discussion in 'sigma', above). ARPACK is generally better
at finding large values than small values. If small eigenvalues are
desired, consider using shift-invert mode for better performance.
maxiter : integer
@@ -1311,7 +1311,7 @@ def eigsh(A, k=6, M=None, sigma=None, which='LM', v0=None,
solver if either A or M is a general linear operator.
Alternatively, the user can supply the matrix or operator OPinv,
which gives x = OPinv * b = [A - sigma * M]^-1 * b.
- Note that when sigma is specified, the keyword 'which' refers to
+ Note that when sigma is specified, the keyword 'which' refers to
the shifted eigenvalues w'[i] where:
- if mode == 'normal',
w'[i] = 1 / (w[i] - sigma)
@@ -1336,7 +1336,7 @@ def eigsh(A, k=6, M=None, sigma=None, which='LM', v0=None,
- 'BE' : Half (k/2) from each end of the spectrum
When k is odd, return one more (k/2+1) from the high end
When sigma != None, 'which' refers to the shifted eigenvalues w'[i]
- (see discussion in 'sigma', above). ARPACK is generally better
+ (see discussion in 'sigma', above). ARPACK is generally better
at finding large values than small values. If small eigenvalues are
desired, consider using shift-invert mode for better performance.
maxiter : integer
@@ -1352,11 +1352,11 @@ def eigsh(A, k=6, M=None, sigma=None, which='LM', v0=None,
Return eigenvectors (True) in addition to eigenvalues
mode : string ['normal' | 'buckling' | 'cayley']
Specify strategy to use for shift-invert mode. This argument applies
- only for real-valued A and sigma != None. For shift-invert mode,
- ARPACK internally solves the eigenvalue problem
- ``OP * x'[i] = w'[i] * B * x'[i]``
- and transforms the resulting Ritz vectors x'[i] and Ritz values w'[i]
- into the desired eigenvectors and eigenvalues of the problem
+ only for real-valued A and sigma != None. For shift-invert mode,
+ ARPACK internally solves the eigenvalue problem
+ ``OP * x'[i] = w'[i] * B * x'[i]``
+ and transforms the resulting Ritz vectors x'[i] and Ritz values w'[i]
+ into the desired eigenvectors and eigenvalues of the problem
``A * x[i] = w[i] * M * x[i]``.
The modes are as follows:
- 'normal' : OP = [A - sigma * M]^-1 * M
@@ -1369,7 +1369,7 @@ def eigsh(A, k=6, M=None, sigma=None, which='LM', v0=None,
B = M
w'[i] = (w[i] + sigma) / (w[i] - sigma)
The choice of mode will affect which eigenvalues are selected by
- the keyword 'which', and can also impact the stability of
+ the keyword 'which', and can also impact the stability of
convergence (see [2] for a discussion)
Raises

0 comments on commit fda88cf

Please sign in to comment.