LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ zhetrs_aa()

subroutine zhetrs_aa ( character uplo,
integer n,
integer nrhs,
complex*16, dimension( lda, * ) a,
integer lda,
integer, dimension( * ) ipiv,
complex*16, dimension( ldb, * ) b,
integer ldb,
complex*16, dimension( * ) work,
integer lwork,
integer info )

ZHETRS_AA

Download ZHETRS_AA + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> ZHETRS_AA solves a system of linear equations A*X = B with a complex
!> hermitian matrix A using the factorization A = U**H*T*U or
!> A = L*T*L**H computed by ZHETRF_AA.
!> 
Parameters
[in]UPLO
!>          UPLO is CHARACTER*1
!>          Specifies whether the details of the factorization are stored
!>          as an upper or lower triangular matrix.
!>          = 'U':  Upper triangular, form is A = U**H*T*U;
!>          = 'L':  Lower triangular, form is A = L*T*L**H.
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in]NRHS
!>          NRHS is INTEGER
!>          The number of right hand sides, i.e., the number of columns
!>          of the matrix B.  NRHS >= 0.
!> 
[in]A
!>          A is COMPLEX*16 array, dimension (LDA,N)
!>          Details of factors computed by ZHETRF_AA.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,N).
!> 
[in]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>          Details of the interchanges as computed by ZHETRF_AA.
!> 
[in,out]B
!>          B is COMPLEX*16 array, dimension (LDB,NRHS)
!>          On entry, the right hand side matrix B.
!>          On exit, the solution matrix X.
!> 
[in]LDB
!>          LDB is INTEGER
!>          The leading dimension of the array B.  LDB >= max(1,N).
!> 
[out]WORK
!>          WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK.
!>          If MIN(N,NRHS) = 0, LWORK >= 1, else LWORK >= 3*N-2.
!>
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the minimal size of the WORK array, returns
!>          this value as the first entry of the WORK array, and no error
!>          message related to LWORK is issued by XERBLA.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 134 of file zhetrs_aa.f.

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*
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 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
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
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
Here is the call graph for this function:
Here is the caller graph for this function: