LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine zhetrs2 ( 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  INFO 
)

ZHETRS2

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

Purpose:
 ZHETRS2 solves a system of linear equations A*X = B with a complex
 Hermitian matrix A using the factorization A = U*D*U**H or
 A = L*D*L**H computed by ZHETRF and converted by ZSYCONV.
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*D*U**H;
          = 'L':  Lower triangular, form is A = L*D*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)
          The block diagonal matrix D and the multipliers used to
          obtain the factor U or L as computed by ZHETRF.
[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 and the block structure of D
          as determined by ZHETRF.
[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 (N)
[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.
Date
June 2016

Definition at line 129 of file zhetrs2.f.

129 *
130 * -- LAPACK computational routine (version 3.6.1) --
131 * -- LAPACK is a software package provided by Univ. of Tennessee, --
132 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
133 * June 2016
134 *
135 * .. Scalar Arguments ..
136  CHARACTER uplo
137  INTEGER info, lda, ldb, n, nrhs
138 * ..
139 * .. Array Arguments ..
140  INTEGER ipiv( * )
141  COMPLEX*16 a( lda, * ), b( ldb, * ), work( * )
142 * ..
143 *
144 * =====================================================================
145 *
146 * .. Parameters ..
147  COMPLEX*16 one
148  parameter ( one = (1.0d+0,0.0d+0) )
149 * ..
150 * .. Local Scalars ..
151  LOGICAL upper
152  INTEGER i, iinfo, j, k, kp
153  DOUBLE PRECISION s
154  COMPLEX*16 ak, akm1, akm1k, bk, bkm1, denom
155 * ..
156 * .. External Functions ..
157  LOGICAL lsame
158  EXTERNAL lsame
159 * ..
160 * .. External Subroutines ..
161  EXTERNAL zlacgv, zscal, zsyconv, zswap, ztrsm, xerbla
162 * ..
163 * .. Intrinsic Functions ..
164  INTRINSIC dble, dconjg, max
165 * ..
166 * .. Executable Statements ..
167 *
168  info = 0
169  upper = lsame( uplo, 'U' )
170  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
171  info = -1
172  ELSE IF( n.LT.0 ) THEN
173  info = -2
174  ELSE IF( nrhs.LT.0 ) THEN
175  info = -3
176  ELSE IF( lda.LT.max( 1, n ) ) THEN
177  info = -5
178  ELSE IF( ldb.LT.max( 1, n ) ) THEN
179  info = -8
180  END IF
181  IF( info.NE.0 ) THEN
182  CALL xerbla( 'ZHETRS2', -info )
183  RETURN
184  END IF
185 *
186 * Quick return if possible
187 *
188  IF( n.EQ.0 .OR. nrhs.EQ.0 )
189  $ RETURN
190 *
191 * Convert A
192 *
193  CALL zsyconv( uplo, 'C', n, a, lda, ipiv, work, iinfo )
194 *
195  IF( upper ) THEN
196 *
197 * Solve A*X = B, where A = U*D*U**H.
198 *
199 * P**T * B
200  k=n
201  DO WHILE ( k .GE. 1 )
202  IF( ipiv( k ).GT.0 ) THEN
203 * 1 x 1 diagonal block
204 * Interchange rows K and IPIV(K).
205  kp = ipiv( k )
206  IF( kp.NE.k )
207  $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
208  k=k-1
209  ELSE
210 * 2 x 2 diagonal block
211 * Interchange rows K-1 and -IPIV(K).
212  kp = -ipiv( k )
213  IF( kp.EQ.-ipiv( k-1 ) )
214  $ CALL zswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
215  k=k-2
216  END IF
217  END DO
218 *
219 * Compute (U \P**T * B) -> B [ (U \P**T * B) ]
220 *
221  CALL ztrsm('L','U','N','U',n,nrhs,one,a,lda,b,ldb)
222 *
223 * Compute D \ B -> B [ D \ (U \P**T * B) ]
224 *
225  i=n
226  DO WHILE ( i .GE. 1 )
227  IF( ipiv(i) .GT. 0 ) THEN
228  s = dble( one ) / dble( a( i, i ) )
229  CALL zdscal( nrhs, s, b( i, 1 ), ldb )
230  ELSEIF ( i .GT. 1) THEN
231  IF ( ipiv(i-1) .EQ. ipiv(i) ) THEN
232  akm1k = work(i)
233  akm1 = a( i-1, i-1 ) / akm1k
234  ak = a( i, i ) / dconjg( akm1k )
235  denom = akm1*ak - one
236  DO 15 j = 1, nrhs
237  bkm1 = b( i-1, j ) / akm1k
238  bk = b( i, j ) / dconjg( akm1k )
239  b( i-1, j ) = ( ak*bkm1-bk ) / denom
240  b( i, j ) = ( akm1*bk-bkm1 ) / denom
241  15 CONTINUE
242  i = i - 1
243  ENDIF
244  ENDIF
245  i = i - 1
246  END DO
247 *
248 * Compute (U**H \ B) -> B [ U**H \ (D \ (U \P**T * B) ) ]
249 *
250  CALL ztrsm('L','U','C','U',n,nrhs,one,a,lda,b,ldb)
251 *
252 * P * B [ P * (U**H \ (D \ (U \P**T * B) )) ]
253 *
254  k=1
255  DO WHILE ( k .LE. n )
256  IF( ipiv( k ).GT.0 ) THEN
257 * 1 x 1 diagonal block
258 * Interchange rows K and IPIV(K).
259  kp = ipiv( k )
260  IF( kp.NE.k )
261  $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
262  k=k+1
263  ELSE
264 * 2 x 2 diagonal block
265 * Interchange rows K-1 and -IPIV(K).
266  kp = -ipiv( k )
267  IF( k .LT. n .AND. kp.EQ.-ipiv( k+1 ) )
268  $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
269  k=k+2
270  ENDIF
271  END DO
272 *
273  ELSE
274 *
275 * Solve A*X = B, where A = L*D*L**H.
276 *
277 * P**T * B
278  k=1
279  DO WHILE ( k .LE. n )
280  IF( ipiv( k ).GT.0 ) THEN
281 * 1 x 1 diagonal block
282 * Interchange rows K and IPIV(K).
283  kp = ipiv( k )
284  IF( kp.NE.k )
285  $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
286  k=k+1
287  ELSE
288 * 2 x 2 diagonal block
289 * Interchange rows K and -IPIV(K+1).
290  kp = -ipiv( k+1 )
291  IF( kp.EQ.-ipiv( k ) )
292  $ CALL zswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
293  k=k+2
294  ENDIF
295  END DO
296 *
297 * Compute (L \P**T * B) -> B [ (L \P**T * B) ]
298 *
299  CALL ztrsm('L','L','N','U',n,nrhs,one,a,lda,b,ldb)
300 *
301 * Compute D \ B -> B [ D \ (L \P**T * B) ]
302 *
303  i=1
304  DO WHILE ( i .LE. n )
305  IF( ipiv(i) .GT. 0 ) THEN
306  s = dble( one ) / dble( a( i, i ) )
307  CALL zdscal( nrhs, s, b( i, 1 ), ldb )
308  ELSE
309  akm1k = work(i)
310  akm1 = a( i, i ) / dconjg( akm1k )
311  ak = a( i+1, i+1 ) / akm1k
312  denom = akm1*ak - one
313  DO 25 j = 1, nrhs
314  bkm1 = b( i, j ) / dconjg( akm1k )
315  bk = b( i+1, j ) / akm1k
316  b( i, j ) = ( ak*bkm1-bk ) / denom
317  b( i+1, j ) = ( akm1*bk-bkm1 ) / denom
318  25 CONTINUE
319  i = i + 1
320  ENDIF
321  i = i + 1
322  END DO
323 *
324 * Compute (L**H \ B) -> B [ L**H \ (D \ (L \P**T * B) ) ]
325 *
326  CALL ztrsm('L','L','C','U',n,nrhs,one,a,lda,b,ldb)
327 *
328 * P * B [ P * (L**H \ (D \ (L \P**T * B) )) ]
329 *
330  k=n
331  DO WHILE ( k .GE. 1 )
332  IF( ipiv( k ).GT.0 ) THEN
333 * 1 x 1 diagonal block
334 * Interchange rows K and IPIV(K).
335  kp = ipiv( k )
336  IF( kp.NE.k )
337  $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
338  k=k-1
339  ELSE
340 * 2 x 2 diagonal block
341 * Interchange rows K-1 and -IPIV(K).
342  kp = -ipiv( k )
343  IF( k.GT.1 .AND. kp.EQ.-ipiv( k-1 ) )
344  $ CALL zswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
345  k=k-2
346  ENDIF
347  END DO
348 *
349  END IF
350 *
351 * Revert A
352 *
353  CALL zsyconv( uplo, 'R', n, a, lda, ipiv, work, iinfo )
354 *
355  RETURN
356 *
357 * End of ZHETRS2
358 *
subroutine zsyconv(UPLO, WAY, N, A, LDA, IPIV, E, INFO)
ZSYCONV
Definition: zsyconv.f:116
subroutine zswap(N, ZX, INCX, ZY, INCY)
ZSWAP
Definition: zswap.f:52
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine zdscal(N, DA, ZX, INCX)
ZDSCAL
Definition: zdscal.f:54
subroutine ztrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
ZTRSM
Definition: ztrsm.f:182
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine zscal(N, ZA, ZX, INCX)
ZSCAL
Definition: zscal.f:54
subroutine zlacgv(N, X, INCX)
ZLACGV conjugates a complex vector.
Definition: zlacgv.f:76

Here is the call graph for this function:

Here is the caller graph for this function: