next up previous contents index
Next: The determinant of a Up: Some algorithms connected to Previous: Swapping the representation   Contents   Index


A fast matrix vector multiplication

In this section an example of an implementation with the Givens-vector representation is given. In later chapters, other algorithms based on this representation can be found.

Because for generator representable semiseparable matrices the multiplication with a vector clearly can be performed with $ O(n)$ operations, we also want an $ O(n)$ implementation for the Givens-vector representation. The formulas will be given for nonsymmetric semiseparable matrices, that are represented by two sequences of Givens transformations and two vectors. Let us denote the first sequence as:

$\displaystyle G$ $\displaystyle =$ \begin{displaymath}\left(
\begin{array}{cccc}
c_1 & c_2 & \ldots & c_{n-1} \\
s_1 & s_2 & \ldots & s_{n-1}
\end{array} \right)\end{displaymath}  
$\displaystyle d$ $\displaystyle =$ \begin{displaymath}\left(
\begin{array}{cccc}
d_1 & d_2 & \ldots & d_n
\end{array} \right)\end{displaymath}  

and the second as:
$\displaystyle H$ $\displaystyle =$ \begin{displaymath}\left(
\begin{array}{cccc}
r_1 & r_2 & \ldots & r_{n-2} \\
t_1 & t_2 & \ldots & t_{n-2}
\end{array} \right)\end{displaymath}  
$\displaystyle e$ $\displaystyle =$ \begin{displaymath}\left(
\begin{array}{cccc}
e_1 & e_2 & \ldots & e_{n-1}
\end{array} \right).\end{displaymath}  

We want to calculate the multiplication between $ S$ and $ v$ where

% latex2html id marker 31964
$\displaystyle S=\left( \begin{array}{cccccc} c_1 d...
...} s_{n-2} \cdots s_1 d_1 & \ldots & & & s_{n-1}d_{n-1}& d_n \end{array} \right)$    

and

% latex2html id marker 31966
$\displaystyle v=\left( \begin{array}{cccc} v_1 & v_2 & \ldots & v_n \end{array} \right)^T.$    

To deduce the algorithm, we have to decompose the matrix $ S$ into a strictly upper triangular, and a lower triangular part. Denote $ S_1=\tril(S)$ and $ S_2=\triu(S,1)$. We will now compute:
$\displaystyle y$ $\displaystyle =$ $\displaystyle S_1 v$  
$\displaystyle z$ $\displaystyle =$ $\displaystyle S_2 v$  

such that $ x=y+z=Sv$ is the result. To calculate % latex2html id marker 31989
$ y=\left( \begin{array}{cccc} y_1 & y_2 & \ldots & y_n \end{array} \right)$ in a fast way, we rewrite the following formulas (only the first $ 4$ components of $ y$ are denoted):
$\displaystyle y_1$ $\displaystyle =$ $\displaystyle c_1 d_1 v_1$  
$\displaystyle y_2$ $\displaystyle =$ $\displaystyle c_2 s_1 d_1 v_1 + c_2 d_2 v_2$  
$\displaystyle y_3$ $\displaystyle =$ $\displaystyle c_3 s_2 s_1 d_1 v_1 + c_3 s_2 d_2 v_2 + c_3 d_3 v_3$  
$\displaystyle y_4$ $\displaystyle =$ $\displaystyle c_4 s_3 s_2 s_1 d_1 v_1 + c_4 s_3 s_2 d_2 v_2 + c_4 s_3 d_3
v_3 + c_4 d_4 v_4.$  

We use some temporary variables called $ a_i$. Rewriting the formulas reveals the order $ O(n)$ algorithm for the multiplication.
$\displaystyle y_1$ $\displaystyle =$ $\displaystyle c_1 \left( d_1 v_1 \right)$  
  $\displaystyle =$ $\displaystyle c_1 a_1$  
$\displaystyle y_2$ $\displaystyle =$ $\displaystyle c_2 \left( s_1 d_1 v_1 + d_2 v_2 \right)$  
  $\displaystyle =$ $\displaystyle c_2 \left( s_1 a_1+d_2 v_2 \right)$  
  $\displaystyle =$ $\displaystyle c_2 a_2$  
$\displaystyle y_3$ $\displaystyle =$ $\displaystyle c_3 \left( s_2 \left( s_1 d_1 v_1 + d_2 v_2 \right) + d_3 v_3 \right)$  
  $\displaystyle =$ $\displaystyle c_3 \left( s_2 a_2 + d_3 v_3 \right)$  
  $\displaystyle =$ $\displaystyle c_3 a_3$  
$\displaystyle y_4$ $\displaystyle =$ $\displaystyle c_4 \left( s_3 \left( s_2 \left( s_1 d_1 v_1 + d_2 v_2 \right) + d_3 v_3 \right)
v_3 + d_4 v_4 \right)$  
  $\displaystyle =$ $\displaystyle c_4\left( s_3 a_3 + d_4 v_4 \right)$  
  $\displaystyle =$ $\displaystyle c_4 a_4.$  

Combining the last $ 2$ equalities of all the $ y_i$'s one can derive an order $ n$ algorithm to perform the multiplication of $ S_1$ and $ v$. The multiplication of $ S_2$ and $ v$ can be derived in a completely analogous way.
next up previous contents index
Next: The determinant of a Up: Some algorithms connected to Previous: Swapping the representation   Contents   Index
Raf Vandebril 2004-05-03