You are on page 1of 4

3.4.

Method of LU decomposition

To solve for the matrices L and U for given matrix A, let us write the i, j th element of equation (3.40). In general, the element aij can be represented as (from equation (3.40)),

i1 1j + i2 2j + up to appropriate term = aij

(3.47)

The number of terms in the sum of equation (3.47) depends on whether i or j is the smaller number. We have in fact three distinct cases:

i < j; i = j; i > j;

i1 1j + i2 2j + + ii ij = aij i1 1j + i2 2j + + ii jj = aij i1 1j + i2 2j + + ij jj = aij

(3.48) (3.49) (3.50)

In equations (3.48)-(3.50), total N 2 equations are available for a total of (N 2 + N ) unknown and (the diagonals terms being repeated twice). As the number of unknown quantities is greater than the number of equations, we need to specify N of the unknown quantities arbitrarily and then the remaining unknown quantities can be solved. In fact, it is always possible to take

ii = 1;

i = 1, 2, N

(3.51)

With the condition of equation (3.51), an elegant procedure called Crouts algorithm quite easily solves for the N 2 unknown and by just rearranging the equations in a certain order. The algorithm is as follows: step 1: Set ii = 1 for i = 1, 2, 3 N . step 2: For each j = 1, 2, 3 N , perform the following operation: a) For i = 1, 2, 3 N solve for ij as

ij = aij

i 1 k =1

ik kj

(3.52)

Note: when i = 1, the summation term in equation (3.52) is taken to be zero. b) For i = j + 1, j + 2, N solve for ij as;
j 1 1 ij = aij ik kj jj k =1

(3.53)

These rst and second operations both need to be carried out before going to next value of j. 95

3.4.2

Example of LU decomposition

3 2 7 Decompose the matrix A = 2 3 1 in LU form through Crouts algorithm. 3 4 1 3 2 7 0 11 12 13 11 0 = 21 22 0 0 22 23 Solution: Let A = 2 3 1 3 4 1 31 32 33 0 0 33 Applying Crouts algorithm; 11 = 1; 22 = 1; 33 = 1; For j = 1; i = 1 11 = a11 = 3; 1 (a21 0) = i = 2 21 = 11 1 i = 3 31 = (a31 0) = 11
For j = 2;

2 ; 3 3 = 1; 3

5 i = 2 22 = a22 21 12 = ; 3 6 1 (a32 31 12 ) = ; i = 3 32 = 22 5
For j = 3;

i = 1 12 = a12 = 2;

i = 1 13 = a13 = 7; i = 2 23 = a23 21 13 =

11 ; 13

8 i = 3 33 = a33 31 13 32 23 = ; 5 3 2 7 1 0 0 7 3 2 Hence, 2 3 1 = 2 3 1 0 0 5 3 11 3 3 4 1 1 6 5 1 0 0 8 5

3.5

Storage schemes for sparse matrices

There are several methods available in the literature for storing a sparse matrix. Some of these schemes are described here. 96

Random packing: In this method, every non-zero element of the matrix is stored in a primary array while its row and column indices are stored in two secondary arrays. As each element in individually identied, the elements can be stored in a random manner. For example, the sparse matrixes shown in equation (3.54) are stored in one primary array and two secondary arrays as shown below.

0 0 0 0 0 A= 0 2.67 0 3.12 0 1.25 0.29 0 0 2.31


Primary array (elements) X = Secondary array (row indices) i = Secondary array (column indices) j = {0.29 {3 {2 3.12 2 5 -1.25 2.67 3 2 1 3 2.31 0} 3 0} 5 0}

(3.54)

In the above, the zero at the end of each array denotes the termination of the array.

Systematic packing: In case the elements of a sparse matrix are read or constructed or sorted in a systematic order, then there is no need to adopt both row and column indices for each element. Instead some alternative, more ecient schemes can be adopted as described below. a) The use of row address: In this scheme, the index of rst non-zero element in each row is specied in a separate integer array. As an example, for the matrix A in equation (3.54) the elements can be represented as, Real array (elements) = {2.67 Integer array JA = {3 Integer array IST = {1 3.12 5 1 -1.25 1 3 0.29 2 6 2.31} 5} }

In this case, the array of row address IST has been constructed such that the number of non-zero elements in row i is IST(I+1)-IST(I). Thus, for a matrix with m rows, the array IST will have (m+1) entries. For example, from the array IST, the number of non-zero elements in 1st row of the matrix A is IST(2) - IST(1) = 1 - 1 = 0, which is indeed true as observed from equation (3.54). Similarly, the array IST indicates that the number of non-zero elements in 2nd row of the matrix A is IST(3) - IST(2) = 3 - 1 = 2 and from the rst two elements of the array JA, these two elements are located at columns 3 and 5 of the matrix whereas the elements themselves are given by the rst two elements of the real array (2.67 and 3.12) (which is again true from equation (3.54)). In a similar way, the elements and the locations of the elements in the third row of the matrix A can easily be identied from the above three arrays. Moreover, please note that, as the number of rows in the matrix A is 3, the total number of entries in array IST is 4.

97

b) The use of dummy variables: In this scheme, the integer array IST is not used. Instead, dummy variables are introduced in the array JA itself to indicate the beginning of each row and the end of the matrix. For example, a zero entry (except the last one) in the array JA could indicate the presence of dummy variables and the dummy variables itself could specify the row number. Moreover, the non-zero elements would indicate the column number of the elements. Also, as before, the zero at the end of the array indicates the termination of the list. Hence the matrix A of equation (3.54) in this scheme looks like Real array (elements) Integer array JA = {2 2.67 = {0 3 3.12 3 5 0 -1.25 1 0.29 2 2.31 0} 5 0}

c) Compound identiers: In the random packing scheme it in possible to reduce the storage requirement by combining the two indices for each element so that these can be held in one integer storage. A suitable compound identier could be (n i + j ) where n is an integer higher than the number of columns in the matrix and (i, j ) denote the position of the non-zero element in the matrix. For example, the matrix A in equation (3.54) could look like Real array (elements) Integer array JA = = {2.67 {2003 3.12 -1.25 2005 3001 0.29 3002 2.31 3005 0} 9999}

In the above, n has been chosen to be equal to 1000. Also, in the real array, the entry zero indicates the end of the array and the corresponding entry in the integer array is 9999 (to signies the end of the integer array). However, unless compound identiers yield necessary or highly desirable storage saving, it should not be used because of the following reasons: i) Extra programming would be required to interpret the identiers correctly. ii) It should not be used for matrices whose order is so large that integer register overow results. d) The use of mixed arrays: It is possible to use a single array to store both the non-zero elements of the matrix and the identiers. For example, the matrix A in equation (3.54) could be stored as, Real array (B) = {-2 3 2.67 5 3.12 -3 1 -1.25 2 0.29 5 2.31 0}

In the above scheme, each non-zero element is preceded by its column number and each non-zero row is preceded by the negative of the corresponding row number. With this discussion, we are now at the and of our study of sparse linear systems. From the next lecture, we will start the discussion of short circuit analysis methods.

98

You might also like