LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zhetrs_aa.f
Go to the documentation of this file.
1*> \brief \b ZHETRS_AA
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZHETRS_AA + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhetrs_aa.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhetrs_aa.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhetrs_aa.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
20* WORK, LWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER UPLO
24* INTEGER N, NRHS, LDA, LDB, LWORK, INFO
25* ..
26* .. Array Arguments ..
27* INTEGER IPIV( * )
28* COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
29* ..
30*
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> ZHETRS_AA solves a system of linear equations A*X = B with a complex
39*> hermitian matrix A using the factorization A = U**H*T*U or
40*> A = L*T*L**H computed by ZHETRF_AA.
41*> \endverbatim
42*
43* Arguments:
44* ==========
45*
46*> \param[in] UPLO
47*> \verbatim
48*> UPLO is CHARACTER*1
49*> Specifies whether the details of the factorization are stored
50*> as an upper or lower triangular matrix.
51*> = 'U': Upper triangular, form is A = U**H*T*U;
52*> = 'L': Lower triangular, form is A = L*T*L**H.
53*> \endverbatim
54*>
55*> \param[in] N
56*> \verbatim
57*> N is INTEGER
58*> The order of the matrix A. N >= 0.
59*> \endverbatim
60*>
61*> \param[in] NRHS
62*> \verbatim
63*> NRHS is INTEGER
64*> The number of right hand sides, i.e., the number of columns
65*> of the matrix B. NRHS >= 0.
66*> \endverbatim
67*>
68*> \param[in] A
69*> \verbatim
70*> A is COMPLEX*16 array, dimension (LDA,N)
71*> Details of factors computed by ZHETRF_AA.
72*> \endverbatim
73*>
74*> \param[in] LDA
75*> \verbatim
76*> LDA is INTEGER
77*> The leading dimension of the array A. LDA >= max(1,N).
78*> \endverbatim
79*>
80*> \param[in] IPIV
81*> \verbatim
82*> IPIV is INTEGER array, dimension (N)
83*> Details of the interchanges as computed by ZHETRF_AA.
84*> \endverbatim
85*>
86*> \param[in,out] B
87*> \verbatim
88*> B is COMPLEX*16 array, dimension (LDB,NRHS)
89*> On entry, the right hand side matrix B.
90*> On exit, the solution matrix X.
91*> \endverbatim
92*>
93*> \param[in] LDB
94*> \verbatim
95*> LDB is INTEGER
96*> The leading dimension of the array B. LDB >= max(1,N).
97*> \endverbatim
98*>
99*> \param[out] WORK
100*> \verbatim
101*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
102*> \endverbatim
103*>
104*> \param[in] LWORK
105*> \verbatim
106*> LWORK is INTEGER
107*> The dimension of the array WORK.
108*> If MIN(N,NRHS) = 0, LWORK >= 1, else LWORK >= 3*N-2.
109*>
110*> If LWORK = -1, then a workspace query is assumed; the routine
111*> only calculates the minimal size of the WORK array, returns
112*> this value as the first entry of the WORK array, and no error
113*> message related to LWORK is issued by XERBLA.
114*> \endverbatim
115*>
116*> \param[out] INFO
117*> \verbatim
118*> INFO is INTEGER
119*> = 0: successful exit
120*> < 0: if INFO = -i, the i-th argument had an illegal value
121*> \endverbatim
122*
123* Authors:
124* ========
125*
126*> \author Univ. of Tennessee
127*> \author Univ. of California Berkeley
128*> \author Univ. of Colorado Denver
129*> \author NAG Ltd.
130*
131*> \ingroup hetrs_aa
132*
133* =====================================================================
134 SUBROUTINE zhetrs_aa( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
135 $ WORK, LWORK, INFO )
136*
137* -- LAPACK computational routine --
138* -- LAPACK is a software package provided by Univ. of Tennessee, --
139* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
140*
141 IMPLICIT NONE
142*
143* .. Scalar Arguments ..
144 CHARACTER UPLO
145 INTEGER N, NRHS, LDA, LDB, LWORK, INFO
146* ..
147* .. Array Arguments ..
148 INTEGER IPIV( * )
149 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
150* ..
151*
152* =====================================================================
153*
154 COMPLEX*16 ONE
155 parameter( one = 1.0d+0 )
156* ..
157* .. Local Scalars ..
158 LOGICAL LQUERY, UPPER
159 INTEGER K, KP, LWKMIN
160* ..
161* .. External Functions ..
162 LOGICAL LSAME
163 EXTERNAL lsame
164* ..
165* .. External Subroutines ..
166 EXTERNAL zgtsv, zswap, ztrsm, zlacgv, zlacpy,
167 $ xerbla
168* ..
169* .. Intrinsic Functions ..
170 INTRINSIC min, max
171* ..
172* .. Executable Statements ..
173*
174 info = 0
175 upper = lsame( uplo, 'U' )
176 lquery = ( lwork.EQ.-1 )
177 IF( min( n, nrhs ).EQ.0 ) THEN
178 lwkmin = 1
179 ELSE
180 lwkmin = 3*n-2
181 END IF
182*
183 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
184 info = -1
185 ELSE IF( n.LT.0 ) THEN
186 info = -2
187 ELSE IF( nrhs.LT.0 ) THEN
188 info = -3
189 ELSE IF( lda.LT.max( 1, n ) ) THEN
190 info = -5
191 ELSE IF( ldb.LT.max( 1, n ) ) THEN
192 info = -8
193 ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery ) THEN
194 info = -10
195 END IF
196 IF( info.NE.0 ) THEN
197 CALL xerbla( 'ZHETRS_AA', -info )
198 RETURN
199 ELSE IF( lquery ) THEN
200 work( 1 ) = lwkmin
201 RETURN
202 END IF
203*
204* Quick return if possible
205*
206 IF( min( n, nrhs ).EQ.0 )
207 $ RETURN
208*
209 IF( upper ) THEN
210*
211* Solve A*X = B, where A = U**H*T*U.
212*
213* 1) Forward substitution with U**H
214*
215 IF( n.GT.1 ) THEN
216*
217* Pivot, P**T * B -> B
218*
219 DO k = 1, n
220 kp = ipiv( k )
221 IF( kp.NE.k )
222 $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
223 END DO
224*
225* Compute U**H \ B -> B [ (U**H \P**T * B) ]
226*
227 CALL ztrsm( 'L', 'U', 'C', 'U', n-1, nrhs, one, a( 1,
228 $ 2 ),
229 $ lda, b( 2, 1 ), ldb )
230 END IF
231*
232* 2) Solve with triangular matrix T
233*
234* Compute T \ B -> B [ T \ (U**H \P**T * B) ]
235*
236 CALL zlacpy( 'F', 1, n, a(1, 1), lda+1, work(n), 1 )
237 IF( n.GT.1 ) THEN
238 CALL zlacpy( 'F', 1, n-1, a( 1, 2 ), lda+1, work( 2*n ),
239 $ 1)
240 CALL zlacpy( 'F', 1, n-1, a( 1, 2 ), lda+1, work( 1 ),
241 $ 1 )
242 CALL zlacgv( n-1, work( 1 ), 1 )
243 END IF
244 CALL zgtsv( n, nrhs, work(1), work(n), work(2*n), b, ldb,
245 $ info )
246*
247* 3) Backward substitution with U
248*
249 IF( n.GT.1 ) THEN
250*
251* Compute U \ B -> B [ U \ (T \ (U**H \P**T * B) ) ]
252*
253 CALL ztrsm( 'L', 'U', 'N', 'U', n-1, nrhs, one, a( 1,
254 $ 2 ),
255 $ lda, b(2, 1), ldb)
256*
257* Pivot, P * B [ P * (U**H \ (T \ (U \P**T * B) )) ]
258*
259 DO k = n, 1, -1
260 kp = ipiv( k )
261 IF( kp.NE.k )
262 $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
263 END DO
264 END IF
265*
266 ELSE
267*
268* Solve A*X = B, where A = L*T*L**H.
269*
270* 1) Forward substitution with L
271*
272 IF( n.GT.1 ) THEN
273*
274* Pivot, P**T * B -> B
275*
276 DO k = 1, n
277 kp = ipiv( k )
278 IF( kp.NE.k )
279 $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
280 END DO
281*
282* Compute L \ B -> B [ (L \P**T * B) ]
283*
284 CALL ztrsm( 'L', 'L', 'N', 'U', n-1, nrhs, one, a( 2,
285 $ 1 ),
286 $ lda, b(2, 1), ldb)
287 END IF
288*
289* 2) Solve with triangular matrix T
290*
291* Compute T \ B -> B [ T \ (L \P**T * B) ]
292*
293 CALL zlacpy( 'F', 1, n, a(1, 1), lda+1, work(n), 1)
294 IF( n.GT.1 ) THEN
295 CALL zlacpy( 'F', 1, n-1, a( 2, 1 ), lda+1, work( 1 ),
296 $ 1)
297 CALL zlacpy( 'F', 1, n-1, a( 2, 1 ), lda+1, work( 2*n ),
298 $ 1)
299 CALL zlacgv( n-1, work( 2*n ), 1 )
300 END IF
301 CALL zgtsv(n, nrhs, work(1), work(n), work(2*n), b, ldb,
302 $ info)
303*
304* 3) Backward substitution with L**H
305*
306 IF( n.GT.1 ) THEN
307*
308* Compute L**H \ B -> B [ L**H \ (T \ (L \P**T * B) ) ]
309*
310 CALL ztrsm( 'L', 'L', 'C', 'U', n-1, nrhs, one, a( 2,
311 $ 1 ),
312 $ lda, b( 2, 1 ), ldb)
313*
314* Pivot, P * B [ P * (L**H \ (T \ (L \P**T * B) )) ]
315*
316 DO k = n, 1, -1
317 kp = ipiv( k )
318 IF( kp.NE.k )
319 $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
320 END DO
321 END IF
322*
323 END IF
324*
325 RETURN
326*
327* End of ZHETRS_AA
328*
329 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zgtsv(n, nrhs, dl, d, du, b, ldb, info)
ZGTSV computes the solution to system of linear equations A * X = B for GT matrices
Definition zgtsv.f:122
subroutine zhetrs_aa(uplo, n, nrhs, a, lda, ipiv, b, ldb, work, lwork, info)
ZHETRS_AA
Definition zhetrs_aa.f:136
subroutine zlacgv(n, x, incx)
ZLACGV conjugates a complex vector.
Definition zlacgv.f:72
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
Definition zlacpy.f:101
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP
Definition zswap.f:81
subroutine ztrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
ZTRSM
Definition ztrsm.f:180