class_docstr: IterInv:
     helper class to repeatedly solve M*x=b
     using an iterative method.
class_docstr_tok: ["IterInv",":","helper","class","to","repeatedly","solve","M","*","x=b","using","an","iterative","method","."]
code: 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 = 2 * np.finfo(M.dtype).eps
      self.M = M
      self.ifunc = ifunc
      self.tol = tol
      if hasattr(M, "dtype"):
          self.dtype = M.dtype
      else:
          x = np.zeros(M.shape[1])
          self.dtype = (M * x).dtype
      self.shape = M.shape
  
imports: from scipy.sparse.linalg.eigen.arpack import _arpack
  import numpy
  from scipy.sparse.linalg.interface import aslinearoperator, LinearOperator
  from scipy.sparse import identity, isspmatrix, isspmatrix_csr
  from scipy.linalg import lu_factor, lu_solve
  from scipy.sparse.sputils import isdense
  from scipy.sparse.linalg import gmres, splu
  import scipy
  import functools
  import operator
  from distutils.version import LooseVersion
label_desc: Use image node_id 1 to create a new IterInv object from inherited base classes: LinearOperator with example: obj = IterInv(M, ifunc, tol)