LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
dsytrs2.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dsytrs2 (UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK, INFO)
 DSYTRS2 More...
 

Function/Subroutine Documentation

subroutine dsytrs2 ( character  UPLO,
integer  N,
integer  NRHS,
double precision, dimension( lda, * )  A,
integer  LDA,
integer, dimension( * )  IPIV,
double precision, dimension( ldb, * )  B,
integer  LDB,
double precision, dimension( * )  WORK,
integer  INFO 
)

DSYTRS2

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

Purpose:
 DSYTRS2 solves a system of linear equations A*X = B with a real
 symmetric matrix A using the factorization A = U*D*U**T or
 A = L*D*L**T computed by DSYTRF and converted by DSYCONV.
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**T;
          = 'L':  Lower triangular, form is A = L*D*L**T.
[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 DOUBLE PRECISION array, dimension (LDA,N)
          The block diagonal matrix D and the multipliers used to
          obtain the factor U or L as computed by DSYTRF.
[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 DSYTRF.
[in,out]B
          B is DOUBLE PRECISION 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 REAL 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 dsytrs2.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  DOUBLE PRECISION a( lda, * ), b( ldb, * ), work( * )
142 * ..
143 *
144 * =====================================================================
145 *
146 * .. Parameters ..
147  DOUBLE PRECISION one
148  parameter( one = 1.0d+0 )
149 * ..
150 * .. Local Scalars ..
151  LOGICAL upper
152  INTEGER i, iinfo, j, k, kp
153  DOUBLE PRECISION ak, akm1, akm1k, bk, bkm1, denom
154 * ..
155 * .. External Functions ..
156  LOGICAL lsame
157  EXTERNAL lsame
158 * ..
159 * .. External Subroutines ..
160  EXTERNAL dscal, dsyconv, dswap, dtrsm, xerbla
161 * ..
162 * .. Intrinsic Functions ..
163  INTRINSIC max
164 * ..
165 * .. Executable Statements ..
166 *
167  info = 0
168  upper = lsame( uplo, 'U' )
169  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
170  info = -1
171  ELSE IF( n.LT.0 ) THEN
172  info = -2
173  ELSE IF( nrhs.LT.0 ) THEN
174  info = -3
175  ELSE IF( lda.LT.max( 1, n ) ) THEN
176  info = -5
177  ELSE IF( ldb.LT.max( 1, n ) ) THEN
178  info = -8
179  END IF
180  IF( info.NE.0 ) THEN
181  CALL xerbla( 'DSYTRS2', -info )
182  RETURN
183  END IF
184 *
185 * Quick return if possible
186 *
187  IF( n.EQ.0 .OR. nrhs.EQ.0 )
188  $ RETURN
189 *
190 * Convert A
191 *
192  CALL dsyconv( uplo, 'C', n, a, lda, ipiv, work, iinfo )
193 *
194  IF( upper ) THEN
195 *
196 * Solve A*X = B, where A = U*D*U**T.
197 *
198 * P**T * B
199  k=n
200  DO WHILE ( k .GE. 1 )
201  IF( ipiv( k ).GT.0 ) THEN
202 * 1 x 1 diagonal block
203 * Interchange rows K and IPIV(K).
204  kp = ipiv( k )
205  IF( kp.NE.k )
206  $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
207  k=k-1
208  ELSE
209 * 2 x 2 diagonal block
210 * Interchange rows K-1 and -IPIV(K).
211  kp = -ipiv( k )
212  IF( kp.EQ.-ipiv( k-1 ) )
213  $ CALL dswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
214  k=k-2
215  END IF
216  END DO
217 *
218 * Compute (U \P**T * B) -> B [ (U \P**T * B) ]
219 *
220  CALL dtrsm('L','U','N','U',n,nrhs,one,a,lda,b,ldb)
221 *
222 * Compute D \ B -> B [ D \ (U \P**T * B) ]
223 *
224  i=n
225  DO WHILE ( i .GE. 1 )
226  IF( ipiv(i) .GT. 0 ) THEN
227  CALL dscal( nrhs, one / a( i, i ), b( i, 1 ), ldb )
228  ELSEIF ( i .GT. 1) THEN
229  IF ( ipiv(i-1) .EQ. ipiv(i) ) THEN
230  akm1k = work(i)
231  akm1 = a( i-1, i-1 ) / akm1k
232  ak = a( i, i ) / akm1k
233  denom = akm1*ak - one
234  DO 15 j = 1, nrhs
235  bkm1 = b( i-1, j ) / akm1k
236  bk = b( i, j ) / akm1k
237  b( i-1, j ) = ( ak*bkm1-bk ) / denom
238  b( i, j ) = ( akm1*bk-bkm1 ) / denom
239  15 CONTINUE
240  i = i - 1
241  ENDIF
242  ENDIF
243  i = i - 1
244  END DO
245 *
246 * Compute (U**T \ B) -> B [ U**T \ (D \ (U \P**T * B) ) ]
247 *
248  CALL dtrsm('L','U','T','U',n,nrhs,one,a,lda,b,ldb)
249 *
250 * P * B [ P * (U**T \ (D \ (U \P**T * B) )) ]
251 *
252  k=1
253  DO WHILE ( k .LE. n )
254  IF( ipiv( k ).GT.0 ) THEN
255 * 1 x 1 diagonal block
256 * Interchange rows K and IPIV(K).
257  kp = ipiv( k )
258  IF( kp.NE.k )
259  $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
260  k=k+1
261  ELSE
262 * 2 x 2 diagonal block
263 * Interchange rows K-1 and -IPIV(K).
264  kp = -ipiv( k )
265  IF( k .LT. n .AND. kp.EQ.-ipiv( k+1 ) )
266  $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
267  k=k+2
268  ENDIF
269  END DO
270 *
271  ELSE
272 *
273 * Solve A*X = B, where A = L*D*L**T.
274 *
275 * P**T * B
276  k=1
277  DO WHILE ( k .LE. n )
278  IF( ipiv( k ).GT.0 ) THEN
279 * 1 x 1 diagonal block
280 * Interchange rows K and IPIV(K).
281  kp = ipiv( k )
282  IF( kp.NE.k )
283  $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
284  k=k+1
285  ELSE
286 * 2 x 2 diagonal block
287 * Interchange rows K and -IPIV(K+1).
288  kp = -ipiv( k+1 )
289  IF( kp.EQ.-ipiv( k ) )
290  $ CALL dswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
291  k=k+2
292  ENDIF
293  END DO
294 *
295 * Compute (L \P**T * B) -> B [ (L \P**T * B) ]
296 *
297  CALL dtrsm('L','L','N','U',n,nrhs,one,a,lda,b,ldb)
298 *
299 * Compute D \ B -> B [ D \ (L \P**T * B) ]
300 *
301  i=1
302  DO WHILE ( i .LE. n )
303  IF( ipiv(i) .GT. 0 ) THEN
304  CALL dscal( nrhs, one / a( i, i ), b( i, 1 ), ldb )
305  ELSE
306  akm1k = work(i)
307  akm1 = a( i, i ) / akm1k
308  ak = a( i+1, i+1 ) / akm1k
309  denom = akm1*ak - one
310  DO 25 j = 1, nrhs
311  bkm1 = b( i, j ) / akm1k
312  bk = b( i+1, j ) / akm1k
313  b( i, j ) = ( ak*bkm1-bk ) / denom
314  b( i+1, j ) = ( akm1*bk-bkm1 ) / denom
315  25 CONTINUE
316  i = i + 1
317  ENDIF
318  i = i + 1
319  END DO
320 *
321 * Compute (L**T \ B) -> B [ L**T \ (D \ (L \P**T * B) ) ]
322 *
323  CALL dtrsm('L','L','T','U',n,nrhs,one,a,lda,b,ldb)
324 *
325 * P * B [ P * (L**T \ (D \ (L \P**T * B) )) ]
326 *
327  k=n
328  DO WHILE ( k .GE. 1 )
329  IF( ipiv( k ).GT.0 ) THEN
330 * 1 x 1 diagonal block
331 * Interchange rows K and IPIV(K).
332  kp = ipiv( k )
333  IF( kp.NE.k )
334  $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
335  k=k-1
336  ELSE
337 * 2 x 2 diagonal block
338 * Interchange rows K-1 and -IPIV(K).
339  kp = -ipiv( k )
340  IF( k.GT.1 .AND. kp.EQ.-ipiv( k-1 ) )
341  $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
342  k=k-2
343  ENDIF
344  END DO
345 *
346  END IF
347 *
348 * Revert A
349 *
350  CALL dsyconv( uplo, 'R', n, a, lda, ipiv, work, iinfo )
351 *
352  RETURN
353 *
354 * End of DSYTRS2
355 *
subroutine dsyconv(UPLO, WAY, N, A, LDA, IPIV, WORK, INFO)
DSYCONV
Definition: dsyconv.f:114
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine dscal(N, DA, DX, INCX)
DSCAL
Definition: dscal.f:55
subroutine dtrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
DTRSM
Definition: dtrsm.f:183
subroutine dswap(N, DX, INCX, DY, INCY)
DSWAP
Definition: dswap.f:53

Here is the call graph for this function:

Here is the caller graph for this function: