1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
|
\section{{\tt DChvMtx}: Double Precision Chevron Matrix Object}
\par
Let $A$ be an $n \times n$ matrix to be factored.
We are going to allow both row and column permutations as the
factorization proceeds, and our pivot blocks may be larger
than $1 \times 1$ pivots.
After the first step we have
$$
A = A_0
=
P_0
\left \lbrack \begin{array}{cc}
I & 0 \\
{\hat L}_0 & I
\end{array} \right \rbrack
\left \lbrack \begin{array}{cc}
I & 0 \\
0 & {\hat A}_1
\end{array} \right \rbrack
\left \lbrack \begin{array}{cc}
{\hat D}_0 & {\hat U}_0 \\
0 & I
\end{array} \right \rbrack
Q_0
= P_0 \ L_0 \ A_1 \ U_0 \ Q_0
$$
where $P_0$ is the row permutation matrix,
${\hat D}_0$ is the pivot block,
$\displaystyle L_0 =
\left \lbrack \begin{array}{cc}
I & 0 \\
{\hat L}_0 & I
\end{array} \right \rbrack
$,
$\displaystyle A_1 =
\left \lbrack \begin{array}{cc}
I & 0 \\
0 & {\hat A}_1
\end{array} \right \rbrack
$,
$\displaystyle U_0 =
\left \lbrack \begin{array}{cc}
{\hat D}_0 & {\hat U}_0 \\
0 & I
\end{array} \right \rbrack
$ and
$Q_0$ is the column permutation matrix.
Now $A_1$ can be factored in the same manner,
$$
A_1
=
P_1
\left \lbrack \begin{array}{cc}
I & 0 \\
{\hat L}_1 & I
\end{array} \right \rbrack
\left \lbrack \begin{array}{cc}
I & 0 \\
0 & {\hat A}_2
\end{array} \right \rbrack
\left \lbrack \begin{array}{cc}
{\hat D}_1 & {\hat U}_1 \\
0 & I
\end{array} \right \rbrack
Q_1
= P_1 \ L_1 \ A_2 \ U_1 \ Q_1
$$
so we can expand $A_0$ to find
$A = P_0 \ L_0 \ P_1 \ L_1 \ A_2 \ U_1 \ Q_1 \ U_0 \ Q_0$.
Eventually the factorization proceeds to completion and we have
$$
A = (P_0 \ L_0 \ P_1 \ L_1 \ \cdots \ P_k \ L_k)
(U_K \ Q_k \ \cdots \ U_1 \ Q_1 \ U_0\ Q_0)
$$
Note, $L_0, L_1, \ldots, L_k$ are all lower triangular,
for it is the row permutation matrices that are responsible.
Note that ${\tilde L}_i = P_i L_i$ is not a lower triangular
matrix, but one can solve a linear system involving ${\tilde L}_i$
without any difficulty.
A similar statement holds for ${\tilde U}_i = U_i Q_i$,
except we have the presence of a block pivot ${\hat D}_i$.
\par
The key to understanding how we factor and solve linear systems
using the {\tt DChvMtx} object is that the permutation matrices
$P_i$ and $Q_i$ are held implicitly in
${\tilde L}_i$
and
${\tilde U}_i$,
and we solve any linear system with
${\tilde L}_i$
and
${\tilde U}_i$ correctly,
even though they are not triangular.
We can write $A$ as
$$
A =
{\tilde L}_0 \
{\tilde L}_1 \
\cdots \
{\tilde L}_k \
{\tilde U}_k \
\cdots \
{\tilde U}_1 \
{\tilde U}_0
$$
and thus $A y = b$ by solving a sequence of linear systems
${\tilde L}_0 \ x^0 = b$,
${\tilde L}_1 \ x^1 = x^0$,
$\cdots$,
${\tilde L}_k \ x^k = x^{k-1}$,
${\tilde U}_k \ y^k = x^k$,
${\tilde U}_{k-1} \ y^{k-1} = y^k$,
$\cdots$,
${\tilde U}_1 \ y^1 = y^2$,
${\tilde U}_0 \ y = y^1$.
% Here is a crucial point:
% solving a linear system with ${\tilde L}_i$ requires
% information about the row permutation at the $i$-th step,
% but does not require any knowledge about the column permutation
% at that or any other step.
% A similar point holds for systems with ${\tilde U}_i$.
\par
Let us clarify the process with an example.
At the first step we permute a $3 \times 3$ matrix so that the
$a_{1,2}$ element is the pivot.
\begin{eqnarray*}
A & = &
\left \lbrack \begin{array}{ccc}
a_{0,0} & a_{0,1} & a_{0,2} \\
a_{1,0} & a_{1,1} & a_{1,2} \\
a_{2,0} & a_{2,1} & a_{2,2}
\end{array} \right \rbrack
=
\left \lbrack \begin{array}{ccc}
0 & 1 & 0 \\
1 & 0 & 0 \\
0 & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
a_{1,2} & a_{1,0} & a_{1,1} \\
a_{0,2} & a_{0,0} & a_{0,1} \\
a_{2,2} & a_{2,0} & a_{2,1}
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
0 & 0 & 1 \\
1 & 0 & 0 \\
0 & 1 & 0
\end{array} \right \rbrack \\
& = &
\left \lbrack \begin{array}{ccc}
0 & 1 & 0 \\
1 & 0 & 0 \\
0 & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
l_{0,2} & 1 & 0 \\
l_{2,2} & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & {\hat a}_{0,0} & {\hat a}_{0,1} \\
0 & {\hat a}_{2,0} & {\hat a}_{2,1}
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
d_{1,2} & u_{1,0} & u_{1,1} \\
0 & 1 & 0 \\
0 & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
0 & 0 & 1 \\
1 & 0 & 0 \\
0 & 1 & 0
\end{array} \right \rbrack \\
& = &
{\tilde L}_0 \ A_1 \ {\tilde U}_0
=
\left \lbrack \begin{array}{ccc}
l_{0,2} & 1 & 0 \\
1 & 0 & 0 \\
l_{2,2} & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & {\hat a}_{0,0} & {\hat a}_{0,1} \\
0 & {\hat a}_{2,0} & {\hat a}_{2,1}
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
u_{1,0} & u_{1,1} & d_{1,2} \\
1 & 0 & 0 \\
0 & 1 & 0
\end{array} \right \rbrack
\end{eqnarray*}
We then do the same for $A_1$, using ${\hat a}_{2,1}$ as the pivot.
\begin{eqnarray*}
A_1 & = &
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & {\hat a}_{0,0} & {\hat a}_{0,1} \\
0 & {\hat a}_{2,0} & {\hat a}_{2,1}
\end{array} \right \rbrack
=
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 0 & 1 \\
0 & 1 & 0
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & {\hat a}_{2,1} & {\hat a}_{2,0} \\
0 & {\hat a}_{0,1} & {\hat a}_{0,0}
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 0 & 1 \\
0 & 1 & 0
\end{array} \right \rbrack \\
& = &
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 0 & 1 \\
0 & 1 & 0
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & l_{0,1} & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & {\hat a}_{2,1} & {\hat a}_{2,0} \\
0 & {\hat a}_{0,1} & {\hat a}_{0,0}
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & d_{2,1} & u_{2,0} \\
0 & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 0 & 1 \\
0 & 1 & 0
\end{array} \right \rbrack \\
& = &
{\tilde L}_1 \ A_2 \ {\tilde U}_1
=
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & l_{0,1} & 1 \\
0 & 1 & 0
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & {\tilde a}_{0,0}
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & u_{2,0} & d_{2,1} \\
0 & 1 & 0
\end{array} \right \rbrack
\end{eqnarray*}
Finally, we have the factorization of $A_2$.
$$
A_2
=
P_2 \ L_2 \ U_2 \ Q_2
=
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & d_{0,0}
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{array} \right \rbrack
$$
Written on one line we have the factorization of $A$ given below
where ${\tilde L}_2 = I$ is omitted.
\begin{eqnarray*}
A
& = &
{\tilde L}_0 \
{\tilde L}_1 \
{\tilde U}_2 \
{\tilde U}_1 \
{\tilde U}_0 \\
& = &
\left \lbrack \begin{array}{ccc}
l_{0,2} & 1 & 0 \\
1 & 0 & 0 \\
l_{2,2} & 0 & 1
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & l_{0,1} & 1 \\
0 & 1 & 0
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & d_{0,0}
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
1 & 0 & 0 \\
0 & u_{2,0} & d_{2,1} \\
0 & 1 & 0
\end{array} \right \rbrack
\left \lbrack \begin{array}{ccc}
u_{1,0} & u_{1,1} & d_{1,2} \\
1 & 0 & 0 \\
0 & 1 & 0
\end{array} \right \rbrack
\end{eqnarray*}
At best this equation looks awkward, but take heart, it really
doesn't describe how we store the entries or use them to solve a
linear system.
The entries can be logically grouped in terms of chevrons.
$$
A^0 =
\left \lbrack \begin{array}{ccc}
d_{1,2} & u_{1,0} & u_{1,1} \\
l_{0,2} & 0 & 0 \\
l_{2,2} & 0 & 0
\end{array} \right \rbrack,
\qquad
A^1 =
\left \lbrack \begin{array}{ccc}
0 & 0 & 0 \\
0 & d_{2,1} & u_{2,0} \\
0 & l_{0,1} & 0
\end{array} \right \rbrack,
\qquad
A^2 =
\left \lbrack \begin{array}{ccc}
0 & 0 & 0 \\
0 & 0 & 0 \\
0 & 0 & d_{0,0}
\end{array} \right \rbrack,
\qquad
$$
For each chevron we store
the indices of the rows and columns that are nonzero,
and the entries in the diagonal, lower triangular and
upper triangular block.
Note, the row indices and the column indices need not be the same.
\par
Let us show how we solve a linear system.
To solve $A x = b$ we first solve $L y = b$ and then solve $U x = y$
where $L = {\tilde L}_0 {\tilde L}_1 {\tilde L}_2$
and $U = {\tilde U}_2 {\tilde U}_1 {\tilde U}_0$.
Note that there are no permutation matrices anywhere.
\begin{itemize}
\item
To solve with ${\tilde L}_0$ we set $y_1 = b_1$,
$b_0 := b_0 - l_{0,2} y_1$ and
$b_2 := b_2 - l_{2,2} y_1$.
\item
To solve with ${\tilde L}_1$ we set $y_2 = b_2$ and
$b_0 := b_0 - l_{0,1} y_2$.
\item
To solve with ${\tilde L}_2$ we set $y_0 = b_0$.
\item
To solve with ${\tilde U}_2$ we set $x_0 = y_0/d_{0,0}$.
\item
To solve with ${\tilde U}_1$ we set $x_1 = (y_2 - u_{2,0}x_0)/d_{2,1}$.
\item
To solve with ${\tilde U}_0$
we set $x_2 = (y_1 - u_{1,0}x_0 - u_{1,1} x_1)/d_{1,2}$.
\end{itemize}
In general, let us write the $k$-th chevron as
$$
A^2 =
\left \lbrack \begin{array}{cc}
D_{\alpha_k,\beta_k} & U_{\alpha_k,\delta_k} \\
L_{\gamma_k,\beta_k} & 0
\end{array} \right \rbrack
$$
where $\alpha_k$ and $\gamma_k$ form the row index set
and $\beta_k$ and $\delta_k$ form the column index set.
Since the pivots partition the rows and columns, we have
$$
\gamma_k \cap \bigcup_{i < k} \alpha_i = \emptyset
\quad \mbox{and} \quad
\delta_k \cap \bigcup_{i < k} \beta_i = \emptyset.
$$
The forward solve and backward solve are executed by
\begin{center}
\begin{minipage}{3 in}
\begin{tabbing}
XXX\=XXX\=XXX\=\kill
for $k = 1, \ldots, \mbox{\# of pivots}$ \\
\> $y_{\alpha_k} = b_{\alpha_k}$ \\
\> $b_{\gamma_k} := b_{\gamma_k}
- L_{\gamma_k, \beta_k} y_{\alpha_k}$ \\
end for \\
for $k = \mbox{\# of pivots}, \ldots, 1$ \\
\> $y_{\alpha_k} = b_{\alpha_k}$ \\
\> $x_{\beta_k} := D_{\alpha_k, \beta_k}^{-1}
(y_{\alpha_k} - U_{\alpha_k, \delta_k} x_{\delta_k})$
end for
\end{tabbing}
\end{minipage}
\end{center}
|