[TOC]

ishermitian

Determine if a matrix is Hermitian or skew-Hermitian

Definitions

Hermitian Matrix

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

If is the element in Row and Column of , then for all and . That means, is the conjugate of .

Skew Hermitian Matrix

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

If is the element in Row and Column of , then for all and . That means, is the negation of the conjugate of .

Usage

ishermitian(A)

ishermitian(A, skew)

Examples

Input
A = [1 2 3;4 5 6;7 8 9];
B = A+A'
ishermitian(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) = -conj(A(2,1));
A(1,3) = -conj(A(3,1));
A(2,3) = -conj(A(3,2))
ishermitian(A,'skew')
Output
A = 
 0.0000 + 0.0000i  -4.0000 + 4.0000i  -7.0000 + 7.0000i
 4.0000 + 4.0000i   0.0000 + 0.0000i  -8.0000 + 8.0000i
 7.0000 + 7.0000i   8.0000 + 8.0000i   0.0000 + 0.0000i

ans = 
1