% C4
clc
randn('seed',0)

fprintf('Example 1.\n')
n = 6;
A = randn(n,n); A = A + A'; A = A + A(n:-1:1,n:-1:1);
[Q,D] = CentroSymSchur(A)
fprintf('norm(Q''*Q - I) = %10.3e\n',norm(Q'*Q - eye(n,n)))
fprintf('norm(A*Q - Q*D) = %10.3e\n',norm(A*Q - Q*D))

fprintf('\n\nExample 2.\n')
n = 7;
A = randn(n,n); A = A + A'; A = A + A(n:-1:1,n:-1:1);
[Q,D] = CentroSymSchur(A)
fprintf('norm(Q''*Q - I) = %10.3e\n',norm(Q'*Q - eye(n,n)))
fprintf('norm(A*Q - Q*D) = %10.3e\n',norm(A*Q - Q*D))

fprintf('\n\nExample 3.\n\n')
n = 600;
A = randn(n,n); A = A + A'; A = A + A(n:-1:1,n:-1:1);
[Q,D] = CentroSymSchur(A);
fprintf('norm(Q''*Q - I) = %10.3e\n',norm(Q'*Q - eye(n,n)))
fprintf('norm(A*Q - Q*D) = %10.3e\n',norm(A*Q - Q*D))

fprintf('\n\nExample 4.\n\n')
n = 701;
A = randn(n,n); A = A + A'; A = A + A(n:-1:1,n:-1:1);
[Q,D] = CentroSymSchur(A);
fprintf('norm(Q''*Q - I) = %10.3e\n',norm(Q'*Q - eye(n,n)))
fprintf('norm(A*Q - Q*D) = %10.3e\n',norm(A*Q - Q*D))