% In this file we will simply test the software UniEquiNorm, 
% just by applying it to few matrices.

n=10;
I=sqrt(-1);

A=GenNormal(n);

disp('1. Arbitrary matrix ---------------')
[U,T,V,D]=UniEquiNorm(A);
disp('   Check equality: norm of U^* A V - T')
norm(U'*A*V-T)
disp('   Check self-adjointness')
norm(inv(D)*T.'*D-T)
pause
clc


disp('2. Specific T matrix:sym ---------------')
[U,T,V,D]=UniEquiNorm(A,'sym');
disp('   Check equality: norm of U^* A V - T')
norm(U'*A*V-T)
disp('   Check self-adjointness')
norm(inv(D)*T.'*D-T)
%disp('   Show D')
%D
disp('Compare super and subdiagonal elements')
disp('D is shown in the last column')
disp('Symmetric --> they should be equal')
[diag(T,1),diag(T,-1),diag(D(2:n,2:n))]
pause
clc


disp('3. Specific T matrix:free ---------------')
[U,T,V,D]=UniEquiNorm(A,'free');
disp('   Check equality: norm of U^* A V - T')
norm(U'*A*V-T)
disp('   Check self-adjointness')
norm(inv(D)*T.'*D-T)
disp('   Show D: arbitrary unitary diagonal')
D
pause
clc

disp('4. Specific T matrix: pseusym ---------------')
d=ones(1,n);
d(1:3:n)=-1;
D=diag(d);
[U,T,V,D]=UniEquiNorm(A,'pseusym',D);
disp('   Check equality: norm of U^* A V - T')
norm(U'*A*V-T)
disp('   Check self-adjointness')
norm(inv(D)*T.'*D-T)
%disp('   Show D')
%D
disp('Compare super and subdiagonal elements')
disp('D is shown in the last column')
disp('Pseudo-sym, hence only signs should differ')
[diag(T,1),diag(T,-1),diag(D(2:n,2:n))]
pause
clc

disp('5. Specific T matrix: skewsym ---------------')
[U,T,V,D]=UniEquiNorm(A,'skewsym');
disp('   Check equality: norm of U^* A V - T')
norm(U'*A*V-T)
disp('   Check self-adjointness')
norm(inv(D)*T.'*D-T)
disp('Compare super and subdiagonal elements')
disp('D is shown in the last column')
disp('Skew-sym, hence opposite signs')
[diag(T,1),diag(T,-1),diag(D(2:n,2:n))]
pause
clc


disp('6. Specific T matrix: conj ---------------')
[U,T,V,D]=UniEquiNorm(A,'herm');
disp('   Check equality: norm of U^* A V - T')
norm(U'*A*V-T)
disp('   Check self-adjointness')
norm(inv(D)*T.'*D-T)
disp('Compare super and subdiagonal elements')
disp('D is shown in the last column')
disp('Conjugate, hence complex conjugates')
[diag(T,1),diag(T,-1),diag(D(2:n,2:n))]
pause
clc


disp('7. Specific T matrix: skewherm ---------------')
[U,T,V,D]=UniEquiNorm(A,'skewherm');
disp('   Check equality: norm of U^* A V - T')
norm(U'*A*V-T)
disp('   Check self-adjointness')
norm(inv(D)*T.'*D-T)
disp('Compare super and subdiagonal elements')
disp('D is shown in the last column')
disp('Skew Conjugate, hence minus complex conjugates')
[diag(T,1),diag(T,-1),diag(D(2:n,2:n))]
pause
clc



disp('7. Specific T matrix: herm ---------------')
[U,T,V,D]=UniEquiNorm(A,'herm');
disp('   Check equality: norm of U^* A V - T')
norm(U'*A*V-T)
disp('   Check self-adjointness')
norm(inv(D)*T.'*D-T)
disp('Compare super and subdiagonal elements')
disp('D is shown in the last column')
disp('Conjugate, hence complex conjugates')
[diag(T,1),diag(T,-1),diag(D(2:n,2:n))]


%disp('   Show D')
%D
pause
clc
