% SCript P1
% Checks out ParJacSVD

clc
% generate an example...
n = 20;
A = randn(n,n);
tol = .000000000001;
% Compute an approximate UNnormalized SVD...
[U,Sigma,V,sweeps] = ParJacSVD(A,tol);
% UNnormalized means that the diagonal of Sigma may have negatives of
% the singular values andthey need not be ordered. (Who cares!)

% These should be O(eps)...
fprintf('errU   = %10.3e\n', norm(U'*U - eye(n,n)))
fprintf('errV   = %10.3e\n', norm(V'*V - eye(n,n)))
% This should be O(eps*norm(A))..
fprintf('errSig = %10.3e\n', norm(U'*A*V - Sigma))
% This should be less than 1...
fprintf('offSig = %10.3e\n',norm(Sigma-diag(diag(Sigma)),'fro')/(tol*norm(A,'fro')))
% This should be a modest integer, e.g.
fprintf('sweeps = %1d\n\n',sweeps)