LAPACK  3.10.0 LAPACK: Linear Algebra PACKage

## ◆ ssytrs()

 subroutine ssytrs ( character UPLO, integer N, integer NRHS, real, dimension( lda, * ) A, integer LDA, integer, dimension( * ) IPIV, real, dimension( ldb, * ) B, integer LDB, integer INFO )

SSYTRS

Purpose:
``` SSYTRS 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.```
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.``` [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.``` [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```

Definition at line 119 of file ssytrs.f.

120 *
121 * -- LAPACK computational routine --
122 * -- LAPACK is a software package provided by Univ. of Tennessee, --
123 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
124 *
125 * .. Scalar Arguments ..
126  CHARACTER UPLO
127  INTEGER INFO, LDA, LDB, N, NRHS
128 * ..
129 * .. Array Arguments ..
130  INTEGER IPIV( * )
131  REAL A( LDA, * ), B( LDB, * )
132 * ..
133 *
134 * =====================================================================
135 *
136 * .. Parameters ..
137  REAL ONE
138  parameter( one = 1.0e+0 )
139 * ..
140 * .. Local Scalars ..
141  LOGICAL UPPER
142  INTEGER J, K, KP
143  REAL AK, AKM1, AKM1K, BK, BKM1, DENOM
144 * ..
145 * .. External Functions ..
146  LOGICAL LSAME
147  EXTERNAL lsame
148 * ..
149 * .. External Subroutines ..
150  EXTERNAL sgemv, sger, sscal, sswap, xerbla
151 * ..
152 * .. Intrinsic Functions ..
153  INTRINSIC max
154 * ..
155 * .. Executable Statements ..
156 *
157  info = 0
158  upper = lsame( uplo, 'U' )
159  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
160  info = -1
161  ELSE IF( n.LT.0 ) THEN
162  info = -2
163  ELSE IF( nrhs.LT.0 ) THEN
164  info = -3
165  ELSE IF( lda.LT.max( 1, n ) ) THEN
166  info = -5
167  ELSE IF( ldb.LT.max( 1, n ) ) THEN
168  info = -8
169  END IF
170  IF( info.NE.0 ) THEN
171  CALL xerbla( 'SSYTRS', -info )
172  RETURN
173  END IF
174 *
175 * Quick return if possible
176 *
177  IF( n.EQ.0 .OR. nrhs.EQ.0 )
178  \$ RETURN
179 *
180  IF( upper ) THEN
181 *
182 * Solve A*X = B, where A = U*D*U**T.
183 *
184 * First solve U*D*X = B, overwriting B with X.
185 *
186 * K is the main loop index, decreasing from N to 1 in steps of
187 * 1 or 2, depending on the size of the diagonal blocks.
188 *
189  k = n
190  10 CONTINUE
191 *
192 * If K < 1, exit from loop.
193 *
194  IF( k.LT.1 )
195  \$ GO TO 30
196 *
197  IF( ipiv( k ).GT.0 ) THEN
198 *
199 * 1 x 1 diagonal block
200 *
201 * Interchange rows K and IPIV(K).
202 *
203  kp = ipiv( k )
204  IF( kp.NE.k )
205  \$ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
206 *
207 * Multiply by inv(U(K)), where U(K) is the transformation
208 * stored in column K of A.
209 *
210  CALL sger( k-1, nrhs, -one, a( 1, k ), 1, b( k, 1 ), ldb,
211  \$ b( 1, 1 ), ldb )
212 *
213 * Multiply by the inverse of the diagonal block.
214 *
215  CALL sscal( nrhs, one / a( k, k ), b( k, 1 ), ldb )
216  k = k - 1
217  ELSE
218 *
219 * 2 x 2 diagonal block
220 *
221 * Interchange rows K-1 and -IPIV(K).
222 *
223  kp = -ipiv( k )
224  IF( kp.NE.k-1 )
225  \$ CALL sswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ), ldb )
226 *
227 * Multiply by inv(U(K)), where U(K) is the transformation
228 * stored in columns K-1 and K of A.
229 *
230  CALL sger( k-2, nrhs, -one, a( 1, k ), 1, b( k, 1 ), ldb,
231  \$ b( 1, 1 ), ldb )
232  CALL sger( k-2, nrhs, -one, a( 1, k-1 ), 1, b( k-1, 1 ),
233  \$ ldb, b( 1, 1 ), ldb )
234 *
235 * Multiply by the inverse of the diagonal block.
236 *
237  akm1k = a( k-1, k )
238  akm1 = a( k-1, k-1 ) / akm1k
239  ak = a( k, k ) / akm1k
240  denom = akm1*ak - one
241  DO 20 j = 1, nrhs
242  bkm1 = b( k-1, j ) / akm1k
243  bk = b( k, j ) / akm1k
244  b( k-1, j ) = ( ak*bkm1-bk ) / denom
245  b( k, j ) = ( akm1*bk-bkm1 ) / denom
246  20 CONTINUE
247  k = k - 2
248  END IF
249 *
250  GO TO 10
251  30 CONTINUE
252 *
253 * Next solve U**T *X = B, overwriting B with X.
254 *
255 * K is the main loop index, increasing from 1 to N in steps of
256 * 1 or 2, depending on the size of the diagonal blocks.
257 *
258  k = 1
259  40 CONTINUE
260 *
261 * If K > N, exit from loop.
262 *
263  IF( k.GT.n )
264  \$ GO TO 50
265 *
266  IF( ipiv( k ).GT.0 ) THEN
267 *
268 * 1 x 1 diagonal block
269 *
270 * Multiply by inv(U**T(K)), where U(K) is the transformation
271 * stored in column K of A.
272 *
273  CALL sgemv( 'Transpose', k-1, nrhs, -one, b, ldb, a( 1, k ),
274  \$ 1, one, b( k, 1 ), ldb )
275 *
276 * Interchange rows K and IPIV(K).
277 *
278  kp = ipiv( k )
279  IF( kp.NE.k )
280  \$ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
281  k = k + 1
282  ELSE
283 *
284 * 2 x 2 diagonal block
285 *
286 * Multiply by inv(U**T(K+1)), where U(K+1) is the transformation
287 * stored in columns K and K+1 of A.
288 *
289  CALL sgemv( 'Transpose', k-1, nrhs, -one, b, ldb, a( 1, k ),
290  \$ 1, one, b( k, 1 ), ldb )
291  CALL sgemv( '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 sswap( 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 sswap( 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 sger( 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 sscal( 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 sswap( 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 sger( n-k-1, nrhs, -one, a( k+2, k ), 1, b( k, 1 ),
358  \$ ldb, b( k+2, 1 ), ldb )
359  CALL sger( n-k-1, nrhs, -one, a( k+2, k+1 ), 1,
360  \$ b( k+1, 1 ), ldb, b( k+2, 1 ), ldb )
361  END IF
362 *
363 * Multiply by the inverse of the diagonal block.
364 *
365  akm1k = a( k+1, k )
366  akm1 = a( k, k ) / akm1k
367  ak = a( k+1, k+1 ) / akm1k
368  denom = akm1*ak - one
369  DO 70 j = 1, nrhs
370  bkm1 = b( k, j ) / akm1k
371  bk = b( k+1, j ) / akm1k
372  b( k, j ) = ( ak*bkm1-bk ) / denom
373  b( k+1, j ) = ( akm1*bk-bkm1 ) / denom
374  70 CONTINUE
375  k = k + 2
376  END IF
377 *
378  GO TO 60
379  80 CONTINUE
380 *
381 * Next solve L**T *X = B, overwriting B with X.
382 *
383 * K is the main loop index, decreasing from N to 1 in steps of
384 * 1 or 2, depending on the size of the diagonal blocks.
385 *
386  k = n
387  90 CONTINUE
388 *
389 * If K < 1, exit from loop.
390 *
391  IF( k.LT.1 )
392  \$ GO TO 100
393 *
394  IF( ipiv( k ).GT.0 ) THEN
395 *
396 * 1 x 1 diagonal block
397 *
398 * Multiply by inv(L**T(K)), where L(K) is the transformation
399 * stored in column K of A.
400 *
401  IF( k.LT.n )
402  \$ CALL sgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
403  \$ ldb, a( k+1, k ), 1, one, b( k, 1 ), ldb )
404 *
405 * Interchange rows K and IPIV(K).
406 *
407  kp = ipiv( k )
408  IF( kp.NE.k )
409  \$ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
410  k = k - 1
411  ELSE
412 *
413 * 2 x 2 diagonal block
414 *
415 * Multiply by inv(L**T(K-1)), where L(K-1) is the transformation
416 * stored in columns K-1 and K of A.
417 *
418  IF( k.LT.n ) THEN
419  CALL sgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
420  \$ ldb, a( k+1, k ), 1, one, b( k, 1 ), ldb )
421  CALL sgemv( 'Transpose', n-k, nrhs, -one, b( k+1, 1 ),
422  \$ ldb, a( k+1, k-1 ), 1, one, b( k-1, 1 ),
423  \$ ldb )
424  END IF
425 *
426 * Interchange rows K and -IPIV(K).
427 *
428  kp = -ipiv( k )
429  IF( kp.NE.k )
430  \$ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
431  k = k - 2
432  END IF
433 *
434  GO TO 90
435  100 CONTINUE
436  END IF
437 *
438  RETURN
439 *
440 * End of SSYTRS
441 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine sswap(N, SX, INCX, SY, INCY)
SSWAP
Definition: sswap.f:82
subroutine sscal(N, SA, SX, INCX)
SSCAL
Definition: sscal.f:79
subroutine sger(M, N, ALPHA, X, INCX, Y, INCY, A, LDA)
SGER
Definition: sger.f:130
subroutine sgemv(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
SGEMV
Definition: sgemv.f:156
Here is the call graph for this function:
Here is the caller graph for this function: