next up previous
Next: function prodgiv Up: Appendix Previous: Appendix

function QRstep


function 
$ [\alpha,\beta,C,S] =$ QRstep 
$ (\alpha,\beta,\kappa,n);$ 

 % Input: $ \alpha$ - the main diagonal of the symmetric tridiagonal matrix
 % $ \beta$ - the subdiagonal of the symmetric tridiagonal matrix
 % $ \kappa $ - the shift used in the current step
 % $ n$ - the order of the matrix
 % Output: $ \alpha$ - the new main diagonal of the symmetric tridiagonal matrix
 % $ \beta$ - the new subdiagonal of the symmetric tridiagonal matrix
 % $ C$ - the vector of the cosines coefficients of the Givens rotations
 % $ S$ - the vector of the sines coefficients of the Givens rotations

% one step of implicitly shifted QR algorithm;
$ g=\alpha(1)-\kappa; $
$ s=1; c=1; p=0; $
for $ i=1:n-1, $
$ f= s \times \beta(i);$
$ b=c \times \beta(i); $
$ [c,s,g]$=Givens$ (g,f);$
$ C(i)=c; \; S(i)=s; $
if $ i \sim =1, $
$ \beta(i-1)=g; $
end
$ u=\alpha(i)-p; $
$ v=(\alpha(i+1)-u)\times s+2 \times c \times b; $
$ p=s \times v; $
$ \alpha(i)=u+p; $
$ g=c \times v-b; $
end
$ \alpha(k)=\alpha(k)-p;$
$ \beta(k-1)=g;$
Computational complexity: $ 12 n $ floating point operations plus $ 7 n$ floating point operations due to the computation of the Givens coefficients by the function Givens [8].
next up previous
Next: function prodgiv Up: Appendix Previous: Appendix
Raf Vandebril 2004-10-08