[SciPy-dev] Type handling of matrices
Norbert Nemec
Norbert.Nemec.list at gmx.de
Wed Nov 17 03:33:12 CST 2004
On Wednesday 17 November 2004 10:08, Nils Wagner wrote:
> 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
Why the special case for real matrices? The hermitian adjoint of a real matrix
is identical to its transposed.
> 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:
> min=min1
> return min/2
def gap(A):
w = sort(real(linalg.eigwals(A)))
return min(w[1:]-w[:-1])/2
Don't know about efficiency of the sort, but at least you avoid the loop in
python.
--
_________________________________________Norbert Nemec
Bernhardstr. 2 ... D-93053 Regensburg
Tel: 0941 - 2009638 ... Mobil: 0179 - 7475199
eMail: <Norbert at Nemec-online.de>
More information about the Scipy-dev
mailing list