LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
chetrs_aa.f
Go to the documentation of this file.
1 *> \brief \b CHETRS_AA
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download CHETRS_AA + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chetrs_aa.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chetrs_aa.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chetrs_aa.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE CHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
22 * WORK, LWORK, INFO )
23 *
24 * .. Scalar Arguments ..
25 * CHARACTER UPLO
26 * INTEGER N, NRHS, LDA, LDB, LWORK, INFO
27 * ..
28 * .. Array Arguments ..
29 * INTEGER IPIV( * )
30 * COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
31 * ..
32 *
33 *
34 *> \par Purpose:
35 * =============
36 *>
37 *> \verbatim
38 *>
39 *> CHETRS_AA solves a system of linear equations A*X = B with a complex
40 *> hermitian matrix A using the factorization A = U*T*U**H or
41 *> A = L*T*L**H computed by CHETRF_AA.
42 *> \endverbatim
43 *
44 * Arguments:
45 * ==========
46 *
47 *> \param[in] UPLO
48 *> \verbatim
49 *> UPLO is CHARACTER*1
50 *> Specifies whether the details of the factorization are stored
51 *> as an upper or lower triangular matrix.
52 *> = 'U': Upper triangular, form is A = U*T*U**H;
53 *> = 'L': Lower triangular, form is A = L*T*L**H.
54 *> \endverbatim
55 *>
56 *> \param[in] N
57 *> \verbatim
58 *> N is INTEGER
59 *> The order of the matrix A. N >= 0.
60 *> \endverbatim
61 *>
62 *> \param[in] NRHS
63 *> \verbatim
64 *> NRHS is INTEGER
65 *> The number of right hand sides, i.e., the number of columns
66 *> of the matrix B. NRHS >= 0.
67 *> \endverbatim
68 *>
69 *> \param[in] A
70 *> \verbatim
71 *> A is COMPLEX array, dimension (LDA,N)
72 *> Details of factors computed by CHETRF_AA.
73 *> \endverbatim
74 *>
75 *> \param[in] LDA
76 *> \verbatim
77 *> LDA is INTEGER
78 *> The leading dimension of the array A. LDA >= max(1,N).
79 *> \endverbatim
80 *>
81 *> \param[in] IPIV
82 *> \verbatim
83 *> IPIV is INTEGER array, dimension (N)
84 *> Details of the interchanges as computed by CHETRF_AA.
85 *> \endverbatim
86 *>
87 *> \param[in,out] B
88 *> \verbatim
89 *> B is COMPLEX array, dimension (LDB,NRHS)
90 *> On entry, the right hand side matrix B.
91 *> On exit, the solution matrix X.
92 *> \endverbatim
93 *>
94 *> \param[in] LDB
95 *> \verbatim
96 *> LDB is INTEGER
97 *> The leading dimension of the array B. LDB >= max(1,N).
98 *> \endverbatim
99 *>
100 *> \param[in] WORK
101 *> \verbatim
102 *> WORK is DOUBLE array, dimension (MAX(1,LWORK))
103 *> \endverbatim
104 *>
105 *> \param[in] LWORK
106 *> \verbatim
107 *> LWORK is INTEGER, LWORK >= MAX(1,3*N-2).
108 *>
109 *> \param[out] INFO
110 *> \verbatim
111 *> INFO is INTEGER
112 *> = 0: successful exit
113 *> < 0: if INFO = -i, the i-th argument had an illegal value
114 *> \endverbatim
115 *
116 * Authors:
117 * ========
118 *
119 *> \author Univ. of Tennessee
120 *> \author Univ. of California Berkeley
121 *> \author Univ. of Colorado Denver
122 *> \author NAG Ltd.
123 *
124 *> \date November 2017
125 *
126 *> \ingroup complexHEcomputational
127 *
128 * =====================================================================
129  SUBROUTINE chetrs_aa( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
130  $ WORK, LWORK, INFO )
131 *
132 * -- LAPACK computational routine (version 3.8.0) --
133 * -- LAPACK is a software package provided by Univ. of Tennessee, --
134 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
135 * November 2017
136 *
137  IMPLICIT NONE
138 *
139 * .. Scalar Arguments ..
140  CHARACTER UPLO
141  INTEGER N, NRHS, LDA, LDB, LWORK, INFO
142 * ..
143 * .. Array Arguments ..
144  INTEGER IPIV( * )
145  COMPLEX A( lda, * ), B( ldb, * ), WORK( * )
146 * ..
147 *
148 * =====================================================================
149 *
150  COMPLEX ONE
151  parameter( one = 1.0e+0 )
152 * ..
153 * .. Local Scalars ..
154  LOGICAL LQUERY, UPPER
155  INTEGER K, KP, LWKOPT
156 * ..
157 * .. External Functions ..
158  LOGICAL LSAME
159  EXTERNAL lsame
160 * ..
161 * .. External Subroutines ..
162  EXTERNAL clacpy, clacgv, cgtsv, cswap, ctrsm, xerbla
163 * ..
164 * .. Intrinsic Functions ..
165  INTRINSIC max
166 * ..
167 * .. Executable Statements ..
168 *
169  info = 0
170  upper = lsame( uplo, 'U' )
171  lquery = ( lwork.EQ.-1 )
172  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
173  info = -1
174  ELSE IF( n.LT.0 ) THEN
175  info = -2
176  ELSE IF( nrhs.LT.0 ) THEN
177  info = -3
178  ELSE IF( lda.LT.max( 1, n ) ) THEN
179  info = -5
180  ELSE IF( ldb.LT.max( 1, n ) ) THEN
181  info = -8
182  ELSE IF( lwork.LT.max( 1, 3*n-2 ) .AND. .NOT.lquery ) THEN
183  info = -10
184  END IF
185  IF( info.NE.0 ) THEN
186  CALL xerbla( 'CHETRS_AA', -info )
187  RETURN
188  ELSE IF( lquery ) THEN
189  lwkopt = (3*n-2)
190  work( 1 ) = lwkopt
191  RETURN
192  END IF
193 *
194 * Quick return if possible
195 *
196  IF( n.EQ.0 .OR. nrhs.EQ.0 )
197  $ RETURN
198 *
199  IF( upper ) THEN
200 *
201 * Solve A*X = B, where A = U*T*U**T.
202 *
203 * P**T * B
204 *
205  k = 1
206  DO WHILE ( k.LE.n )
207  kp = ipiv( k )
208  IF( kp.NE.k )
209  $ CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
210  k = k + 1
211  END DO
212 *
213 * Compute (U \P**T * B) -> B [ (U \P**T * B) ]
214 *
215  CALL ctrsm('L', 'U', 'C', 'U', n-1, nrhs, one, a( 1, 2 ), lda,
216  $ b( 2, 1 ), ldb)
217 *
218 * Compute T \ B -> B [ T \ (U \P**T * B) ]
219 *
220  CALL clacpy( 'F', 1, n, a(1, 1), lda+1, work(n), 1)
221  IF( n.GT.1 ) THEN
222  CALL clacpy( 'F', 1, n-1, a( 1, 2 ), lda+1, work( 2*n ), 1)
223  CALL clacpy( 'F', 1, n-1, a( 1, 2 ), lda+1, work( 1 ), 1)
224  CALL clacgv( n-1, work( 1 ), 1 )
225  END IF
226  CALL cgtsv(n, nrhs, work(1), work(n), work(2*n), b, ldb,
227  $ info)
228 *
229 * Compute (U**T \ B) -> B [ U**T \ (T \ (U \P**T * B) ) ]
230 *
231  CALL ctrsm( 'L', 'U', 'N', 'U', n-1, nrhs, one, a( 1, 2 ), lda,
232  $ b(2, 1), ldb)
233 *
234 * Pivot, P * B [ P * (U**T \ (T \ (U \P**T * B) )) ]
235 *
236  k = n
237  DO WHILE ( k.GE.1 )
238  kp = ipiv( k )
239  IF( kp.NE.k )
240  $ CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
241  k = k - 1
242  END DO
243 *
244  ELSE
245 *
246 * Solve A*X = B, where A = L*T*L**T.
247 *
248 * Pivot, P**T * B
249 *
250  k = 1
251  DO WHILE ( k.LE.n )
252  kp = ipiv( k )
253  IF( kp.NE.k )
254  $ CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
255  k = k + 1
256  END DO
257 *
258 * Compute (L \P**T * B) -> B [ (L \P**T * B) ]
259 *
260  CALL ctrsm( 'L', 'L', 'N', 'U', n-1, nrhs, one, a( 2, 1), lda,
261  $ b(2, 1), ldb)
262 *
263 * Compute T \ B -> B [ T \ (L \P**T * B) ]
264 *
265  CALL clacpy( 'F', 1, n, a(1, 1), lda+1, work(n), 1)
266  IF( n.GT.1 ) THEN
267  CALL clacpy( 'F', 1, n-1, a( 2, 1 ), lda+1, work( 1 ), 1)
268  CALL clacpy( 'F', 1, n-1, a( 2, 1 ), lda+1, work( 2*n ), 1)
269  CALL clacgv( n-1, work( 2*n ), 1 )
270  END IF
271  CALL cgtsv(n, nrhs, work(1), work(n), work(2*n), b, ldb,
272  $ info)
273 *
274 * Compute (L**T \ B) -> B [ L**T \ (T \ (L \P**T * B) ) ]
275 *
276  CALL ctrsm( 'L', 'L', 'C', 'U', n-1, nrhs, one, a( 2, 1 ), lda,
277  $ b( 2, 1 ), ldb)
278 *
279 * Pivot, P * B [ P * (L**T \ (T \ (L \P**T * B) )) ]
280 *
281  k = n
282  DO WHILE ( k.GE.1 )
283  kp = ipiv( k )
284  IF( kp.NE.k )
285  $ CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
286  k = k - 1
287  END DO
288 *
289  END IF
290 *
291  RETURN
292 *
293 * End of CHETRS_AA
294 *
295  END
subroutine chetrs_aa(UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK, LWORK, INFO)
CHETRS_AA
Definition: chetrs_aa.f:131
subroutine ctrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
CTRSM
Definition: ctrsm.f:182
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:105
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
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:126
subroutine clacgv(N, X, INCX)
CLACGV conjugates a complex vector.
Definition: clacgv.f:76
subroutine cswap(N, CX, INCX, CY, INCY)
CSWAP
Definition: cswap.f:83