[SciPy-dev] Type handling of matrices

Nils Wagner nwagner at mecha.uni-stuttgart.de
Wed Nov 17 03:08:57 CST 2004

Hi all,

It would be nice to have another "property check"

complex matrices

A.isnormal is true if A^H A - A A^H = 0, that is A commutes with its 
Hermitian adjoint

real matrices

A.isnormal is true if A^T A - A A^T = 0

BTW, how can I compute the gap function of A in scipy, where A is a 
dense normal matrix
and gap(A) is defined as follows

gap(A) = \min\limits_{i \ne j} | \lambda_i-\lambda_j | / 2

This approach seems to be not very efficient

def gap(A):
 w = linalg.eigvals(A) # Compute the spectrum of A
 min = 1.e10 # Initialize
 for i in len(w):
  for j in len(w):
        if i <> j:
              min1 = abs(w[i]-w[j])
              if min1 < min:
 return min/2


More information about the Scipy-dev mailing list