Suppose that A = QR is a full QR factorization of A; that is, Q is (m x m) and R is
(m x n). Then, we can write Aj = QRj , where Rj is the matrix obtained by eliminating
the jth column from R (as above). Using this fact and the particular structure of zeros
of Rj , write the function:
function [Qnew,Rnew] = downqr(Q,R,j)
%
% [Qnew,Rnew] = downqr(Q,R,j)
%
% Given a full QR factorization of A (m x n) with m>= n,
% it obtains the full QR factorization of
%
% A(:,[1:j1,j+1:n]) = Qnew*Rnew
%
% WITHOUT constructing the matrix A.
Apply Matlab’s function qr over n  j carefully chosen (2 x 1) submatrices of
(what initially is) Rj . Apply the obtained (2 x 2) matrix Q on the appropriate
submatrices of (what initially is) the original Q and Rj so they get transformed
progressively into QNEW and RNEW. Do not use qr on matrices larger than (2 x 1)!
The function downqr must be faster than the command qr(Aj). To check that, you must
generate 10 random matrices A of sizes (100 k) x (50 k) for k = 1 : 10 (use the command
randn). For each of those matrices, compute [Q,R] =qr(A), and compare the CPU time
(in seconds) needed by downqr(Q,R,j) and qr(Aj) for j = 16 (use cputime).
You must write the script compartime that plots the CPU time needed for downqr(Q,R,j)
(red circles) and for qr(Aj) (blue crosses) as a function of the parameter k.
