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

◆ ssytrs_aa()

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

SSYTRS_AA

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

Purpose:
!>
!> SSYTRS_AA solves a system of linear equations A*X = B with a real
!> symmetric matrix A using the factorization A = U**T*T*U or
!> A = L*T*L**T computed by SSYTRF_AA.
!> 
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**T*T*U;
!>          = 'L':  Lower triangular, form is A = L*T*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)
!>          Details of factors computed by SSYTRF_AA.
!> 
[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 as computed by SSYTRF_AA.
!> 
[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]WORK
!>          WORK is REAL array, dimension (MAX(1,LWORK))
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK.
!>          If MIN(N,NRHS) = 0, LWORK >= 1, else LWORK >= 3*N-2.
!>
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the minimal size of the WORK array, returns
!>          this value as the first entry of the WORK array, and no error
!>          message related to LWORK is issued by XERBLA.
!> 
[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.

Definition at line 133 of file ssytrs_aa.f.

135*
136* -- LAPACK computational routine --
137* -- LAPACK is a software package provided by Univ. of Tennessee, --
138* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
139*
140 IMPLICIT NONE
141*
142* .. Scalar Arguments ..
143 CHARACTER UPLO
144 INTEGER N, NRHS, LDA, LDB, LWORK, INFO
145* ..
146* .. Array Arguments ..
147 INTEGER IPIV( * )
148 REAL A( LDA, * ), B( LDB, * ), WORK( * )
149* ..
150*
151* =====================================================================
152*
153 REAL ONE
154 parameter( one = 1.0e+0 )
155* ..
156* .. Local Scalars ..
157 LOGICAL LQUERY, UPPER
158 INTEGER K, KP, LWKMIN
159* ..
160* .. External Functions ..
161 LOGICAL LSAME
162 EXTERNAL lsame
163 REAL SROUNDUP_LWORK
164 EXTERNAL sroundup_lwork
165* ..
166* .. External Subroutines ..
167 EXTERNAL sgtsv, sswap, slacpy, strsm, xerbla
168* ..
169* .. Intrinsic Functions ..
170 INTRINSIC min, max
171* ..
172* .. Executable Statements ..
173*
174 info = 0
175 upper = lsame( uplo, 'U' )
176 lquery = ( lwork.EQ.-1 )
177 IF( min( n, nrhs ).EQ.0 ) THEN
178 lwkmin = 1
179 ELSE
180 lwkmin = 3*n-2
181 END IF
182*
183 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
184 info = -1
185 ELSE IF( n.LT.0 ) THEN
186 info = -2
187 ELSE IF( nrhs.LT.0 ) THEN
188 info = -3
189 ELSE IF( lda.LT.max( 1, n ) ) THEN
190 info = -5
191 ELSE IF( ldb.LT.max( 1, n ) ) THEN
192 info = -8
193 ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery ) THEN
194 info = -10
195 END IF
196 IF( info.NE.0 ) THEN
197 CALL xerbla( 'SSYTRS_AA', -info )
198 RETURN
199 ELSE IF( lquery ) THEN
200 work( 1 ) = sroundup_lwork( lwkmin )
201 RETURN
202 END IF
203*
204* Quick return if possible
205*
206 IF( min( n, nrhs ).EQ.0 )
207 $ RETURN
208*
209 IF( upper ) THEN
210*
211* Solve A*X = B, where A = U**T*T*U.
212*
213* 1) Forward substitution with U**T
214*
215 IF( n.GT.1 ) THEN
216*
217* Pivot, P**T * B -> B
218*
219 k = 1
220 DO WHILE ( k.LE.n )
221 kp = ipiv( k )
222 IF( kp.NE.k )
223 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ),
224 $ ldb )
225 k = k + 1
226 END DO
227*
228* Compute U**T \ B -> B [ (U**T \P**T * B) ]
229*
230 CALL strsm( 'L', 'U', 'T', 'U', n-1, nrhs, one, a( 1,
231 $ 2 ),
232 $ lda, b( 2, 1 ), ldb)
233 END IF
234*
235* 2) Solve with triangular matrix T
236*
237* Compute T \ B -> B [ T \ (U**T \P**T * B) ]
238*
239 CALL slacpy( 'F', 1, n, a(1, 1), lda+1, work(n), 1)
240 IF( n.GT.1 ) THEN
241 CALL slacpy( 'F', 1, n-1, a(1, 2), lda+1, work(1), 1)
242 CALL slacpy( 'F', 1, n-1, a(1, 2), lda+1, work(2*n), 1)
243 END IF
244 CALL sgtsv(n, nrhs, work(1), work(n), work(2*n), b, ldb,
245 $ info)
246*
247* 3) Backward substitution with U
248*
249 IF( n.GT.1 ) THEN
250*
251*
252* Compute U \ B -> B [ U \ (T \ (U**T \P**T * B) ) ]
253*
254 CALL strsm( 'L', 'U', 'N', 'U', n-1, nrhs, one, a( 1,
255 $ 2 ),
256 $ lda, b(2, 1), ldb)
257*
258* Pivot, P * B -> B [ P * (U \ (T \ (U**T \P**T * B) )) ]
259*
260 k = n
261 DO WHILE ( k.GE.1 )
262 kp = ipiv( k )
263 IF( kp.NE.k )
264 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
265 k = k - 1
266 END DO
267 END IF
268*
269 ELSE
270*
271* Solve A*X = B, where A = L*T*L**T.
272*
273* 1) Forward substitution with L
274*
275 IF( n.GT.1 ) THEN
276*
277* Pivot, P**T * B -> B
278*
279 k = 1
280 DO WHILE ( k.LE.n )
281 kp = ipiv( k )
282 IF( kp.NE.k )
283 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
284 k = k + 1
285 END DO
286*
287* Compute L \ B -> B [ (L \P**T * B) ]
288*
289 CALL strsm( 'L', 'L', 'N', 'U', n-1, nrhs, one, a( 2, 1),
290 $ lda, b(2, 1), ldb)
291 END IF
292*
293* 2) Solve with triangular matrix T
294*
295* Compute T \ B -> B [ T \ (L \P**T * B) ]
296*
297 CALL slacpy( 'F', 1, n, a(1, 1), lda+1, work(n), 1)
298 IF( n.GT.1 ) THEN
299 CALL slacpy( 'F', 1, n-1, a(2, 1), lda+1, work(1), 1)
300 CALL slacpy( 'F', 1, n-1, a(2, 1), lda+1, work(2*n), 1)
301 END IF
302 CALL sgtsv(n, nrhs, work(1), work(n), work(2*n), b, ldb,
303 $ info)
304*
305* 3) Backward substitution with L**T
306*
307 IF( n.GT.1 ) THEN
308*
309* Compute L**T \ B -> B [ L**T \ (T \ (L \P**T * B) ) ]
310*
311 CALL strsm( 'L', 'L', 'T', 'U', n-1, nrhs, one, a( 2,
312 $ 1 ),
313 $ lda, b( 2, 1 ), ldb)
314*
315* Pivot, P * B -> B [ P * (L**T \ (T \ (L \P**T * B) )) ]
316*
317 k = n
318 DO WHILE ( k.GE.1 )
319 kp = ipiv( k )
320 IF( kp.NE.k )
321 $ CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
322 k = k - 1
323 END DO
324 END IF
325*
326 END IF
327*
328 RETURN
329*
330* End of SSYTRS_AA
331*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgtsv(n, nrhs, dl, d, du, b, ldb, info)
SGTSV computes the solution to system of linear equations A * X = B for GT matrices
Definition sgtsv.f:125
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
Definition slacpy.f:101
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
real function sroundup_lwork(lwork)
SROUNDUP_LWORK
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
Definition sswap.f:82
subroutine strsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
STRSM
Definition strsm.f:181
Here is the call graph for this function:
Here is the caller graph for this function: