Solving Sparse Linear System
Solving Sparse Linear System
LECTURE 17
AX = B
a 1 1 a 1 2 a 1 3 a 1 4 x 1 b1
a 2 1 a 2 2 a 2 3 a 2 4 x 2 b2
=
a 3 1 a 3 2 a 3 3 a 3 4 x 3 b3
a 4 1 a 4 2 a 4 3 a 4 4 x 4 b4
X = A –1 B
p. 17.1
CE 30125 - Lecture 2 - Fall 2004
• Typically it is more efficient to solve for X directly without solving for A –1 since
finding the inverse is an expensive (and less accurate) procedure
p. 2.2
CE 30125 - Lecture 17
Ak
x k = ---------
A
where
A k is the matrix A with its kth column replaced by vector B
• For each B vector, we must evaluate N + 1 determinants of size N where N defines the
size of the matrix A
N N
p. 17.3
CE 30125 - Lecture 2 - Fall 2004
where
I = specified value of i
J = specified value of j
cof a i j = – 1 i + j minor a i j
minor a i j = determinant of the sub-matrix obtained by deleting the ith row and the
jth column
a 1 1 a 1 2
A = = a 1 1 a 2 2 – a 2 1 a 1 2
a 2 1 a 2 2
p. 2.4
CE 30125 - Lecture 17
Example
a 1 1 a 1 2 a 1 3
det A = A = a 2 1 a 2 2 a 2 3
a 3 1 a 3 2 a 3 3
a 2 2 a 2 3 a 2 1 a 2 3
det A = a 1 1 – 1 1 + 1 + a 1 2 – 1 1 + 2
a 3 2 a 3 3 a 3 1 a 3 3
a 2 1 a 2 2
+ a 1 3 – 1 1 + 3
a 3 1 a 3 2
det A = a 1 1 +1 a 2 2 a 3 3 – a 3 2 a 2 3 + a 1 2 – 1 a 2 1 a 3 3 – a 3 1 a 2 3
+ a 1 3 +1 a 2 1 a 3 2 – a 3 1 a 2 2
p. 17.5
CE 30125 - Lecture 2 - Fall 2004
• Note that more efficient methods are available to compute the determinant of a matrix.
These methods are associated with alternative direct procedures.
2 2 system O 2 4 = O 16
p. 2.6
CE 30125 - Lecture 17
• Basic concept is to produce an upper or lower triangular matrix and to then use back-
ward or forward substitution to solve for the unknowns.
Example application
• Solve the system of equations
a 1 1 a 1 2 a 1 3 x 1 b1
a 2 1 a 2 2 a 2 3 x 2 = b 2
a 3 1 a 3 2 a 3 3 x 3 b3
p. 17.7
CE 30125 - Lecture 2 - Fall 2004
p. 2.8
CE 30125 - Lecture 17
• Finally divide row 3 by a'' 3 3 (pivot element) to complete the triangulation procedure
and results in the upper triangular matrix
p. 17.9
CE 30125 - Lecture 2 - Fall 2004
x 3 = b''' 3
• We can also produce a lower triangular matrix and use a forward substitution procedure
p. 2.10
CE 30125 - Lecture 17
1 0 0 0 x1 b 1
0 1 0 0 x2 b 2
=
0 0 1 0 x3 b 3
0 0 0 1 x4 b 4
p. 17.11
CE 30125 - Lecture 2 - Fall 2004
AA –1 I
1 0 0 0 0 0
0 1 0 0 0 0
where I = identity matrix = 0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
p. 2.12
CE 30125 - Lecture 17
AA –1 = I
AA –1 = I
IA –1 = I
A –1 = I
• The right hand side matrix, I , has been transformed into the inverted matrix
p. 17.13
CE 30125 - Lecture 2 - Fall 2004
• Notes:
• Inverting a diagonal matrix simply involves computing reciprocals
a 11 0 0
A = 0 a 22 0
0 0 a 33
1/a 11 0 0
A –1 = 0 1/a 22 0
0 0 1/a 33
AA –1 = I
p. 2.14
CE 30125 - Lecture 17
Banded matrices
• Have non-zero entries contained within a defined number of positions to the left and
right of the diagonal (bandwidth)
INSERT FIGURE NO. 122
halfbandwidth bandwidth
M + 1 =4 M
2
bandwidth M = 7
storage required = N2 storage required = NM
p. 17.15
CE 30125 - Lecture 2 - Fall 2004
• Examples:
p. 2.16
CE 30125 - Lecture 17
• Therefore save O N 2 /M 2 operations since we are not manipulating all the zeros outside
of the bands!
• Examples:
p. 17.17
CE 30125 - Lecture 2 - Fall 2004
• Substantial savings on both storage and computations if we use a banded storage mode
• Even greater savings (both storage and computations) are possible if the matrix A is
symmetrical
• Therefore if a ij = a ji we need only store and operate on half the bandwidth in a
banded matrix (half the matrix in a full storage mode matrix)
INSERT FIGURE NO. 123a
(M + 1)/2 (M + 1)/2
store
only half
p. 2.18
CE 30125 - Lecture 17
a66
p. 17.19
CE 30125 - Lecture 2 - Fall 2004
• Store all entries between skyline and diagonal into a vector as follows:
INSERT FIGURE NO. 124
A(12)
• Accounting procedure must be able to identify the location within the matrix of
elements stored in vector mode in A i Store locations of diagonal terms in A i
1
2
MaxA = 4
6
10
12
p. 2.20
CE 30125 - Lecture 17
• Savings in storage and computation time due to the elimination of the additional zeroes
e.g. storage savings:
N 2 = 36 M +1 7+1
-------------- N = ------------ 6 = 24 15
2 2
• Program COLSOL (Bathe and Wilson) available for skyline storage solution
p. 17.21
CE 30125 - Lecture 2 - Fall 2004
• As more pivot rows are processed, the number of times a pivot element has been modi-
fied increases.
• Sometimes a pivot element can become very small compared to the rest of the elements
in the pivot row
• Pivot element will be inaccurate due to roundoff
• When the pivot element divides the rest of the pivot row, large inaccurate numbers
result across the pivot row
• Pivot row now subtracts (after being multiplied) from all rows below the pivot row,
resulting in propagation of large errors throughout the matrix!
Partial pivoting
• Always look below the pivot element and pick the row with the largest value and switch
rows
p. 2.22
CE 30125 - Lecture 17
Complete pivoting
• Look at all columns and all rows to the right/below the pivot element and switch so that
the largest element possible is in the pivot position.
• For complete pivoting, you must change the order of the variable array
• increase accuracy
p. 17.23