% check unitaries and compare with octave svd
format long g
split_long_rows(0);
echo on
r
norm(A*A'-eye(n),'fro')
norm(Q*Q'-eye(n),'fro')
norm(V(1:r,:)*V(1:r,:)'-eye(r),'fro')
norm(A-Q(1:r,:)'*diag(S,r,r)*V(1:r,:),'fro')
[UU SS VV] = svd(A);
rr=rank(SS)
norm(UU*UU'-eye(n),'fro')
norm(VV(1:rr,:)*VV(1:rr,:)'-eye(r),'fro')
norm(A-UU(:,1:rr)*SS(1:rr,1:rr)*VV(:,1:rr)','fro')
echo off
