5164
|
1 SUBROUTINE ZGTTRF( N, DL, D, DU, DU2, IPIV, INFO ) |
|
2 * |
7034
|
3 * -- LAPACK routine (version 3.1) -- |
|
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. |
|
5 * November 2006 |
5164
|
6 * |
|
7 * .. Scalar Arguments .. |
|
8 INTEGER INFO, N |
|
9 * .. |
|
10 * .. Array Arguments .. |
|
11 INTEGER IPIV( * ) |
|
12 COMPLEX*16 D( * ), DL( * ), DU( * ), DU2( * ) |
|
13 * .. |
|
14 * |
|
15 * Purpose |
|
16 * ======= |
|
17 * |
|
18 * ZGTTRF computes an LU factorization of a complex tridiagonal matrix A |
|
19 * using elimination with partial pivoting and row interchanges. |
|
20 * |
|
21 * The factorization has the form |
|
22 * A = L * U |
|
23 * where L is a product of permutation and unit lower bidiagonal |
|
24 * matrices and U is upper triangular with nonzeros in only the main |
|
25 * diagonal and first two superdiagonals. |
|
26 * |
|
27 * Arguments |
|
28 * ========= |
|
29 * |
|
30 * N (input) INTEGER |
7034
|
31 * The order of the matrix A. |
5164
|
32 * |
|
33 * DL (input/output) COMPLEX*16 array, dimension (N-1) |
7034
|
34 * On entry, DL must contain the (n-1) sub-diagonal elements of |
5164
|
35 * A. |
7034
|
36 * |
5164
|
37 * On exit, DL is overwritten by the (n-1) multipliers that |
|
38 * define the matrix L from the LU factorization of A. |
|
39 * |
|
40 * D (input/output) COMPLEX*16 array, dimension (N) |
|
41 * On entry, D must contain the diagonal elements of A. |
7034
|
42 * |
5164
|
43 * On exit, D is overwritten by the n diagonal elements of the |
|
44 * upper triangular matrix U from the LU factorization of A. |
|
45 * |
|
46 * DU (input/output) COMPLEX*16 array, dimension (N-1) |
7034
|
47 * On entry, DU must contain the (n-1) super-diagonal elements |
5164
|
48 * of A. |
7034
|
49 * |
5164
|
50 * On exit, DU is overwritten by the (n-1) elements of the first |
7034
|
51 * super-diagonal of U. |
5164
|
52 * |
|
53 * DU2 (output) COMPLEX*16 array, dimension (N-2) |
|
54 * On exit, DU2 is overwritten by the (n-2) elements of the |
7034
|
55 * second super-diagonal of U. |
5164
|
56 * |
|
57 * IPIV (output) INTEGER array, dimension (N) |
|
58 * The pivot indices; for 1 <= i <= n, row i of the matrix was |
|
59 * interchanged with row IPIV(i). IPIV(i) will always be either |
|
60 * i or i+1; IPIV(i) = i indicates a row interchange was not |
|
61 * required. |
|
62 * |
|
63 * INFO (output) INTEGER |
|
64 * = 0: successful exit |
7034
|
65 * < 0: if INFO = -k, the k-th argument had an illegal value |
|
66 * > 0: if INFO = k, U(k,k) is exactly zero. The factorization |
5164
|
67 * has been completed, but the factor U is exactly |
|
68 * singular, and division by zero will occur if it is used |
|
69 * to solve a system of equations. |
|
70 * |
|
71 * ===================================================================== |
|
72 * |
7034
|
73 * .. Parameters .. |
|
74 DOUBLE PRECISION ZERO |
|
75 PARAMETER ( ZERO = 0.0D+0 ) |
|
76 * .. |
5164
|
77 * .. Local Scalars .. |
|
78 INTEGER I |
|
79 COMPLEX*16 FACT, TEMP, ZDUM |
|
80 * .. |
|
81 * .. External Subroutines .. |
|
82 EXTERNAL XERBLA |
|
83 * .. |
7034
|
84 * .. Intrinsic Functions .. |
|
85 INTRINSIC ABS, DBLE, DIMAG |
5164
|
86 * .. |
|
87 * .. Statement Functions .. |
|
88 DOUBLE PRECISION CABS1 |
|
89 * .. |
|
90 * .. Statement Function definitions .. |
|
91 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) ) |
|
92 * .. |
|
93 * .. Executable Statements .. |
|
94 * |
|
95 INFO = 0 |
|
96 IF( N.LT.0 ) THEN |
|
97 INFO = -1 |
|
98 CALL XERBLA( 'ZGTTRF', -INFO ) |
|
99 RETURN |
|
100 END IF |
|
101 * |
|
102 * Quick return if possible |
|
103 * |
|
104 IF( N.EQ.0 ) |
|
105 $ RETURN |
|
106 * |
7034
|
107 * Initialize IPIV(i) = i and DU2(i) = 0 |
5164
|
108 * |
|
109 DO 10 I = 1, N |
|
110 IPIV( I ) = I |
|
111 10 CONTINUE |
7034
|
112 DO 20 I = 1, N - 2 |
|
113 DU2( I ) = ZERO |
|
114 20 CONTINUE |
5164
|
115 * |
7034
|
116 DO 30 I = 1, N - 2 |
|
117 IF( CABS1( D( I ) ).GE.CABS1( DL( I ) ) ) THEN |
5164
|
118 * |
|
119 * No row interchange required, eliminate DL(I) |
|
120 * |
7034
|
121 IF( CABS1( D( I ) ).NE.ZERO ) THEN |
|
122 FACT = DL( I ) / D( I ) |
|
123 DL( I ) = FACT |
|
124 D( I+1 ) = D( I+1 ) - FACT*DU( I ) |
|
125 END IF |
5164
|
126 ELSE |
|
127 * |
|
128 * Interchange rows I and I+1, eliminate DL(I) |
|
129 * |
|
130 FACT = D( I ) / DL( I ) |
|
131 D( I ) = DL( I ) |
|
132 DL( I ) = FACT |
|
133 TEMP = DU( I ) |
|
134 DU( I ) = D( I+1 ) |
|
135 D( I+1 ) = TEMP - FACT*D( I+1 ) |
7034
|
136 DU2( I ) = DU( I+1 ) |
|
137 DU( I+1 ) = -FACT*DU( I+1 ) |
|
138 IPIV( I ) = I + 1 |
5164
|
139 END IF |
7034
|
140 30 CONTINUE |
|
141 IF( N.GT.1 ) THEN |
|
142 I = N - 1 |
|
143 IF( CABS1( D( I ) ).GE.CABS1( DL( I ) ) ) THEN |
|
144 IF( CABS1( D( I ) ).NE.ZERO ) THEN |
|
145 FACT = DL( I ) / D( I ) |
|
146 DL( I ) = FACT |
|
147 D( I+1 ) = D( I+1 ) - FACT*DU( I ) |
|
148 END IF |
|
149 ELSE |
|
150 FACT = D( I ) / DL( I ) |
|
151 D( I ) = DL( I ) |
|
152 DL( I ) = FACT |
|
153 TEMP = DU( I ) |
|
154 DU( I ) = D( I+1 ) |
|
155 D( I+1 ) = TEMP - FACT*D( I+1 ) |
|
156 IPIV( I ) = I + 1 |
|
157 END IF |
5164
|
158 END IF |
|
159 * |
7034
|
160 * Check for a zero on the diagonal of U. |
|
161 * |
|
162 DO 40 I = 1, N |
|
163 IF( CABS1( D( I ) ).EQ.ZERO ) THEN |
|
164 INFO = I |
|
165 GO TO 50 |
|
166 END IF |
|
167 40 CONTINUE |
|
168 50 CONTINUE |
|
169 * |
5164
|
170 RETURN |
|
171 * |
|
172 * End of ZGTTRF |
|
173 * |
|
174 END |