function FactorizationReview()

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% QR factorization
 
A = randn(8,5); b = randn(8,1); c = randn(5,1);
[Q,R] = qr(A,0);
% xLS =         % minimizes ||Ax - b|| assuming rank(A) = 5;
% v =           % a vector that is orthogonal to A(:,j),j=1:4
[Q,R] = qr(A);
% Z =           % the columns of this matrix span the null space of A'
% w =           % Solves A'w = c

[Q,R,P] = qr(A);
% xB = approximately minimizes ||Ax - b|| assuming that A is close to having rank
% 3 and xB has three nonzero components.
btilde = Q(:,1:3)'*b; z = R(1:3,1:3)\btilde; xB = P*[z;zeros(2,1)];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SVD
A = randn(8,4); A = [A A*randn(4,1)]; b = randn(8,1);  c = randn(5,1);
[U,S,V] = svd(A,0);
% xLS =         % minimizes ||Ax - b|| assuming rank(A) = 4;
[U,S,V] = svd(A);
% Z =           % the columns of this matrix span the null space of A'
% w =           % Solves A'w = c
% Q =           % A matrix of eigenvectors for A'*A
% Z =           % A matrix of eigenvectors for A*A'

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Schur decomposition
A = randn(5,5); A = A'*A;  b = randn(5,1);
[Q,D] = eig(A);
%  f =        % The vector of eigenvalues for Q(:,1:2)'*A*Q(:,1:2)
%  x =        % the dominant eigenvector of inv(A)
%  x =        % the dominant eigenvector of inv(A-7I)
%  x =        % Solves (A+ 5I)(A+2I)x = b
%  d =        % the vector of eigenvalues for A^10


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\
% Tridiagonalization
A = randn(500,500); A = A'*A; b = randn(500,1);
[U,T] = hess(A);
% x =    % Solves (A+5I)x = b
% v =    % The vector A*U(:,500) 



