next up previous
Next: The shift Up: An implicit algorithm for Previous: Proof of the correctness


Effective $ O(n)$ implementation of the implicit $ QR$ algorithm

The implementation can be downloaded at http://www.cs.kuleuven.ac.be/$ \sim$marc/. Not all the details of the implementation are given, but the mathematical ideas, behind the algorithm are included, and they should make it possible for the reader to implement this algorithm.

The following function in Matlab5-style notation

[Gnew,dnew]=CRep(G,d)
will perform the first sequence of Givens transformations. The input consists of the Givens vector representation of the matrix, the output is the representation of the new matrix, but from bottom to top.

Suppose our semiseparable matrix $ A$ is built up with the Givens transformations $ G$ and the vector elements $ d$. We will now perform the first $ n-1$ Givens transformations on both sides of the matrix, and we will retrieve the representation of the resulting semiseparable matrix. The matrix $ A$ has the following structure:

% latex2html id marker 4208
$\displaystyle \left( \begin{array}{ccc} A^{(n-1)} &...
... & s_{n-1}d_{n-1} \\  s_{n-1} R_{n-1} & s_{n-1}d_{n-1} & d_n \end{array}\right)$ (13)

And the Givens transformations are denoted in the same way as in (6). Remark that the Givens transformations needed for the first step of the $ QR$ algorithm are exactly the Givens transformations $ G^T_j$ from the representation. This is a huge advantage, because these Givens transformations do not need to be calculated anymore.

Applying the first transformation $ G_{n-1}^T$ to the left of matrix (13) gives us the following equations

$\displaystyle \hat{d}_1$ $\displaystyle =$ $\displaystyle s^2_{n-1}d_{n-1} + c_{n-1} d_n$  

and the matrix looks like:

% latex2html id marker 4223
$\displaystyle \left( \begin{array}{ccc} A & c_{n-1}...
...d_{n-1} & s_{n-1}(c_{n-1}d_{n-1}-d_n) \\  0 & 0 & \hat{d}_1 \end{array}\right).$    

Applying the transformation to the right gives the following equations:

% latex2html id marker 4225
$\displaystyle \left( \begin{array}{ccc} A & R_{n-1}...
...{n-1}\hat{d}_1 \\  0 & s_{n-1}\hat{d}_1 & c_{n-1}\hat{d}_1 \end{array}\right) ,$    

with $ \tilde{d}_{n-1} = \left( 1+s^2_{n-1} \right) c_{n-1} d_{n-1} - d_n .$ When denoting now the new representation with $ \hat{G}$ and $ \hat{d}$, we get:

\begin{displaymath}
% latex2html id marker 4233
\hat{G}_1=\left(
\begin{array}{cc}
c_{n-1} & -s_{n-1} \\
s_{n-1} & c_{n-1}
\end{array}\right)\end{displaymath}

and $ \hat{d}_1$. This procedure can now be continued to find the full new matrix $ \hat{G}$ and the vector $ \hat{d}$. Remark once more that this representation is constructed from bottom to top.

The following function

[Gnew,dnew]=PerSeqGiv(G,d,specgiv)
in the algorithm performs in fact the next $ n-1$ Givens transformations on the matrix. This function starts with one special Givens transformation $ \hat{G}=specgiv$. Because the following sequence of Givens transformations will divide the matrix into two semiseparable parts, we have to store twice a semiseparable matrix. The decreasing lower right semiseparable matrix will be stored in the Givens and vector representation. While the growing upper left part will also be stored in a the Givens vector representation $ Gnew,dnew$.

Suppose we want to perform the first special Givens transformation $ \hat{G}$ on the matrix $ A$, which looks like (this is different from above, because the representation is from bottom to top now):

% latex2html id marker 4251
$\displaystyle \left( \begin{array}{ccc} d_n & s_{n-...
...{n-1} \\  s_{n-1} R_{n-1}^T & c_{n-1} R_{n-1}^T & A^{(n-1)} \end{array} \right)$ (14)

Applying now the first special Givens transformation $ \hat{G}$ to the left of the matrix (14), we get the following matrix:

% latex2html id marker 4255
$\displaystyle \left( \begin{array}{ccc} \hat{c} d_n...
...{n-1} \\  s_{n-1} R_{n-1}^T & c_{n-1} R_{n-1}^T & A^{(n-1)} \end{array} \right)$    

Applying the Givens transformation $ \hat{G}$ on the right gives, for

$\displaystyle \hat{d}_1$ $\displaystyle =$ $\displaystyle \hat{c}^2 d_n+ \hat{s}^2 c_{n-1} d_{n-1} -2\hat{c}\hat{s} c_{n-1} d_{n-1},$  
$\displaystyle f_1$ $\displaystyle =$ $\displaystyle \left(\hat{c} s_{n-1} -\hat{s} c_{n-1}\right)/s_{n-1},$  
$\displaystyle f_2$ $\displaystyle =$ $\displaystyle \left(\hat{s} s_{n-1} +\hat{c} c_{n-1}\right)/c_{n-1},$  
$\displaystyle \alpha_1$ $\displaystyle =$ $\displaystyle \hat{c}\hat{s} d_n+\left(\left(\hat{c}^2-\hat{s}^2\right)s_{n-1} - \hat{s}\hat{c} s_{n-1}\right)d_{n-1} ,$  
$\displaystyle \tilde{d}_{n-1}$ $\displaystyle =$ $\displaystyle \hat{s}^2 d_n +\left(2\hat{c}\hat{s} s_{n-1}+ \hat{c}^2c_{n-1}\right)d_{n-1} ,$  

the following matrix:

% latex2html id marker 4290
$\displaystyle \left( \begin{array}{ccc} \hat{d}_1 &...
...  f_1 s_{n-1} R_{n-1}^T & f_2 c_{n-1} R_{n-1}^T & A^{(n-1)} \end{array} \right)$    

The element $ \hat{d}_1$ can already be stored in the Givens vector representation of the new semiseparable matrix. The lower right reduced semiseparable matrix can still be constructed by the old representation and the knowledge of $ \tilde{d}_{n-1}$ and the factor $ f_2$. The upper left $ 3\times 3$ block can now be used to construct the next Givens transformation according to Theorem 3.2. One can clearly see that this procedure, can be repeated to find the new diagonal element $ \hat{d}_2$ and the first subdiagonal element $ \hat{d}^{(s)}_1$, and so on.

In the practical implementation the factor $ f_2$ is not used, instead the Givens $ \hat{G}$ transformation is applied directly on the vector $ [s_{n-1},c_{n-1}]$ from which the value of the first element of $ f_2c_{n-1}R^T_{n-1}$ can be calculated and also the other elements in the same column.

Also the new representation is built up at the same time, by storing extra information concerning the values of $ \alpha_1$ and $ \tilde{d}_{n-1}$. For a full understanding the software can be downloaded and investigated.


next up previous
Next: The shift Up: An implicit algorithm for Previous: Proof of the correctness
Raf Vandebril 2004-04-19