[SciPy-user] Type handling of matrices

Nils Wagner nwagner at mecha.uni-stuttgart.de
Thu Nov 11 03:06:09 EST 2004


Gary Ruben wrote:

>Hi Nils,
>How about transposing and subtracting it?
>
>  
>
That's the definition of a real symmetric matrix 

A = transpose(A)

In case of complex matrices we have

A = conj(transpose(A))

I am looking for a built-in function

A.issym

which returns
1 if  A is hermitian
0 if A is non-hermitian

How about similar functions for

A.issingular (singular from a numerical point of view)
A.isspd (symmetric positive definite) This might be useful with respect 
to iterative solvers. AFAIK linalg.cg is restricted to spd matrices.
A.isindefinite

Any comments or suggestions ?

Nils
  

>>>>a=array([[1,2,3],[2,1,4],[3,4,1]])
>>>>a
>>>>        
>>>>
>array([[1, 2, 3],
>       [2, 1, 4],
>       [3, 4, 1]])
>  
>
>>>>b=transpose(a)
>>>>b
>>>>        
>>>>
>array([[1, 2, 3],
>       [2, 1, 4],
>       [3, 4, 1]])
>  
>
>>>>a-b
>>>>        
>>>>
>array([[0, 0, 0],
>       [0, 0, 0],
>       [0, 0, 0]])
>
>
>Alternatively, maybe you could sum along each axis of your matrix and compare the results?
>eg.
>
>  
>
>>>>c=sum(a)
>>>>d=sum(a,1)
>>>>c
>>>>        
>>>>
>array([6, 7, 8])
>  
>
>>>>d
>>>>        
>>>>
>array([6, 7, 8])
>  
>
>>>>c-d
>>>>        
>>>>
>array([0, 0, 0])
>
>I'm not sure whether there might be cases where this could falsely identify a matrix as symmetric - you'll have to have a think about this.
>Gary R.
>
>----- Original Message -----
>  
>
>>Hi all,
>>
>>Is it currently possible (by a built-in function)  to verify whether a 
>>matrix
>>is symmetric or not.  I am  also interested in a
>>built-in function for verifying the definiteness of a matrix ?
>>
>>Any suggestion or comment ?
>>
>>Nils
>>    
>>
>
>  
>


 





More information about the SciPy-User mailing list