Annotation of rpl/lapack/lapack/zhetrs_aa.f, revision 1.5
1.1 bertrand 1: *> \brief \b ZHETRS_AA
2: *
3: * =========== DOCUMENTATION ===========
4: *
5: * Online html documentation available at
6: * http://www.netlib.org/lapack/explore-html/
7: *
8: *> \htmlonly
9: *> Download ZHETRS_AA + dependencies
10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhetrs_aa.f">
11: *> [TGZ]</a>
12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhetrs_aa.f">
13: *> [ZIP]</a>
14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhetrs_aa.f">
15: *> [TXT]</a>
16: *> \endhtmlonly
17: *
18: * Definition:
19: * ===========
20: *
21: * SUBROUTINE ZHETRS_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*16 A( LDA, * ), B( LDB, * ), WORK( * )
31: * ..
32: *
33: *
34: *
35: *> \par Purpose:
36: * =============
37: *>
38: *> \verbatim
39: *>
40: *> ZHETRS_AA solves a system of linear equations A*X = B with a complex
1.5 ! bertrand 41: *> hermitian matrix A using the factorization A = U**H*T*U or
! 42: *> A = L*T*L**H computed by ZHETRF_AA.
1.1 bertrand 43: *> \endverbatim
44: *
45: * Arguments:
46: * ==========
47: *
48: *> \param[in] UPLO
49: *> \verbatim
50: *> UPLO is CHARACTER*1
51: *> Specifies whether the details of the factorization are stored
52: *> as an upper or lower triangular matrix.
1.5 ! bertrand 53: *> = 'U': Upper triangular, form is A = U**H*T*U;
1.1 bertrand 54: *> = 'L': Lower triangular, form is A = L*T*L**H.
55: *> \endverbatim
56: *>
57: *> \param[in] N
58: *> \verbatim
59: *> N is INTEGER
60: *> The order of the matrix A. N >= 0.
61: *> \endverbatim
62: *>
63: *> \param[in] NRHS
64: *> \verbatim
65: *> NRHS is INTEGER
66: *> The number of right hand sides, i.e., the number of columns
67: *> of the matrix B. NRHS >= 0.
68: *> \endverbatim
69: *>
1.3 bertrand 70: *> \param[in] A
1.1 bertrand 71: *> \verbatim
72: *> A is COMPLEX*16 array, dimension (LDA,N)
73: *> Details of factors computed by ZHETRF_AA.
74: *> \endverbatim
75: *>
76: *> \param[in] LDA
77: *> \verbatim
78: *> LDA is INTEGER
79: *> The leading dimension of the array A. LDA >= max(1,N).
80: *> \endverbatim
81: *>
82: *> \param[in] IPIV
83: *> \verbatim
84: *> IPIV is INTEGER array, dimension (N)
85: *> Details of the interchanges as computed by ZHETRF_AA.
86: *> \endverbatim
87: *>
88: *> \param[in,out] B
89: *> \verbatim
90: *> B is COMPLEX*16 array, dimension (LDB,NRHS)
91: *> On entry, the right hand side matrix B.
92: *> On exit, the solution matrix X.
93: *> \endverbatim
94: *>
95: *> \param[in] LDB
96: *> \verbatim
97: *> LDB is INTEGER
98: *> The leading dimension of the array B. LDB >= max(1,N).
99: *> \endverbatim
100: *>
1.5 ! bertrand 101: *> \param[out] WORK
1.1 bertrand 102: *> \verbatim
1.5 ! bertrand 103: *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
1.1 bertrand 104: *> \endverbatim
105: *>
106: *> \param[in] LWORK
107: *> \verbatim
1.5 ! bertrand 108: *> LWORK is INTEGER
! 109: *> The dimension of the array WORK. LWORK >= max(1,3*N-2).
! 110: *> \endverbatim
1.1 bertrand 111: *>
112: *> \param[out] INFO
113: *> \verbatim
114: *> INFO is INTEGER
115: *> = 0: successful exit
116: *> < 0: if INFO = -i, the i-th argument had an illegal value
117: *> \endverbatim
118: *
119: * Authors:
120: * ========
121: *
122: *> \author Univ. of Tennessee
123: *> \author Univ. of California Berkeley
124: *> \author Univ. of Colorado Denver
125: *> \author NAG Ltd.
126: *
1.3 bertrand 127: *> \date November 2017
1.1 bertrand 128: *
129: *> \ingroup complex16HEcomputational
130: *
131: * =====================================================================
132: SUBROUTINE ZHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
133: $ WORK, LWORK, INFO )
134: *
1.3 bertrand 135: * -- LAPACK computational routine (version 3.8.0) --
1.1 bertrand 136: * -- LAPACK is a software package provided by Univ. of Tennessee, --
137: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1.3 bertrand 138: * November 2017
1.1 bertrand 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: COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
149: * ..
150: *
151: * =====================================================================
152: *
153: COMPLEX*16 ONE
154: PARAMETER ( ONE = 1.0D+0 )
155: * ..
156: * .. Local Scalars ..
157: LOGICAL LQUERY, UPPER
158: INTEGER K, KP, LWKOPT
159: * ..
160: * .. External Functions ..
161: LOGICAL LSAME
162: EXTERNAL LSAME
163: * ..
164: * .. External Subroutines ..
1.3 bertrand 165: EXTERNAL ZGTSV, ZSWAP, ZTRSM, ZLACGV, ZLACPY, XERBLA
1.1 bertrand 166: * ..
167: * .. Intrinsic Functions ..
168: INTRINSIC MAX
169: * ..
170: * .. Executable Statements ..
171: *
172: INFO = 0
173: UPPER = LSAME( UPLO, 'U' )
174: LQUERY = ( LWORK.EQ.-1 )
175: IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
176: INFO = -1
177: ELSE IF( N.LT.0 ) THEN
178: INFO = -2
179: ELSE IF( NRHS.LT.0 ) THEN
180: INFO = -3
181: ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
182: INFO = -5
183: ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
184: INFO = -8
185: ELSE IF( LWORK.LT.MAX( 1, 3*N-2 ) .AND. .NOT.LQUERY ) THEN
186: INFO = -10
187: END IF
188: IF( INFO.NE.0 ) THEN
189: CALL XERBLA( 'ZHETRS_AA', -INFO )
190: RETURN
191: ELSE IF( LQUERY ) THEN
192: LWKOPT = (3*N-2)
193: WORK( 1 ) = LWKOPT
194: RETURN
195: END IF
196: *
197: * Quick return if possible
198: *
199: IF( N.EQ.0 .OR. NRHS.EQ.0 )
200: $ RETURN
201: *
202: IF( UPPER ) THEN
203: *
1.5 ! bertrand 204: * Solve A*X = B, where A = U**H*T*U.
! 205: *
! 206: * 1) Forward substitution with U**H
! 207: *
! 208: IF( N.GT.1 ) THEN
! 209: *
! 210: * Pivot, P**T * B -> B
1.1 bertrand 211: *
1.5 ! bertrand 212: DO K = 1, N
! 213: KP = IPIV( K )
! 214: IF( KP.NE.K )
! 215: $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
! 216: END DO
1.1 bertrand 217: *
1.5 ! bertrand 218: * Compute U**H \ B -> B [ (U**H \P**T * B) ]
1.1 bertrand 219: *
1.5 ! bertrand 220: CALL ZTRSM( 'L', 'U', 'C', 'U', N-1, NRHS, ONE, A( 1, 2 ),
! 221: $ LDA, B( 2, 1 ), LDB )
! 222: END IF
1.1 bertrand 223: *
1.5 ! bertrand 224: * 2) Solve with triangular matrix T
1.1 bertrand 225: *
1.5 ! bertrand 226: * Compute T \ B -> B [ T \ (U**H \P**T * B) ]
1.1 bertrand 227: *
1.5 ! bertrand 228: CALL ZLACPY( 'F', 1, N, A(1, 1), LDA+1, WORK(N), 1 )
1.1 bertrand 229: IF( N.GT.1 ) THEN
230: CALL ZLACPY( 'F', 1, N-1, A( 1, 2 ), LDA+1, WORK( 2*N ), 1)
1.5 ! bertrand 231: CALL ZLACPY( 'F', 1, N-1, A( 1, 2 ), LDA+1, WORK( 1 ), 1 )
1.1 bertrand 232: CALL ZLACGV( N-1, WORK( 1 ), 1 )
233: END IF
1.5 ! bertrand 234: CALL ZGTSV( N, NRHS, WORK(1), WORK(N), WORK(2*N), B, LDB,
! 235: $ INFO )
! 236: *
! 237: * 3) Backward substitution with U
! 238: *
! 239: IF( N.GT.1 ) THEN
1.1 bertrand 240: *
1.5 ! bertrand 241: * Compute U \ B -> B [ U \ (T \ (U**H \P**T * B) ) ]
1.1 bertrand 242: *
1.5 ! bertrand 243: CALL ZTRSM( 'L', 'U', 'N', 'U', N-1, NRHS, ONE, A( 1, 2 ),
! 244: $ LDA, B(2, 1), LDB)
1.1 bertrand 245: *
1.5 ! bertrand 246: * Pivot, P * B [ P * (U**H \ (T \ (U \P**T * B) )) ]
1.1 bertrand 247: *
1.5 ! bertrand 248: DO K = N, 1, -1
! 249: KP = IPIV( K )
! 250: IF( KP.NE.K )
! 251: $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
! 252: END DO
! 253: END IF
1.1 bertrand 254: *
255: ELSE
256: *
1.5 ! bertrand 257: * Solve A*X = B, where A = L*T*L**H.
! 258: *
! 259: * 1) Forward substitution with L
1.1 bertrand 260: *
1.5 ! bertrand 261: IF( N.GT.1 ) THEN
! 262: *
! 263: * Pivot, P**T * B -> B
1.1 bertrand 264: *
1.5 ! bertrand 265: DO K = 1, N
! 266: KP = IPIV( K )
! 267: IF( KP.NE.K )
! 268: $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
! 269: END DO
1.1 bertrand 270: *
1.5 ! bertrand 271: * Compute L \ B -> B [ (L \P**T * B) ]
1.1 bertrand 272: *
1.5 ! bertrand 273: CALL ZTRSM( 'L', 'L', 'N', 'U', N-1, NRHS, ONE, A( 2, 1 ),
! 274: $ LDA, B(2, 1), LDB)
! 275: END IF
! 276: *
! 277: * 2) Solve with triangular matrix T
1.1 bertrand 278: *
279: * Compute T \ B -> B [ T \ (L \P**T * B) ]
280: *
281: CALL ZLACPY( 'F', 1, N, A(1, 1), LDA+1, WORK(N), 1)
282: IF( N.GT.1 ) THEN
283: CALL ZLACPY( 'F', 1, N-1, A( 2, 1 ), LDA+1, WORK( 1 ), 1)
284: CALL ZLACPY( 'F', 1, N-1, A( 2, 1 ), LDA+1, WORK( 2*N ), 1)
285: CALL ZLACGV( N-1, WORK( 2*N ), 1 )
286: END IF
287: CALL ZGTSV(N, NRHS, WORK(1), WORK(N), WORK(2*N), B, LDB,
288: $ INFO)
289: *
1.5 ! bertrand 290: * 3) Backward substitution with L**H
! 291: *
! 292: IF( N.GT.1 ) THEN
1.1 bertrand 293: *
1.5 ! bertrand 294: * Compute L**H \ B -> B [ L**H \ (T \ (L \P**T * B) ) ]
1.1 bertrand 295: *
1.5 ! bertrand 296: CALL ZTRSM( 'L', 'L', 'C', 'U', N-1, NRHS, ONE, A( 2, 1 ),
! 297: $ LDA, B( 2, 1 ), LDB)
1.1 bertrand 298: *
1.5 ! bertrand 299: * Pivot, P * B [ P * (L**H \ (T \ (L \P**T * B) )) ]
! 300: *
! 301: DO K = N, 1, -1
! 302: KP = IPIV( K )
! 303: IF( KP.NE.K )
! 304: $ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
! 305: END DO
! 306: END IF
1.1 bertrand 307: *
308: END IF
309: *
310: RETURN
311: *
312: * End of ZHETRS_AA
313: *
314: END
CVSweb interface <joel.bertrand@systella.fr>