Professional Documents
Culture Documents
Mws Gen Sle TXT Cholesky PDF
Mws Gen Sle TXT Cholesky PDF
11
Cholesky and LDLT Decomposition
Introduction
Solving large (and sparse) system of simultaneous linear equations (SLE) has been (and
continues to be) a major challenging problem for many real-world engineering/science
applications [1-2]. In matrix notation, at set of SLE can be represented as:
[ A][ x] = [b] (1)
where
[ A] = known coefficient matrix, with dimension n × n
[b] = known right-hand-side (RHS) n × 1 vector
[x] = unknown n × 1 vector.
04.11.1
04.11.2 Chapter 04.11
Example 1
Find if
2 −1 0
[ A] = − 1 2 − 1
0 − 1 1
is SPD?
Solution
Criterion a: If each and every determinant of sub-matrix Aii (i = 1,2,..., n) is positive.
The given 3× 3 matrix [ A] is symmetrical, because aij = a ji . Furthermore, one has
det [A]1×1 = 2 = 2 > 0
2 −1
det [A]2×2 =
−1 2
=3>0
2 −1 0
det [A]3×3 = −1 2 −1
0 −1 1
=1> 0
Hence [ A] is SPD.
Criterion (b): If y T Ay > 0 for any given vector [ y ] n×1 ≠ 0
For any given vector
y1
y = y2 ≠ 0 ,
y 3
one computes
2 − 1 0 y1
y Ay = [ y1 y 2 y 3 ] − 1 2 − 1 y 2
T
0 − 1 1 y 3
= (2 y12 − 2 y1 y 2 + 2 y 22 ) + {y 32 − 2 y 2 y 3 }
= ( y1 − y 2 ) + y12 + y 22 + {y 32 − 2 y 2 y 3 }
2
= ( y1 − y 2 ) + y12 + ( y 2 − y 3 ) > 0
2 2
Step 1.2 If u ij is an off-diagonal term (say, i < j ) then from Equation (7)
Sum
u ij =
u ii
else, if u ij is a diagonal term (that is, i = j ), then from Equation (6)
04.11.4 Chapter 04.11
u ii = Sum
As a quick example, one computes:
a − u15 u17 − u 25 u 27 − u 35 u 37 − u 45 u 47
u 57 = 57 (8)
u 55
Thus, for computing u (i = 5, j = 7) , one only needs to use the (already factorized) data in
columns # i (= 5) , and # j (= 7) of [U ] , respectively.
In general, to find the (off-diagonal) factorized term u ij , one only needs to utilize the
“already factorized” columns # i , and # j information (see Figure 1). For example, if i = 5 ,
and j = 7 , then Figure 1 will lead to the same formula as shown earlier in Equation (7), or in
Equation (8). Similarly, to find the (diagonal) factorized term u ii , one simply needs to utilize
columns # i , and # i (again!) information (see Figure 1). In this case, Figure 1 will lead to
the same formula as shown earlier in Equation (6).
Col. # i=5 Col. # j=7
uii u1 j
k=1
u 2i u2 j
k=2
u3i u3 j
k=3
u 4i u4 j
k=4
i=5
uii uij
y1
y
2
.
.
y n
hence the name “forward solution”.
As a quick example, one has from Equation (11)
u11 0 0 y1 b1
u
12 u 22 0 y 2 = b2 (12)
u13 u 23 u 33 y3 b3
From the 1st row of Equation (12), one gets
u11 y1 = b1
b
y1 = 1 (13)
u11
nd
From the 2 row of Equation (12), one gets
u12 y1 + u 22 y 2 = b2
u y
y 2 = b2 − 12 1 (14)
u 22
Similarly
b − u y − u 23 y 2
y 3 = 3 13 1 (15)
u 33
In general, from the j th row of Equation (12), one has
j −1
b j − ∑ u ij y i
yj = i =1
(16)
u jj
Step 3: Backward Solution phase
Since [U ] is an upper triangular matrix, Equation (10) can be efficiently solved for the
original unknown vector [x] , according to the order
xn
x
n −1
xn−2
.
x1
and hence the name “backward solution”.
As a quick example, one has from Equation (10)
04.11.6 Chapter 04.11
Multiplying the three matrices on the RHS of Equation (23), then equating the resulting
upper-triangular RHS terms of Equation (23) to the corresponding ones on the LHS, one
obtains the following formulas for the diagonal [D] , and lower-triangular [L] matrices
j −1
d jj = a jj − ∑ l 2jk d kk (24)
k =1
j −1
1
lij = aij − ∑ lik d kk l jk × (25)
k =1 d jj
Thus, the LDLT algorithms can be summarized by the following step-by-step procedures.
Cholesky and LDLT Decomposition 04.11.7
Also, define
[ D][ y ] = [ z ]
d11 0 0 y1 z1
0 d
22 0 y 2 = z 2 (29)
0 0 d 33 y 3 z 3
z
yi = i , for i = 1,2,3, ......, n (30)
dii
Then Equation (26) becomes
[ L][ z ] = [b]
1 0 0 z1 b1
l
21 1 0 z 2 = b2 (31)
l31 l32 1 z 3 b3
i −1
z i = bi − ∑ Lik z k for i = 1,2,3, ......, n (32)
k =1
Equation (31) can be efficiently solved for the vector [z ] , and then Equation (29) can be
conveniently (and trivially) solved for the vector [ y ].
Example 2
Using the Cholesky algorithm, solve the following SLE system for the unknown vector [x ] .
[ A][ x] = [b]
where
04.11.8 Chapter 04.11
2 −1 0
[A] = − 1 2 − 1
0 − 1 1
1
[b] = 0
0
Solution
The factorized, upper triangular matrix [U ] can be computed by either referring to Equations
(6-7), or looking at Figure 1, as following:
Row 1 of [U] is given below.
u11 = a 11
= 2
= 1.414
a
u12 = 12
u11
−1
=
1.414
= −0.7071
a
u13 = 13
u11
0
=
1.414
=0
Row 2 of [U] is given below
1
i −1=1
2
u 22 = a 22 −
∑ (u )
k =1
ki
2
{ }
1
= 2 − (u12 )
2 2
= 2 − (− 0.7071)
2
= 1.225
Cholesky and LDLT Decomposition 04.11.9
i −1=1
a 23 − ∑u ki ukj
u23 = k =1
U 22
− 1 − u12 × u13
=
1.225
− 1 − (− 0.7071)(0)
=
1.225
= −0.8165
Row 3 of [U] is given below
1
2
i −1= 2 2
u33 = a33 − ∑ (uki )
k =1
1
= {a33 − u132 − u23
2 2
}
= 1 − (0) − (− 0.8165)
2 2
= 0.5774
Thus, the factorized matrix
1.414 − 0.7071 0
[U ] = 0 1.225 − 0.8165
0 0 0.5774
The forward solution phase, shown in Equation (11), becomes
[U ]T [ y ] = [b]
1.414 0 0 y1 1
− 0.7071 1.225
0 y 2 = 0
0 − 0.8165 0.5774 y 3 0
Thus, Equation (16) can be used to solve for [y] as
b
y1 = 1
u11
1
=
1.414
= 0.7071
j −1=1
b2 − ∑u ij yi
y2 = i =1
u jj
0 − (u12 = −0.7071)( y1 = 0.7071)
=
(u22 = 1.225)
= 0.4082
04.11.10 Chapter 04.11
j −1= 2
b3 − ∑u ij yi
y3 = i =1
u jj
0 − (u13 = 0)( y1 = 0.7071) − (u23 = −0.8165)( y 2 = 0.4082 )
=
(u33 = 0.5774 )
= 0.5774
The backward solution phase, shown in Equation (10), becomes:
[U ][x] = [ y ]
1.414 − 0.7071 0 x1 0.7071
0
1.225 − 0.8165 x 2 = 0.4082
0 0 0.5774 x3 0.5774
Thus, Equation (21) can be used to solve
yj
x3 =
u jj
y3
=
u33
0.5774
=
0.5774
=1
N =3
yj − ∑u
i = j +1=3
ji xi
x2 =
u jj
y 2 − u23 x3
=
u22
0.4082 − (− 0.8165)(1)
=
1.225
=1
N =3
yj − ∑u
i = j +1= 2
ji xi
x1 =
u jj
y1 − u12 x2 − u13 x3
=
u11
0.7071 − (− 0.7071)(1) − (0)(1)
=
1.414
=1
Cholesky and LDLT Decomposition 04.11.11
Hence
1
[x] = 1
1
Example 3
Using the LDLT algorithm, solve the following SLE system for the unknown vector [x ] .
[ A][ x] = [b]
where
2 −1 0
[A] = − 1 2 − 1
0 − 1 1
1
[b] = 0
0
Solution
The factorized matrices [D] and [L] can be computed from Equation (24) and Equation (25),
respectively.
j −1= 0
d11 = a11 − ∑ l 2jk d kk
k =1
= a11
=2
l11 = 1 (always !)
j −1= 0
a 21 − ∑ lik d kk l jk
l 21 = k =1
d jj
a
= 21 Column 1 of matrices of [D ] and [L]
d11
−1
=
2
= −0.5
a31
l31 =
d11
0
=
2
=0
04.11.12 Chapter 04.11
j −1=1
d 22 = a22 − ∑l 2
jk d kk
k =1
= 2 − l212 d11
= 2 − (− 0.5) (2 )
2
= 1.5
Column 2 of matrices [D ] and [L ]
l22 = 1 (always !)
j −1=1
a32 − ∑ l31d11l21
l32 = k =1
d 22
− 1 − (0 )(2 )(− 0.5)
=
1.5
= −0.6667
j −1= 2
d 33 = a33 − ∑ l 2jk d kk
k =1
Column 3 of matrices [D ] and [L]
2 2
= 1 − l31 d11 − l32 d 22
= 1 − (0 ) (2 ) − (− 0.6667 ) (1.5)
2 2
= 0.3333
Hence
2 0 0
[D] = 0 1.5 0
0 0 0.3333
and
1 0 0
[L] = − 0.5 1 0
0 − 0.6667 1
The forward solution shown in Equation (31) becomes:
[L][z ] = [b]
1 0 0 z1 1
− 0.5
1 0 z 2 = 0 , or
0 − 0.667 1 z 3 0
i −1
z i = bi − ∑ lik z k (32, repeated)
k =1
Hence
Cholesky and LDLT Decomposition 04.11.13
z1 = b1 = 1
z 2 = b2 − L21 z1
= 0 − (− 0.5)(1)
= 0.5
z 3 = b3 − L31 z1 − L32 z 2
= 0 − (0 )(1) − (− 0.6667 )(0.5)
= 0.3333
The diagonal scaling phase, shown in Equation (29) becomes
[D] [ y ] = [z ]
2 0 0 y1 1
0 1.5
0 y 2 = 0.5 , or
0 0 0.3333 y 3 0.3333
zi
yi =
d ii
Hence
z1
y1 =
d 11
1
=
2
= 0.5
z
y2 = 2
d 22
0.5
=
1.5
= 0.3333
z
y3 = 3
d 33
0.3333
=
0.3333
=1
The backward solution phase can be found by referring to Equation (27)
[L]T [x] = [ y ]
1 − 0.5 0 x1 0.5
0
1 − 0.667 x 2 = 0.333
0 0 1 x3 1
N
xi = yi − ∑l
k =i +1
x
ki k (28, repeated)
04.11.14 Chapter 04.11
Hence
x3 = y 3
=1
x 2 = y 2 − l 32 x 3
= 0.3333 − (− 0.6667 ) × 1
x2 = 1
x1 = y1 − l 21 x 2 − l 31 x 3
x1 = 0.5 − (− 0.5)(1) − (0)(1)
=1
Hence
x1
[x ] = x2
x3
1
= 1
1
Through this numerical example, one clearly sees that the “square root operations” have
NOT been involved during the entire LDLT algorithms. Thus, the coefficient matrix [A],
shown in Equation (1) is NOT required to be SPD.
Re-ordering Algorithms For Minimizing Fill-in Terms [1,2].
During the factorization phase (of Cholesky, or LDL T algorithms), many “zero” terms in the
original/given matrix [ A] will become “non-zero” terms in the factored matrix [U ] . These
new non-zero terms are often called as “fill-in” terms (indicated by the symbol F ). It is,
therefore, highly desirable to minimize these fill-in terms, so that both computational
time/effort and computer memory requirements can be substantially reduced. For example,
the following matrix [ A] and vector [b] are given:
112 7 0 0 0 2
7 110 5 4 3 0
0 5 88 0 0 1 (33)
[A] =
0 4 0 66 0 0
0 3 0 0 44 0
2 0 1 0 0 11
121
129
94 (34)
[b] =
70
47
14
Cholesky and LDLT Decomposition 04.11.15
The Cholesky factorization matrix [U ] , based on the original matrix [ A] (see Equation 33)
and Equations (6-7), or Figure 1, can be symbolically computed as
× × 0 0 0 ×
0
× × × × F
0 0 × F F × (35)
[U ] =
0 0 0 × F F
0 0 0 0 × F
0 0 0 0 0 ×
In Equation (35), the symbols x , and F represents the “non-zero” and “fill-in” terms,
respectively.
In practical applications, however, it is always a necessary step to rearrange the
original matrix [ A] through re-ordering algorithms (or subroutines) [Refs 1-2] and produce
the following integer mapping array
IPERM (new equation #) = {old equation #} (36)
such as, for this particular example:
1 6
2 5
3 4 (37)
IPERM =
4 3
5 2
6 1
Using the above results (see Equation 37), one will be able to construct the following re-
arranged matrices:
11 0 0 1 0 2
0 44 0 0
3 0
0 0 66 0 4 0 (38)
[ ]
A* =
1 0 0 88 5 0
0 3 4 5 110 7
2 0 0 0 7 112
and
14
47
*
70 (39)
[b ] =
94
129
121
In the original matrix A (shown in Equation 33), the nonzero term A (old row 1, old
*
column 2) = 7 will move to new location of the new matrix A (new row 6, new column 5) =
7, etc.
*
The non zero term A (old row 3, old column 3) = 88 will move to A (new row 4, new
column 4) = 88, etc.
*
The value of b (old row 4) = 70 will be moved to (or located at) b (new row 3) = 70,
etc.
04.11.16 Chapter 04.11
Now, one would like to solve the following modified system of linear equations (SLE)
*
for [ x ] ,
[ A* ][ x * ] = [b * ] (40)
rather than to solve the original SLE (see Equation (1)). The original unknown vector {x} can
be easily recovered from [ x ] and [IPERM ] , shown in Equation (37).
*
(A) Teaching undergraduates the process how to use the reordering output IPERM(-), see
Equations (36-37) for converting the original/given matrix [ A] , see Equation (33),
into the new/modified matrix [ A* ] , see Equation (38). This step is reflected in Figure
2, when the “Game Player” decides to swap node (or equation) i (say i = 2 ) with
another node (or equation) j, and click the CONFIRM icon! Since node i=2 is
currently connected to nodes j =4, 6, 7, 8, swapping node i = 2 with the above
nodes j will NOT change the number/pattern of the fill-in terms. However, if node
i = 2 is swapped with node j=1, or 3 or 5, then the fill-in terms pattern may change
(for better or worse)!
(B) Helping undergraduates to understand the “symbolic” factorization” phase by
symbolically utilizing the Cholesky factorized Equations (6-7). This step is illustrated
in Figure 2, for which the “game player” will see (and also hear the computer
animated sound, and human voice) the non-zero terms (including fill-in terms) of the
original matrix [ A] to move to the new locations in the new/modified matrix [ A* ] .
(C) Helping undergraduates to understand the numerical factorization phase, by
numerically utilizing the same Cholesky factorized Equations (6-7).
(D) Teaching undergraduates to understand existing reordering concepts, or to discover
new reordering algorithms.
message” to a particular player who discovers a new “chess-like move” (or, swapping
node) strategies which are even better than RCM algorithms.
4. Initially, the player(s) will select the matrix size ( 8 × 8 , or larger is recommended),
and the percentage (50%, or larger is suggested) of zero-terms (or sparsity of the
matrix). Then, the START Game icon will be clicked by the player.
5. The player will then CLICK one of the selected node i (or equation) numbers
appearing on the computer screen. The player will see those nodes j which are
connected to node i (based on the given/generated matrix [ A] ). The player then has to
decide to swap node i with one of the possible node j . After confirming the player’s
decision, the outcomes/results will be announced by the computer animated human
voice, and the monetary-award will (or will not) be given to the players/learners,
accordingly. In this software, a maximum of $1,000,000 can be earned by the player,
and the exact dollar amount will be inversely proportional to the number of fill-in
terms occurred (based on the player’s decision on how to swap node i with another
node j ).
6. The next player will continue to play, with his/her move (meaning to swap the i th
node with the j th node) based on the current best non-zero terms pattern of the
matrix.
References
CHOLSEKY AND LDLT DECOMPOSITION
Topic Cholesky and LDLT Decomposition
Summary Textbook chapter of Cholesky and LDLT Decomposition
Major General Engineering
Authors Duc Nguyen
Date July 29, 2010
Web Site http://numericalmethods.eng.usf.edu