Function iasym

Synopse

iasym - Check if a matrix is symmetric.

  • a = iasym(A)

    • a: Boolean. TRUE if matrix A is symmetric or FALSE otherwise.

    • A: Numpy array. Matrix that will be checked. Valor 'Inf'

      indica .

Description

Function checks if the input matrix A is symmetric. Works only for square matrices.

Function Code

1 #from numpy import *
2 
3 def iasym(A):
4     return (A.transpose() == A).all()

Examples

1 from iasym import iasym
2 
3 A = array( [ (0,    2, 3),
4              (2,    0,'Inf'),
5              (3,'Inf', 0) ], dtype=float )
6 
7 print A, 'is symmetric?', iasym(A)
[[  0.   2.   3.]
 [  2.   0.  Inf]
 [  3.  Inf   0.]] is symmetric? True

Equation

References

[Feof2009]Paulo Feofiloff. Algoritmos para Grafos em C via Sedgewick. IME-USP. http://www.ime.usp.br/~pf/algoritmos_para_grafos

See also

Contributions

  • Mariana P Bento, 1o semestre de 2012.