function [Q,H] = SpecialHess(A,v)
% v is a column n-vector with unit 2norm
% Q is orthogonal with the property that Q(:,1) = v and
% Q'*A*Q = H is upper Hessenberg.

[w,alpha] = House(v);
%(I - 2ww')v = alpha*e1 with alpha = + or -1.
% Thus, (I-2ww')e1 = alpha*v

% A = (I -2ww')A(I - 2ww') = A -2ww'A - 2Aww' + 4(w'Aw)ww'
% = A - wp' - qw' + (2w'q)ww' where p = 2A'w and q = 2Aw
% = A - w(p - z)' - (q - z)w' where z = (w'q)w

p = 2*(A'*w);
q = 2*(A*w);
z = (w'*q)*w;
A = A - w*(p-z)' - (q-z)*w';
[Q1,H] = hess(A);
% Note that Q1'*Q0'*A*Q0)Q1 = H
% If we set Q = Q0*Q1 then Q'*A*Q = H
Q = Q1 - (2*w)*(w'*Q1);
% Since Q1(:,1) = e1.
% Q*e1 = Q0*Q1*e1 = Q0*e1 = alpha*v.
% To ensure that Q*e1 = v and not -v,...
Q = alpha*Q;