def estimate_spectral_norm_diff(A, B, its=20):
 from scipy.sparse.linalg import aslinearoperator
 A = aslinearoperator(A)
 B = aslinearoperator(B)
 (m, n) = A.shape
 matvec1 = (lambda x: A.matvec(x))
 matveca1 = (lambda x: A.rmatvec(x))
 matvec2 = (lambda x: B.matvec(x))
 matveca2 = (lambda x: B.rmatvec(x))
 if _is_real(A):
  return backend.idd_diffsnorm(m, n, matveca1, matveca2, matvec1, matvec2, its=its)
 else:
  return backend.idz_diffsnorm(m, n, matveca1, matveca2, matvec1, matvec2, its=its)

def estimate_spectral_norm_diff ( A , B , its = 20 ) : from scipy . sparse . linalg import aslinearoperator A = aslinearoperator ( A ) B = aslinearoperator ( B ) ( m , n ) = A . shape matvec1 = ( lambda x : A . matvec ( x ) ) matveca1 = ( lambda x : A . rmatvec ( x ) ) matvec2 = ( lambda x : B . matvec ( x ) ) matveca2 = ( lambda x : B . rmatvec ( x ) ) if _is_real ( A ) : return backend . idd_diffsnorm ( m , n , matveca1 , matveca2 , matvec1 , matvec2 , its = its ) else : return backend . idz_diffsnorm ( m , n , matveca1 , matveca2 , matvec1 , matvec2 , its = its )
estimate spectral norm of the difference of two matrices by the randomized power method .