LAPACK  3.10.1
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**H*T*U 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**H*T*U;
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[out] WORK
101 *> \verbatim
102 *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
103 *> \endverbatim
104 *>
105 *> \param[in] LWORK
106 *> \verbatim
107 *> LWORK is INTEGER
108 *> The dimension of the array WORK. LWORK >= max(1,3*N-2).
109 *> \endverbatim
110 *>
111 *> \param[out] INFO
112 *> \verbatim
113 *> INFO is INTEGER
114 *> = 0: successful exit
115 *> < 0: if INFO = -i, the i-th argument had an illegal value
116 *> \endverbatim
117 *
118 * Authors:
119 * ========
120 *
121 *> \author Univ. of Tennessee
122 *> \author Univ. of California Berkeley
123 *> \author Univ. of Colorado Denver
124 *> \author NAG Ltd.
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 --
133 * -- LAPACK is a software package provided by Univ. of Tennessee, --
134 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
135 *
136  IMPLICIT NONE
137 *
138 * .. Scalar Arguments ..
139  CHARACTER UPLO
140  INTEGER N, NRHS, LDA, LDB, LWORK, INFO
141 * ..
142 * .. Array Arguments ..
143  INTEGER IPIV( * )
144  COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
145 * ..
146 *
147 * =====================================================================
148 *
149  COMPLEX ONE
150  parameter( one = 1.0e+0 )
151 * ..
152 * .. Local Scalars ..
153  LOGICAL LQUERY, UPPER
154  INTEGER K, KP, LWKOPT
155 * ..
156 * .. External Functions ..
157  LOGICAL LSAME
158  EXTERNAL lsame
159 * ..
160 * .. External Subroutines ..
161  EXTERNAL clacpy, clacgv, cgtsv, cswap, ctrsm, xerbla
162 * ..
163 * .. Intrinsic Functions ..
164  INTRINSIC max
165 * ..
166 * .. Executable Statements ..
167 *
168  info = 0
169  upper = lsame( uplo, 'U' )
170  lquery = ( lwork.EQ.-1 )
171  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
172  info = -1
173  ELSE IF( n.LT.0 ) THEN
174  info = -2
175  ELSE IF( nrhs.LT.0 ) THEN
176  info = -3
177  ELSE IF( lda.LT.max( 1, n ) ) THEN
178  info = -5
179  ELSE IF( ldb.LT.max( 1, n ) ) THEN
180  info = -8
181  ELSE IF( lwork.LT.max( 1, 3*n-2 ) .AND. .NOT.lquery ) THEN
182  info = -10
183  END IF
184  IF( info.NE.0 ) THEN
185  CALL xerbla( 'CHETRS_AA', -info )
186  RETURN
187  ELSE IF( lquery ) THEN
188  lwkopt = (3*n-2)
189  work( 1 ) = lwkopt
190  RETURN
191  END IF
192 *
193 * Quick return if possible
194 *
195  IF( n.EQ.0 .OR. nrhs.EQ.0 )
196  $ RETURN
197 *
198  IF( upper ) THEN
199 *
200 * Solve A*X = B, where A = U**H*T*U.
201 *
202 * 1) Forward substitution with U**H
203 *
204  IF( n.GT.1 ) THEN
205 *
206 * Pivot, P**T * B -> B
207 *
208  k = 1
209  DO WHILE ( k.LE.n )
210  kp = ipiv( k )
211  IF( kp.NE.k )
212  $ CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
213  k = k + 1
214  END DO
215 *
216 * Compute U**H \ B -> B [ (U**H \P**T * B) ]
217 *
218  CALL ctrsm( 'L', 'U', 'C', 'U', n-1, nrhs, one, a( 1, 2 ),
219  $ lda, b( 2, 1 ), ldb)
220  END IF
221 *
222 * 2) Solve with triangular matrix T
223 *
224 * Compute T \ B -> B [ T \ (U**H \P**T * B) ]
225 *
226  CALL clacpy( 'F', 1, n, a(1, 1), lda+1, work(n), 1)
227  IF( n.GT.1 ) THEN
228  CALL clacpy( 'F', 1, n-1, a( 1, 2 ), lda+1, work( 2*n ), 1)
229  CALL clacpy( 'F', 1, n-1, a( 1, 2 ), lda+1, work( 1 ), 1)
230  CALL clacgv( n-1, work( 1 ), 1 )
231  END IF
232  CALL cgtsv(n, nrhs, work(1), work(n), work(2*n), b, 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**H \P**T * B) ) ]
240 *
241  CALL ctrsm( 'L', 'U', 'N', 'U', n-1, nrhs, one, a( 1, 2 ),
242  $ lda, b(2, 1), ldb)
243 *
244 * Pivot, P * B -> B [ P * (U \ (T \ (U**H \P**T * B) )) ]
245 *
246  k = n
247  DO WHILE ( k.GE.1 )
248  kp = ipiv( k )
249  IF( kp.NE.k )
250  $ CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
251  k = k - 1
252  END DO
253  END IF
254 *
255  ELSE
256 *
257 * Solve A*X = B, where A = L*T*L**H.
258 *
259 * 1) Forward substitution with L
260 *
261  IF( n.GT.1 ) THEN
262 *
263 * Pivot, P**T * B -> B
264 *
265  k = 1
266  DO WHILE ( k.LE.n )
267  kp = ipiv( k )
268  IF( kp.NE.k )
269  $ CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
270  k = k + 1
271  END DO
272 *
273 * Compute L \ B -> B [ (L \P**T * B) ]
274 *
275  CALL ctrsm( 'L', 'L', 'N', 'U', n-1, nrhs, one, a( 2, 1),
276  $ lda, b(2, 1), ldb )
277  END IF
278 *
279 * 2) Solve with triangular matrix T
280 *
281 * Compute T \ B -> B [ T \ (L \P**T * B) ]
282 *
283  CALL clacpy( 'F', 1, n, a(1, 1), lda+1, work(n), 1)
284  IF( n.GT.1 ) THEN
285  CALL clacpy( 'F', 1, n-1, a( 2, 1 ), lda+1, work( 1 ), 1 )
286  CALL clacpy( 'F', 1, n-1, a( 2, 1 ), lda+1, work( 2*n ), 1)
287  CALL clacgv( n-1, work( 2*n ), 1 )
288  END IF
289  CALL cgtsv(n, nrhs, work(1), work(n), work(2*n), b, ldb,
290  $ info)
291 *
292 * 3) Backward substitution with L**H
293 *
294  IF( n.GT.1 ) THEN
295 *
296 * Compute (L**H \ B) -> B [ L**H \ (T \ (L \P**T * B) ) ]
297 *
298  CALL ctrsm( 'L', 'L', 'C', 'U', n-1, nrhs, one, a( 2, 1 ),
299  $ lda, b( 2, 1 ), ldb )
300 *
301 * Pivot, P * B -> B [ P * (L**H \ (T \ (L \P**T * B) )) ]
302 *
303  k = n
304  DO WHILE ( k.GE.1 )
305  kp = ipiv( k )
306  IF( kp.NE.k )
307  $ CALL cswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
308  k = k - 1
309  END DO
310  END IF
311 *
312  END IF
313 *
314  RETURN
315 *
316 * End of CHETRS_AA
317 *
318  END
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
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
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:124
subroutine chetrs_aa(UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK, LWORK, INFO)
CHETRS_AA
Definition: chetrs_aa.f:131
subroutine clacgv(N, X, INCX)
CLACGV conjugates a complex vector.
Definition: clacgv.f:74
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:103