LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine chetrs2 ( character  UPLO,
integer  N,
integer  NRHS,
complex, dimension( lda, * )  A,
integer  LDA,
integer, dimension( * )  IPIV,
complex, dimension( ldb, * )  B,
integer  LDB,
complex, dimension( * )  WORK,
integer  INFO 
)

CHETRS2

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

Purpose:
 CHETRS2 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 CHETRF and converted by CSYCONV.
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 array, dimension (LDA,N)
          The block diagonal matrix D and the multipliers used to
          obtain the factor U or L as computed by CHETRF.
[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 CHETRF.
[in,out]B
          B is COMPLEX 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 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
November 2011

Definition at line 129 of file chetrs2.f.

129 *
130 * -- LAPACK computational routine (version 3.4.0) --
131 * -- LAPACK is a software package provided by Univ. of Tennessee, --
132 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
133 * November 2011
134 *
135 * .. Scalar Arguments ..
136  CHARACTER uplo
137  INTEGER info, lda, ldb, n, nrhs
138 * ..
139 * .. Array Arguments ..
140  INTEGER ipiv( * )
141  COMPLEX a( lda, * ), b( ldb, * ), work( * )
142 * ..
143 *
144 * =====================================================================
145 *
146 * .. Parameters ..
147  COMPLEX one
148  parameter ( one = (1.0e+0,0.0e+0) )
149 * ..
150 * .. Local Scalars ..
151  LOGICAL upper
152  INTEGER i, iinfo, j, k, kp
153  REAL s
154  COMPLEX ak, akm1, akm1k, bk, bkm1, denom
155 * ..
156 * .. External Functions ..
157  LOGICAL lsame
158  EXTERNAL lsame
159 * ..
160 * .. External Subroutines ..
161  EXTERNAL cscal, csyconv, cswap, ctrsm, xerbla
162 * ..
163 * .. Intrinsic Functions ..
164  INTRINSIC conjg, max, real
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( 'CHETRS2', -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 csyconv( 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 cswap( 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 cswap( 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 ctrsm('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 = REAL( ONE ) / REAL( A( I, I ) )
229  CALL csscal( 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 ) / conjg( akm1k )
235  denom = akm1*ak - one
236  DO 15 j = 1, nrhs
237  bkm1 = b( i-1, j ) / akm1k
238  bk = b( i, j ) / conjg( 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 ctrsm('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 cswap( 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 cswap( 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 cswap( 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 cswap( 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 ctrsm('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 = REAL( ONE ) / REAL( A( I, I ) )
307  CALL csscal( nrhs, s, b( i, 1 ), ldb )
308  ELSE
309  akm1k = work(i)
310  akm1 = a( i, i ) / conjg( 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 ) / conjg( 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 ctrsm('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 cswap( 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 cswap( 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 csyconv( uplo, 'R', n, a, lda, ipiv, work, iinfo )
354 *
355  RETURN
356 *
357 * End of CHETRS2
358 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine cscal(N, CA, CX, INCX)
CSCAL
Definition: cscal.f:54
subroutine ctrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
CTRSM
Definition: ctrsm.f:182
subroutine csyconv(UPLO, WAY, N, A, LDA, IPIV, E, INFO)
CSYCONV
Definition: csyconv.f:116
subroutine cswap(N, CX, INCX, CY, INCY)
CSWAP
Definition: cswap.f:52
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine csscal(N, SA, CX, INCX)
CSSCAL
Definition: csscal.f:54

Here is the call graph for this function:

Here is the caller graph for this function: