% P2
% Checks out SpecialSchur
% Generate a random example...
clc
randn('seed',0)
n = 6;p = 3; X = randn(n,p); B = randn(p,p); B = B + B';

[Q,D] = SpecialSchur(X,B);

% Check that Q diagonalizes...
D1 = Q'*(eye(n,n) + X*B*X')*Q
% Compare computed eigenvalues with what schur produces...
[Q0,Dexact] = schur(eye(n,n)+X*B*X');
compareEigs = [diag(D) diag(Dexact)]
% Check orthonormality..
errQ = norm(Q'*Q-eye(n,n))