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

◆ ssytrs_rook()

subroutine ssytrs_rook ( character uplo,
integer n,
integer nrhs,
real, dimension( lda, * ) a,
integer lda,
integer, dimension( * ) ipiv,
real, dimension( ldb, * ) b,
integer ldb,
integer info )

SSYTRS_ROOK

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

Purpose:
!>
!> SSYTRS_ROOK 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 SSYTRF_ROOK.
!> 
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 REAL array, dimension (LDA,N)
!>          The block diagonal matrix D and the multipliers used to
!>          obtain the factor U or L as computed by SSYTRF_ROOK.
!> 
[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 SSYTRF_ROOK.
!> 
[in,out]B
!>          B is REAL 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]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.
Contributors:
!>
!>   April 2012, Igor Kozachenko,
!>                  Computer Science Division,
!>                  University of California, Berkeley
!>
!>  September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas,
!>                  School of Mathematics,
!>                  University of Manchester
!>
!> 

Definition at line 132 of file ssytrs_rook.f.

134*
135* -- LAPACK computational routine --
136* -- LAPACK is a software package provided by Univ. of Tennessee, --
137* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
138*
139* .. Scalar Arguments ..
140 CHARACTER UPLO
141 INTEGER INFO, LDA, LDB, N, NRHS
142* ..
143* .. Array Arguments ..
144 INTEGER IPIV( * )
145 REAL A( LDA, * ), B( LDB, * )
146* ..
147*
148* =====================================================================
149*
150* .. Parameters ..
151 REAL ONE
152 parameter( one = 1.0e+0 )
153* ..
154* .. Local Scalars ..
155 LOGICAL UPPER
156 INTEGER J, K, KP
157 REAL AK, AKM1, AKM1K, BK, BKM1, DENOM
158* ..
159* .. External Functions ..
160 LOGICAL LSAME
161 EXTERNAL lsame
162* ..
163* .. External Subroutines ..
164 EXTERNAL sgemv, sger, sscal, sswap, xerbla
165* ..
166* .. Intrinsic Functions ..
167 INTRINSIC max
168* ..
169* .. Executable Statements ..
170*
171 info = 0
172 upper = lsame( uplo, 'U' )
173 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
174 info = -1
175 ELSE IF( n.LT.0 ) THEN
176 info = -2
177 ELSE IF( nrhs.LT.0 ) THEN
178 info = -3
179 ELSE IF( lda.LT.max( 1, n ) ) THEN
180 info = -5
181 ELSE IF( ldb.LT.max( 1, n ) ) THEN
182 info = -8
183 END IF
184 IF( info.NE.0 ) THEN
185 CALL xerbla( 'SSYTRS_ROOK', -info )
186 RETURN
187 END IF
188*
189* Quick return if possible
190*
191 IF( n.EQ.0 .OR. nrhs.EQ.0 )
192 $ RETURN
193*
194 IF( upper ) THEN
195*
196* Solve A*X = B, where A = U*D*U**T.
197*
198* First solve U*D*X = B, overwriting B with X.
199*
200* K is the main loop index, decreasing from N to 1 in steps of
201* 1 or 2, depending on the size of the diagonal blocks.
202*
203 k = n
204 10 CONTINUE
205*
206* If K < 1, exit from loop.
207*
208 IF( k.LT.1 )
209 $ GO TO 30
210*
211 IF( ipiv( k ).GT.0 ) THEN
212*
213* 1 x 1 diagonal block
214*
215* Interchange rows K and IPIV(K).
216*
217 kp = ipiv( k )
218 IF( kp.NE.k )
219 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
220*
221* Multiply by inv(U(K)), where U(K) is the transformation
222* stored in column K of A.
223*
224 CALL sger( k-1, nrhs, -one, a( 1, k ), 1, b( k, 1 ), ldb,
225 $ b( 1, 1 ), ldb )
226*
227* Multiply by the inverse of the diagonal block.
228*
229 CALL sscal( nrhs, one / a( k, k ), b( k, 1 ), ldb )
230 k = k - 1
231 ELSE
232*
233* 2 x 2 diagonal block
234*
235* Interchange rows K and -IPIV(K) THEN K-1 and -IPIV(K-1)
236*
237 kp = -ipiv( k )
238 IF( kp.NE.k )
239 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
240*
241 kp = -ipiv( k-1 )
242 IF( kp.NE.k-1 )
243 $ CALL sswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
244*
245* Multiply by inv(U(K)), where U(K) is the transformation
246* stored in columns K-1 and K of A.
247*
248 IF( k.GT.2 ) THEN
249 CALL sger( k-2, nrhs, -one, a( 1, k ), 1, b( k, 1 ),
250 $ ldb, b( 1, 1 ), ldb )
251 CALL sger( k-2, nrhs, -one, a( 1, k-1 ), 1, b( k-1,
252 $ 1 ),
253 $ ldb, b( 1, 1 ), ldb )
254 END IF
255*
256* Multiply by the inverse of the diagonal block.
257*
258 akm1k = a( k-1, k )
259 akm1 = a( k-1, k-1 ) / akm1k
260 ak = a( k, k ) / akm1k
261 denom = akm1*ak - one
262 DO 20 j = 1, nrhs
263 bkm1 = b( k-1, j ) / akm1k
264 bk = b( k, j ) / akm1k
265 b( k-1, j ) = ( ak*bkm1-bk ) / denom
266 b( k, j ) = ( akm1*bk-bkm1 ) / denom
267 20 CONTINUE
268 k = k - 2
269 END IF
270*
271 GO TO 10
272 30 CONTINUE
273*
274* Next solve U**T *X = B, overwriting B with X.
275*
276* K is the main loop index, increasing from 1 to N in steps of
277* 1 or 2, depending on the size of the diagonal blocks.
278*
279 k = 1
280 40 CONTINUE
281*
282* If K > N, exit from loop.
283*
284 IF( k.GT.n )
285 $ GO TO 50
286*
287 IF( ipiv( k ).GT.0 ) THEN
288*
289* 1 x 1 diagonal block
290*
291* Multiply by inv(U**T(K)), where U(K) is the transformation
292* stored in column K of A.
293*
294 IF( k.GT.1 )
295 $ CALL sgemv( 'Transpose', k-1, nrhs, -one, b,
296 $ ldb, a( 1, k ), 1, one, b( k, 1 ), ldb )
297*
298* Interchange rows K and IPIV(K).
299*
300 kp = ipiv( k )
301 IF( kp.NE.k )
302 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
303 k = k + 1
304 ELSE
305*
306* 2 x 2 diagonal block
307*
308* Multiply by inv(U**T(K+1)), where U(K+1) is the transformation
309* stored in columns K and K+1 of A.
310*
311 IF( k.GT.1 ) THEN
312 CALL sgemv( 'Transpose', k-1, nrhs, -one, b,
313 $ ldb, a( 1, k ), 1, one, b( k, 1 ), ldb )
314 CALL sgemv( 'Transpose', k-1, nrhs, -one, b,
315 $ ldb, a( 1, k+1 ), 1, one, b( k+1, 1 ), ldb )
316 END IF
317*
318* Interchange rows K and -IPIV(K) THEN K+1 and -IPIV(K+1).
319*
320 kp = -ipiv( k )
321 IF( kp.NE.k )
322 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
323*
324 kp = -ipiv( k+1 )
325 IF( kp.NE.k+1 )
326 $ CALL sswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
327*
328 k = k + 2
329 END IF
330*
331 GO TO 40
332 50 CONTINUE
333*
334 ELSE
335*
336* Solve A*X = B, where A = L*D*L**T.
337*
338* First solve L*D*X = B, overwriting B with X.
339*
340* K is the main loop index, increasing from 1 to N in steps of
341* 1 or 2, depending on the size of the diagonal blocks.
342*
343 k = 1
344 60 CONTINUE
345*
346* If K > N, exit from loop.
347*
348 IF( k.GT.n )
349 $ GO TO 80
350*
351 IF( ipiv( k ).GT.0 ) THEN
352*
353* 1 x 1 diagonal block
354*
355* Interchange rows K and IPIV(K).
356*
357 kp = ipiv( k )
358 IF( kp.NE.k )
359 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
360*
361* Multiply by inv(L(K)), where L(K) is the transformation
362* stored in column K of A.
363*
364 IF( k.LT.n )
365 $ CALL sger( n-k, nrhs, -one, a( k+1, k ), 1, b( k, 1 ),
366 $ ldb, b( k+1, 1 ), ldb )
367*
368* Multiply by the inverse of the diagonal block.
369*
370 CALL sscal( nrhs, one / a( k, k ), b( k, 1 ), ldb )
371 k = k + 1
372 ELSE
373*
374* 2 x 2 diagonal block
375*
376* Interchange rows K and -IPIV(K) THEN K+1 and -IPIV(K+1)
377*
378 kp = -ipiv( k )
379 IF( kp.NE.k )
380 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
381*
382 kp = -ipiv( k+1 )
383 IF( kp.NE.k+1 )
384 $ CALL sswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
385*
386* Multiply by inv(L(K)), where L(K) is the transformation
387* stored in columns K and K+1 of A.
388*
389 IF( k.LT.n-1 ) THEN
390 CALL sger( n-k-1, nrhs, -one, a( k+2, k ), 1, b( k,
391 $ 1 ),
392 $ ldb, b( k+2, 1 ), ldb )
393 CALL sger( n-k-1, nrhs, -one, a( k+2, k+1 ), 1,
394 $ b( k+1, 1 ), ldb, b( k+2, 1 ), ldb )
395 END IF
396*
397* Multiply by the inverse of the diagonal block.
398*
399 akm1k = a( k+1, k )
400 akm1 = a( k, k ) / akm1k
401 ak = a( k+1, k+1 ) / akm1k
402 denom = akm1*ak - one
403 DO 70 j = 1, nrhs
404 bkm1 = b( k, j ) / akm1k
405 bk = b( k+1, j ) / akm1k
406 b( k, j ) = ( ak*bkm1-bk ) / denom
407 b( k+1, j ) = ( akm1*bk-bkm1 ) / denom
408 70 CONTINUE
409 k = k + 2
410 END IF
411*
412 GO TO 60
413 80 CONTINUE
414*
415* Next solve L**T *X = B, overwriting B with X.
416*
417* K is the main loop index, decreasing from N to 1 in steps of
418* 1 or 2, depending on the size of the diagonal blocks.
419*
420 k = n
421 90 CONTINUE
422*
423* If K < 1, exit from loop.
424*
425 IF( k.LT.1 )
426 $ GO TO 100
427*
428 IF( ipiv( k ).GT.0 ) THEN
429*
430* 1 x 1 diagonal block
431*
432* Multiply by inv(L**T(K)), where L(K) is the transformation
433* stored in column K of A.
434*
435 IF( k.LT.n )
436 $ CALL sgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
437 $ ldb, a( k+1, k ), 1, one, b( k, 1 ), ldb )
438*
439* Interchange rows K and IPIV(K).
440*
441 kp = ipiv( k )
442 IF( kp.NE.k )
443 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
444 k = k - 1
445 ELSE
446*
447* 2 x 2 diagonal block
448*
449* Multiply by inv(L**T(K-1)), where L(K-1) is the transformation
450* stored in columns K-1 and K of A.
451*
452 IF( k.LT.n ) THEN
453 CALL sgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
454 $ ldb, a( k+1, k ), 1, one, b( k, 1 ), ldb )
455 CALL sgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
456 $ ldb, a( k+1, k-1 ), 1, one, b( k-1, 1 ),
457 $ ldb )
458 END IF
459*
460* Interchange rows K and -IPIV(K) THEN K-1 and -IPIV(K-1)
461*
462 kp = -ipiv( k )
463 IF( kp.NE.k )
464 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
465*
466 kp = -ipiv( k-1 )
467 IF( kp.NE.k-1 )
468 $ CALL sswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
469*
470 k = k - 2
471 END IF
472*
473 GO TO 90
474 100 CONTINUE
475 END IF
476*
477 RETURN
478*
479* End of SSYTRS_ROOK
480*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
SGEMV
Definition sgemv.f:158
subroutine sger(m, n, alpha, x, incx, y, incy, a, lda)
SGER
Definition sger.f:130
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
Definition sswap.f:82
Here is the call graph for this function:
Here is the caller graph for this function: