I am using the following function to block diagonalize antisymmetric matrices.
function [R, RI , S ] = Matrix_block (A)
[U,D]= schur (A);
E=ordeig(double(D)) ;
[R, S]= ordschur (U,D, abs(E)<1000*eps ) ;
RI=R';
The code works perfectly fine for real antisymmetric matrices but fails for complex antisymmetric matrices as follows :-
a = rand(6); a = a-a'; [r,ri,s] = Matrix_block(a);
b = rand(6)+1i*rand(6); b= b-conj(b)'; [r,ri,s] = Matrix_block(b);
How can I correct my code for it to work also for complex matrices ? I want a block-diagonal matrix (of the following form) as the output for both real and complex matrices.
0 e1 -0.0000 -0.0000 0.0000 -0.0000
-e1 0 0.0000 0.0000 -0.0000 0.0000
0 0 -0.0000 e2 0.0000 -0.0000
0 0 -e2 -0.0000 0.0000 -0.0000
0 0 0 0 -0.0000 e3
0 0 0 0 -e3 -0.0000