LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
ssytrs_rook.f
Go to the documentation of this file.
1*> \brief \b SSYTRS_ROOK
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SSYTRS_ROOK + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssytrs_rook.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssytrs_rook.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssytrs_rook.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SSYTRS_ROOK( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
20*
21* .. Scalar Arguments ..
22* CHARACTER UPLO
23* INTEGER INFO, LDA, LDB, N, NRHS
24* ..
25* .. Array Arguments ..
26* INTEGER IPIV( * )
27* REAL A( LDA, * ), B( LDB, * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> SSYTRS_ROOK solves a system of linear equations A*X = B with
37*> a real symmetric matrix A using the factorization A = U*D*U**T or
38*> A = L*D*L**T computed by SSYTRF_ROOK.
39*> \endverbatim
40*
41* Arguments:
42* ==========
43*
44*> \param[in] UPLO
45*> \verbatim
46*> UPLO is CHARACTER*1
47*> Specifies whether the details of the factorization are stored
48*> as an upper or lower triangular matrix.
49*> = 'U': Upper triangular, form is A = U*D*U**T;
50*> = 'L': Lower triangular, form is A = L*D*L**T.
51*> \endverbatim
52*>
53*> \param[in] N
54*> \verbatim
55*> N is INTEGER
56*> The order of the matrix A. N >= 0.
57*> \endverbatim
58*>
59*> \param[in] NRHS
60*> \verbatim
61*> NRHS is INTEGER
62*> The number of right hand sides, i.e., the number of columns
63*> of the matrix B. NRHS >= 0.
64*> \endverbatim
65*>
66*> \param[in] A
67*> \verbatim
68*> A is REAL array, dimension (LDA,N)
69*> The block diagonal matrix D and the multipliers used to
70*> obtain the factor U or L as computed by SSYTRF_ROOK.
71*> \endverbatim
72*>
73*> \param[in] LDA
74*> \verbatim
75*> LDA is INTEGER
76*> The leading dimension of the array A. LDA >= max(1,N).
77*> \endverbatim
78*>
79*> \param[in] IPIV
80*> \verbatim
81*> IPIV is INTEGER array, dimension (N)
82*> Details of the interchanges and the block structure of D
83*> as determined by SSYTRF_ROOK.
84*> \endverbatim
85*>
86*> \param[in,out] B
87*> \verbatim
88*> B is REAL array, dimension (LDB,NRHS)
89*> On entry, the right hand side matrix B.
90*> On exit, the solution matrix X.
91*> \endverbatim
92*>
93*> \param[in] LDB
94*> \verbatim
95*> LDB is INTEGER
96*> The leading dimension of the array B. LDB >= max(1,N).
97*> \endverbatim
98*>
99*> \param[out] INFO
100*> \verbatim
101*> INFO is INTEGER
102*> = 0: successful exit
103*> < 0: if INFO = -i, the i-th argument had an illegal value
104*> \endverbatim
105*
106* Authors:
107* ========
108*
109*> \author Univ. of Tennessee
110*> \author Univ. of California Berkeley
111*> \author Univ. of Colorado Denver
112*> \author NAG Ltd.
113*
114*> \ingroup hetrs_rook
115*
116*> \par Contributors:
117* ==================
118*>
119*> \verbatim
120*>
121*> April 2012, Igor Kozachenko,
122*> Computer Science Division,
123*> University of California, Berkeley
124*>
125*> September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas,
126*> School of Mathematics,
127*> University of Manchester
128*>
129*> \endverbatim
130*
131* =====================================================================
132 SUBROUTINE ssytrs_rook( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
133 $ INFO )
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*
481 END
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
subroutine ssytrs_rook(uplo, n, nrhs, a, lda, ipiv, b, ldb, info)
SSYTRS_ROOK
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
Definition sswap.f:82