Golub-Kahan reorthogonalization [Y]=REORT(U,UADD) Given orthonormal matrix U, orthonormalize UADD to it to get orthogonal basis in [U,UADD]. Faster then the QR-decomposition, using the Golub-Kahan method TT-Toolbox 2.2, 2009-2012 This is TT Toolbox, written by Ivan Oseledets et al. Institute of Numerical Mathematics, Moscow, Russia webpage: http://spring.inm.ras.ru/osel For all questions, bugs and suggestions please mail ivan.oseledets@gmail.com ---------------------------
0001 function [y]=reort(u,uadd) 0002 %Golub-Kahan reorthogonalization 0003 % [Y]=REORT(U,UADD) Given orthonormal matrix U, orthonormalize UADD to it 0004 % to get orthogonal basis in [U,UADD]. Faster then the QR-decomposition, 0005 % using the Golub-Kahan method 0006 % 0007 % 0008 % TT-Toolbox 2.2, 2009-2012 0009 % 0010 %This is TT Toolbox, written by Ivan Oseledets et al. 0011 %Institute of Numerical Mathematics, Moscow, Russia 0012 %webpage: http://spring.inm.ras.ru/osel 0013 % 0014 %For all questions, bugs and suggestions please mail 0015 %ivan.oseledets@gmail.com 0016 %--------------------------- 0017 if (size(uadd,2)==0) 0018 y = u; 0019 return; 0020 end; 0021 if (size(u,1) == size(u,2) ) 0022 y=u; 0023 return 0024 end 0025 if (size(u,2) + size(uadd,2) >= size(u,1) ) 0026 uadd=uadd(:,size(u,1)-size(u,2)); 0027 end 0028 radd=size(uadd,2); 0029 0030 mvr=u'*uadd; unew=uadd-u*mvr; 0031 reort_flag=true; 0032 while (reort_flag ) 0033 reort_flag=false; 0034 j=1; 0035 %Nice vectorization! 0036 norm_unew=sum(unew.^2,1); 0037 norm_uadd=sum(uadd.^2,1); 0038 reort_flag=isempty(norm_unew <= 0.25*norm_uadd); 0039 [unew,rv_not_used]=qr(unew,0); %Here it is ok. 0040 if (reort_flag) 0041 su=u'*unew; 0042 uadd=unew; 0043 unew=unew-u*su; 0044 end 0045 0046 end 0047 y=[u,unew]; 0048 return 0049 end