rbmatlab 0.10.01
general/vecmat/improve_conditioning.m
00001 function UO = improve_conditioning(U,K);
00002 %function UO = improve_conditioning(U,K);
00003 %
00004 % function performing svd of U, therefore making columns of U more
00005 % linearly
00006 % independent. Finally, the UO columns are scaled wrt its K-norm.
00007 % Note that this is "normalization" wrt the K-scalarproduct, but
00008 % NOT orthogonalization wrt K, but only orthogonalization wrt. the
00009 % Euclidean scalar product.
00010 
00011 % Bernard Haasdonk 28.2.2012
00012 
00013 if (cond(U'*K*U)>1e6);
00014 %  disp('improving conditioning!');
00015   
00016   % perform not exact orthongonalization, but 
00017   % conditioning improvement.
00018 %  keyboard;
00019   [u,s,v] = svd(U,0);
00020   UO = u;
00021   unorminv = (sqrt(sum((K * UO).*UO,1))).^(-1);
00022   UO = UO * diag(unorminv(:));
00023 %  disp(['new cond=',num2str(cond(UO'*K*UO))]);
00024   %% the following performs repeated qr orthogonalization
00025   %UO = orthonormalize_qr(U,K,eps);
00026   %KN = UO' * K * UO;
00027   %e = (max(max(abs(KN-eye(size(KN))))));
00028   %while e > 1e-12
00029   %  disp('PERFORMING REPEATED ORTHONORMALIZATION');
00030   %  disp('Detected orthonormalization accuracy problem.');
00031   %  UO = orthonormalize_qr(UO,K,2e-16);
00032   %  KN = UO' * K * UO;
00033   %  e = (max(max(abs(KN-eye(size(KN))))));
00034   %  %    error('error in orthonormalization, please check!');
00035   %end;
00036 
00037 else
00038   UO = U;
00039 end;
00040 
All Classes Namespaces Files Functions Variables