function QRvsSVD()

clc
m = 1000;
disp('                                      With Pivoting       No Pivoting ')
disp('  m     n     svd(A)    svd(A,0)    QR(A)     QR(A,0)    QR(A)    QR(A,0)')
disp('----------------------------------------------------------------------------')
for n=100:100:1000
    A = randn(m,n);
    tic, [U,S,V] = svd(A);   tSVD = toc;
    tic, [U,S,V] = svd(A,0); tSVD0 = toc;
    tic, [Q,R,P] = qr(A);    tQRP = toc;
    tic, [Q,R,P] = qr(A,0);  tQRP0 = toc;
    tic, [Q,R]   = qr(A);    tQR = toc;
    tic, [Q,R]   = qr(A,0);  tQR0 = toc;
    fprintf('%4d  %4d    %5.2f     %5.2f       %5.2f     %5.2f     %5.2f      %5.2f\n',...
        m,n,1,tSVD0/tSVD,tQRP/tSVD,tQRP0/tSVD,tQR/tSVD,tQR0/tSVD)
end
        