LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dsytrs.f
Go to the documentation of this file.
1*> \brief \b DSYTRS
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DSYTRS + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsytrs.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsytrs.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsytrs.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DSYTRS( 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* DOUBLE PRECISION A( LDA, * ), B( LDB, * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> DSYTRS solves a system of linear equations A*X = B with a real
37*> symmetric matrix A using the factorization A = U*D*U**T or
38*> A = L*D*L**T computed by DSYTRF.
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 DOUBLE PRECISION 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 DSYTRF.
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 DSYTRF.
84*> \endverbatim
85*>
86*> \param[in,out] B
87*> \verbatim
88*> B is DOUBLE PRECISION 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
115*
116* =====================================================================
117 SUBROUTINE dsytrs( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
118*
119* -- LAPACK computational routine --
120* -- LAPACK is a software package provided by Univ. of Tennessee, --
121* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
122*
123* .. Scalar Arguments ..
124 CHARACTER UPLO
125 INTEGER INFO, LDA, LDB, N, NRHS
126* ..
127* .. Array Arguments ..
128 INTEGER IPIV( * )
129 DOUBLE PRECISION A( LDA, * ), B( LDB, * )
130* ..
131*
132* =====================================================================
133*
134* .. Parameters ..
135 DOUBLE PRECISION ONE
136 parameter( one = 1.0d+0 )
137* ..
138* .. Local Scalars ..
139 LOGICAL UPPER
140 INTEGER J, K, KP
141 DOUBLE PRECISION AK, AKM1, AKM1K, BK, BKM1, DENOM
142* ..
143* .. External Functions ..
144 LOGICAL LSAME
145 EXTERNAL lsame
146* ..
147* .. External Subroutines ..
148 EXTERNAL dgemv, dger, dscal, dswap, xerbla
149* ..
150* .. Intrinsic Functions ..
151 INTRINSIC max
152* ..
153* .. Executable Statements ..
154*
155 info = 0
156 upper = lsame( uplo, 'U' )
157 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
158 info = -1
159 ELSE IF( n.LT.0 ) THEN
160 info = -2
161 ELSE IF( nrhs.LT.0 ) THEN
162 info = -3
163 ELSE IF( lda.LT.max( 1, n ) ) THEN
164 info = -5
165 ELSE IF( ldb.LT.max( 1, n ) ) THEN
166 info = -8
167 END IF
168 IF( info.NE.0 ) THEN
169 CALL xerbla( 'DSYTRS', -info )
170 RETURN
171 END IF
172*
173* Quick return if possible
174*
175 IF( n.EQ.0 .OR. nrhs.EQ.0 )
176 $ RETURN
177*
178 IF( upper ) THEN
179*
180* Solve A*X = B, where A = U*D*U**T.
181*
182* First solve U*D*X = B, overwriting B with X.
183*
184* K is the main loop index, decreasing from N to 1 in steps of
185* 1 or 2, depending on the size of the diagonal blocks.
186*
187 k = n
188 10 CONTINUE
189*
190* If K < 1, exit from loop.
191*
192 IF( k.LT.1 )
193 $ GO TO 30
194*
195 IF( ipiv( k ).GT.0 ) THEN
196*
197* 1 x 1 diagonal block
198*
199* Interchange rows K and IPIV(K).
200*
201 kp = ipiv( k )
202 IF( kp.NE.k )
203 $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
204*
205* Multiply by inv(U(K)), where U(K) is the transformation
206* stored in column K of A.
207*
208 CALL dger( k-1, nrhs, -one, a( 1, k ), 1, b( k, 1 ), ldb,
209 $ b( 1, 1 ), ldb )
210*
211* Multiply by the inverse of the diagonal block.
212*
213 CALL dscal( nrhs, one / a( k, k ), b( k, 1 ), ldb )
214 k = k - 1
215 ELSE
216*
217* 2 x 2 diagonal block
218*
219* Interchange rows K-1 and -IPIV(K).
220*
221 kp = -ipiv( k )
222 IF( kp.NE.k-1 )
223 $ CALL dswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
224*
225* Multiply by inv(U(K)), where U(K) is the transformation
226* stored in columns K-1 and K of A.
227*
228 CALL dger( k-2, nrhs, -one, a( 1, k ), 1, b( k, 1 ), ldb,
229 $ b( 1, 1 ), ldb )
230 CALL dger( k-2, nrhs, -one, a( 1, k-1 ), 1, b( k-1, 1 ),
231 $ ldb, b( 1, 1 ), ldb )
232*
233* Multiply by the inverse of the diagonal block.
234*
235 akm1k = a( k-1, k )
236 akm1 = a( k-1, k-1 ) / akm1k
237 ak = a( k, k ) / akm1k
238 denom = akm1*ak - one
239 DO 20 j = 1, nrhs
240 bkm1 = b( k-1, j ) / akm1k
241 bk = b( k, j ) / akm1k
242 b( k-1, j ) = ( ak*bkm1-bk ) / denom
243 b( k, j ) = ( akm1*bk-bkm1 ) / denom
244 20 CONTINUE
245 k = k - 2
246 END IF
247*
248 GO TO 10
249 30 CONTINUE
250*
251* Next solve U**T *X = B, overwriting B with X.
252*
253* K is the main loop index, increasing from 1 to N in steps of
254* 1 or 2, depending on the size of the diagonal blocks.
255*
256 k = 1
257 40 CONTINUE
258*
259* If K > N, exit from loop.
260*
261 IF( k.GT.n )
262 $ GO TO 50
263*
264 IF( ipiv( k ).GT.0 ) THEN
265*
266* 1 x 1 diagonal block
267*
268* Multiply by inv(U**T(K)), where U(K) is the transformation
269* stored in column K of A.
270*
271 CALL dgemv( 'Transpose', k-1, nrhs, -one, b, ldb, a( 1,
272 $ k ),
273 $ 1, one, b( k, 1 ), ldb )
274*
275* Interchange rows K and IPIV(K).
276*
277 kp = ipiv( k )
278 IF( kp.NE.k )
279 $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
280 k = k + 1
281 ELSE
282*
283* 2 x 2 diagonal block
284*
285* Multiply by inv(U**T(K+1)), where U(K+1) is the transformation
286* stored in columns K and K+1 of A.
287*
288 CALL dgemv( 'Transpose', k-1, nrhs, -one, b, ldb, a( 1,
289 $ k ),
290 $ 1, one, b( k, 1 ), ldb )
291 CALL dgemv( 'Transpose', k-1, nrhs, -one, b, ldb,
292 $ a( 1, k+1 ), 1, one, b( k+1, 1 ), ldb )
293*
294* Interchange rows K and -IPIV(K).
295*
296 kp = -ipiv( k )
297 IF( kp.NE.k )
298 $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
299 k = k + 2
300 END IF
301*
302 GO TO 40
303 50 CONTINUE
304*
305 ELSE
306*
307* Solve A*X = B, where A = L*D*L**T.
308*
309* First solve L*D*X = B, overwriting B with X.
310*
311* K is the main loop index, increasing from 1 to N in steps of
312* 1 or 2, depending on the size of the diagonal blocks.
313*
314 k = 1
315 60 CONTINUE
316*
317* If K > N, exit from loop.
318*
319 IF( k.GT.n )
320 $ GO TO 80
321*
322 IF( ipiv( k ).GT.0 ) THEN
323*
324* 1 x 1 diagonal block
325*
326* Interchange rows K and IPIV(K).
327*
328 kp = ipiv( k )
329 IF( kp.NE.k )
330 $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
331*
332* Multiply by inv(L(K)), where L(K) is the transformation
333* stored in column K of A.
334*
335 IF( k.LT.n )
336 $ CALL dger( n-k, nrhs, -one, a( k+1, k ), 1, b( k, 1 ),
337 $ ldb, b( k+1, 1 ), ldb )
338*
339* Multiply by the inverse of the diagonal block.
340*
341 CALL dscal( nrhs, one / a( k, k ), b( k, 1 ), ldb )
342 k = k + 1
343 ELSE
344*
345* 2 x 2 diagonal block
346*
347* Interchange rows K+1 and -IPIV(K).
348*
349 kp = -ipiv( k )
350 IF( kp.NE.k+1 )
351 $ CALL dswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ), ldb )
352*
353* Multiply by inv(L(K)), where L(K) is the transformation
354* stored in columns K and K+1 of A.
355*
356 IF( k.LT.n-1 ) THEN
357 CALL dger( n-k-1, nrhs, -one, a( k+2, k ), 1, b( k,
358 $ 1 ),
359 $ ldb, b( k+2, 1 ), ldb )
360 CALL dger( n-k-1, nrhs, -one, a( k+2, k+1 ), 1,
361 $ b( k+1, 1 ), ldb, b( k+2, 1 ), ldb )
362 END IF
363*
364* Multiply by the inverse of the diagonal block.
365*
366 akm1k = a( k+1, k )
367 akm1 = a( k, k ) / akm1k
368 ak = a( k+1, k+1 ) / akm1k
369 denom = akm1*ak - one
370 DO 70 j = 1, nrhs
371 bkm1 = b( k, j ) / akm1k
372 bk = b( k+1, j ) / akm1k
373 b( k, j ) = ( ak*bkm1-bk ) / denom
374 b( k+1, j ) = ( akm1*bk-bkm1 ) / denom
375 70 CONTINUE
376 k = k + 2
377 END IF
378*
379 GO TO 60
380 80 CONTINUE
381*
382* Next solve L**T *X = B, overwriting B with X.
383*
384* K is the main loop index, decreasing from N to 1 in steps of
385* 1 or 2, depending on the size of the diagonal blocks.
386*
387 k = n
388 90 CONTINUE
389*
390* If K < 1, exit from loop.
391*
392 IF( k.LT.1 )
393 $ GO TO 100
394*
395 IF( ipiv( k ).GT.0 ) THEN
396*
397* 1 x 1 diagonal block
398*
399* Multiply by inv(L**T(K)), where L(K) is the transformation
400* stored in column K of A.
401*
402 IF( k.LT.n )
403 $ CALL dgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
404 $ ldb, a( k+1, k ), 1, one, b( k, 1 ), ldb )
405*
406* Interchange rows K and IPIV(K).
407*
408 kp = ipiv( k )
409 IF( kp.NE.k )
410 $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
411 k = k - 1
412 ELSE
413*
414* 2 x 2 diagonal block
415*
416* Multiply by inv(L**T(K-1)), where L(K-1) is the transformation
417* stored in columns K-1 and K of A.
418*
419 IF( k.LT.n ) THEN
420 CALL dgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
421 $ ldb, a( k+1, k ), 1, one, b( k, 1 ), ldb )
422 CALL dgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
423 $ ldb, a( k+1, k-1 ), 1, one, b( k-1, 1 ),
424 $ ldb )
425 END IF
426*
427* Interchange rows K and -IPIV(K).
428*
429 kp = -ipiv( k )
430 IF( kp.NE.k )
431 $ CALL dswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
432 k = k - 2
433 END IF
434*
435 GO TO 90
436 100 CONTINUE
437 END IF
438*
439 RETURN
440*
441* End of DSYTRS
442*
443 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
DGEMV
Definition dgemv.f:158
subroutine dger(m, n, alpha, x, incx, y, incy, a, lda)
DGER
Definition dger.f:130
subroutine dsytrs(uplo, n, nrhs, a, lda, ipiv, b, ldb, info)
DSYTRS
Definition dsytrs.f:118
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
subroutine dswap(n, dx, incx, dy, incy)
DSWAP
Definition dswap.f:82