[TOC]

issymmetric

Determine if a matrix is symmetric or skew-symmetric

Definitions

Symmetric Matrix

A symmetric matrix is a square matrix (real or complex) that satisfies the following condition:

For all and , it holds that , where is the element in -th row and -th column of .

Skew Symmetric Matrix

A skew symmetric matrix is a square matrix (real or complex) satisfying the following condition:

For all and , it holds that , where is the element in -th row and -th column of .

This definition implies that all diagonal elements of are zero since for all .

Usage

issymmetric(A)

issymmetric(A, skew)

Examples

Input
A = [1 2 3;4 5 6;7 8 9];
B = A+A'
issymmetric(B)
Output
B =
2.000   6.000   10.00
6.000   10.00   14.00
10.00   14.00   18.00

ans =
1
Input
A = [1 2 3;4 5 6;7 8 9]+[1 2 3;4 5 6;7 8 9] * i;
A(1,1) = 0; A(2,2) = 0; A(3,3) = 0;
A(1,2) = -A(2,1);
A(1,3) = -A(3,1);
A(2,3) = -A(3,2)
issymmetric(A,'skew')
Output
A =
0.000 + 0.000i  -4.000 - 4.000i  -7.000 - 7.000i
4.000 + 4.000i   0.000 + 0.000i  -8.000 - 8.000i
7.000 + 7.000i   8.000 + 8.000i   0.000 + 0.000i

ans =
1