5164
|
1 SUBROUTINE ZPTTS2( IUPLO, N, NRHS, D, E, B, LDB ) |
|
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 IUPLO, LDB, N, NRHS |
|
9 * .. |
|
10 * .. Array Arguments .. |
|
11 DOUBLE PRECISION D( * ) |
|
12 COMPLEX*16 B( LDB, * ), E( * ) |
|
13 * .. |
|
14 * |
|
15 * Purpose |
|
16 * ======= |
|
17 * |
|
18 * ZPTTS2 solves a tridiagonal system of the form |
|
19 * A * X = B |
|
20 * using the factorization A = U'*D*U or A = L*D*L' computed by ZPTTRF. |
|
21 * D is a diagonal matrix specified in the vector D, U (or L) is a unit |
|
22 * bidiagonal matrix whose superdiagonal (subdiagonal) is specified in |
|
23 * the vector E, and X and B are N by NRHS matrices. |
|
24 * |
|
25 * Arguments |
|
26 * ========= |
|
27 * |
|
28 * IUPLO (input) INTEGER |
|
29 * Specifies the form of the factorization and whether the |
|
30 * vector E is the superdiagonal of the upper bidiagonal factor |
|
31 * U or the subdiagonal of the lower bidiagonal factor L. |
|
32 * = 1: A = U'*D*U, E is the superdiagonal of U |
|
33 * = 0: A = L*D*L', E is the subdiagonal of L |
|
34 * |
|
35 * N (input) INTEGER |
|
36 * The order of the tridiagonal matrix A. N >= 0. |
|
37 * |
|
38 * NRHS (input) INTEGER |
|
39 * The number of right hand sides, i.e., the number of columns |
|
40 * of the matrix B. NRHS >= 0. |
|
41 * |
|
42 * D (input) DOUBLE PRECISION array, dimension (N) |
|
43 * The n diagonal elements of the diagonal matrix D from the |
|
44 * factorization A = U'*D*U or A = L*D*L'. |
|
45 * |
|
46 * E (input) COMPLEX*16 array, dimension (N-1) |
|
47 * If IUPLO = 1, the (n-1) superdiagonal elements of the unit |
|
48 * bidiagonal factor U from the factorization A = U'*D*U. |
|
49 * If IUPLO = 0, the (n-1) subdiagonal elements of the unit |
|
50 * bidiagonal factor L from the factorization A = L*D*L'. |
|
51 * |
|
52 * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) |
|
53 * On entry, the right hand side vectors B for the system of |
|
54 * linear equations. |
|
55 * On exit, the solution vectors, X. |
|
56 * |
|
57 * LDB (input) INTEGER |
|
58 * The leading dimension of the array B. LDB >= max(1,N). |
|
59 * |
|
60 * ===================================================================== |
|
61 * |
|
62 * .. Local Scalars .. |
|
63 INTEGER I, J |
|
64 * .. |
|
65 * .. External Subroutines .. |
|
66 EXTERNAL ZDSCAL |
|
67 * .. |
|
68 * .. Intrinsic Functions .. |
|
69 INTRINSIC DCONJG |
|
70 * .. |
|
71 * .. Executable Statements .. |
|
72 * |
|
73 * Quick return if possible |
|
74 * |
|
75 IF( N.LE.1 ) THEN |
|
76 IF( N.EQ.1 ) |
|
77 $ CALL ZDSCAL( NRHS, 1.D0 / D( 1 ), B, LDB ) |
|
78 RETURN |
|
79 END IF |
|
80 * |
|
81 IF( IUPLO.EQ.1 ) THEN |
|
82 * |
|
83 * Solve A * X = B using the factorization A = U'*D*U, |
|
84 * overwriting each right hand side vector with its solution. |
|
85 * |
|
86 IF( NRHS.LE.2 ) THEN |
|
87 J = 1 |
|
88 10 CONTINUE |
|
89 * |
|
90 * Solve U' * x = b. |
|
91 * |
|
92 DO 20 I = 2, N |
|
93 B( I, J ) = B( I, J ) - B( I-1, J )*DCONJG( E( I-1 ) ) |
|
94 20 CONTINUE |
|
95 * |
|
96 * Solve D * U * x = b. |
|
97 * |
|
98 DO 30 I = 1, N |
|
99 B( I, J ) = B( I, J ) / D( I ) |
|
100 30 CONTINUE |
|
101 DO 40 I = N - 1, 1, -1 |
|
102 B( I, J ) = B( I, J ) - B( I+1, J )*E( I ) |
|
103 40 CONTINUE |
|
104 IF( J.LT.NRHS ) THEN |
|
105 J = J + 1 |
|
106 GO TO 10 |
|
107 END IF |
|
108 ELSE |
|
109 DO 70 J = 1, NRHS |
|
110 * |
|
111 * Solve U' * x = b. |
|
112 * |
|
113 DO 50 I = 2, N |
|
114 B( I, J ) = B( I, J ) - B( I-1, J )*DCONJG( E( I-1 ) ) |
|
115 50 CONTINUE |
|
116 * |
|
117 * Solve D * U * x = b. |
|
118 * |
|
119 B( N, J ) = B( N, J ) / D( N ) |
|
120 DO 60 I = N - 1, 1, -1 |
|
121 B( I, J ) = B( I, J ) / D( I ) - B( I+1, J )*E( I ) |
|
122 60 CONTINUE |
|
123 70 CONTINUE |
|
124 END IF |
|
125 ELSE |
|
126 * |
|
127 * Solve A * X = B using the factorization A = L*D*L', |
|
128 * overwriting each right hand side vector with its solution. |
|
129 * |
|
130 IF( NRHS.LE.2 ) THEN |
|
131 J = 1 |
|
132 80 CONTINUE |
|
133 * |
|
134 * Solve L * x = b. |
|
135 * |
|
136 DO 90 I = 2, N |
|
137 B( I, J ) = B( I, J ) - B( I-1, J )*E( I-1 ) |
|
138 90 CONTINUE |
|
139 * |
|
140 * Solve D * L' * x = b. |
|
141 * |
|
142 DO 100 I = 1, N |
|
143 B( I, J ) = B( I, J ) / D( I ) |
|
144 100 CONTINUE |
|
145 DO 110 I = N - 1, 1, -1 |
|
146 B( I, J ) = B( I, J ) - B( I+1, J )*DCONJG( E( I ) ) |
|
147 110 CONTINUE |
|
148 IF( J.LT.NRHS ) THEN |
|
149 J = J + 1 |
|
150 GO TO 80 |
|
151 END IF |
|
152 ELSE |
|
153 DO 140 J = 1, NRHS |
|
154 * |
|
155 * Solve L * x = b. |
|
156 * |
|
157 DO 120 I = 2, N |
|
158 B( I, J ) = B( I, J ) - B( I-1, J )*E( I-1 ) |
|
159 120 CONTINUE |
|
160 * |
|
161 * Solve D * L' * x = b. |
|
162 * |
|
163 B( N, J ) = B( N, J ) / D( N ) |
|
164 DO 130 I = N - 1, 1, -1 |
|
165 B( I, J ) = B( I, J ) / D( I ) - |
|
166 $ B( I+1, J )*DCONJG( E( I ) ) |
|
167 130 CONTINUE |
|
168 140 CONTINUE |
|
169 END IF |
|
170 END IF |
|
171 * |
|
172 RETURN |
|
173 * |
|
174 * End of ZPTTS2 |
|
175 * |
|
176 END |