rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
improve_conditioning.m
1 function UO = improve_conditioning(U,K);
2 %function UO = improve_conditioning(U,K);
3 %
4 % function performing svd of U, therefore making columns of U more
5 % linearly
6 % independent. Finally, the UO columns are scaled wrt its K-norm.
7 % Note that this is "normalization" wrt the K-scalarproduct, but
8 % NOT orthogonalization wrt K, but only orthogonalization wrt. the
9 % Euclidean scalar product.
10 
11 % Bernard Haasdonk 28.2.2012
12 
13 if (cond(U'*K*U)>1e6);
14 % disp('improving conditioning!');
15 
16  % perform not exact orthongonalization, but
17  % conditioning improvement.
18 % keyboard;
19  [u,s,v] = svd(U,0);
20  UO = u;
21  unorminv = (sqrt(sum((K * UO).*UO,1))).^(-1);
22  UO = UO * diag(unorminv(:));
23 % disp(['new cond=',num2str(cond(UO'*K*UO))]);
24  %% the following performs repeated qr orthogonalization
25  %UO = orthonormalize_qr(U,K,eps);
26  %KN = UO' * K * UO;
27  %e = (max(max(abs(KN-eye(size(KN))))));
28  %while e > 1e-12
29  % disp('PERFORMING REPEATED ORTHONORMALIZATION');
30  % disp('Detected orthonormalization accuracy problem.');
31  % UO = orthonormalize_qr(UO,K,2e-16);
32  % KN = UO' * K * UO;
33  % e = (max(max(abs(KN-eye(size(KN))))));
34  % % error('error in orthonormalization, please check!');
35  %end;
36 
37 else
38  UO = U;
39 end;
40