thanks a lot for your hints.
I have kept your code and changed it a bit, however when I run it, there is a logical error in it
as I always get 1, no matter how the matrix looks.
I have kept your code and changed it a bit, however when I run it, there is a logical error in it
as I always get 1, no matter how the matrix looks.
import numpy as np def is_symmetric(A): return np.array(A) == np.array(A).T def is_skew(A): return np.array(A) == -np.array(A).T def test_matrix(A): if is_symmetric(np.any(A)): return 1 if is_skew(np.any(A)): return -1 else: return 0 if __name__ == '__main__': a, b, c, d, e, f, g, h, i = 1,2,3,4,5,6,7,8,9 A = [[a, b, c], [d, e, f], [g, h, i]] print("Testing matrix A: ", test_matrix(A))
import numpy as np def is_symmetric(A): return np.array(A) == np.array(A).T def is_skew(A): return np.array(A) == -np.array(A).T def test_matrix(A): if is_symmetric(np.any(A)): return 1 if is_skew(np.any(A)): return -1 else: return 0 if __name__ == '__main__': a, b, c, d, e, f, g, h, i = 1,2,3,4,5,6,7,8,9 A = [[a, b, c], [d, e, f], [g, h, i]] print("Testing matrix A: ", test_matrix(A))