%Hessenberg: Transform a square matrix B into Hessenberg form using
% Householder reflections. 
%
% Usage:
%   >> H = Hessenberg(B);
%
function [B]=Hessenberg(B);
  
  [N,M]=size(B);
  
  for k=1:N-1
    %
    % Select a Householder reflection such that H*B(k+1:N,1)=alpha*e1. 
    % This Householder reflection needs to be applied from the left
    % and from the right to the appropriate part of the matrix B.
    %
    %
    % Note: Even though the ApplyReflection subrouting is written to
    % apply the reflection from the left its possible to use the same
    % subroutine to apply the reflection from the right. How?
    %
    
  end;
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% LOCAL SUBROUTINES 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
%ApplyReflection: Compute the product H*A where H is a 
% Householder reflection matrix such that H*x=norm(x)*e1.
%
function [A]=ApplyReflection(A,x);
  
% 
% Find the vector v so that H(v)*x=alpha*e1. 
%
  v=x;v(1)=v(1)+sign(x(1))*norm(x);
    
%
% Apply the reflection H to all the columns A(:,k) one at a time.
%
 [m,n]=size(A);
 for i=1:n
    A(:,i)=A(:,i)-2*v'*A(:,i)*v/(v'*v);               
 end


