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

◆ csytrs_aa()

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

CSYTRS_AA

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

Purpose:
!>
!> CSYTRS_AA solves a system of linear equations A*X = B with a complex
!> symmetric matrix A using the factorization A = U**T*T*U or
!> A = L*T*L**T computed by CSYTRF_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 COMPLEX array, dimension (LDA,N)
!>          Details of factors computed by CSYTRF_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 CSYTRF_AA.
!> 
[in,out]B
!>          B is COMPLEX 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 COMPLEX array, dimension (MAX(1,LWORK))
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK. LWORK >= max(1,3*N-2).
!> 
[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 127 of file csytrs_aa.f.

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