LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zhegs2.f
Go to the documentation of this file.
1*> \brief \b ZHEGS2 reduces a Hermitian definite generalized eigenproblem to standard form, using the factorization results obtained from cpotrf (unblocked algorithm).
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZHEGS2 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhegs2.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhegs2.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhegs2.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZHEGS2( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
20*
21* .. Scalar Arguments ..
22* CHARACTER UPLO
23* INTEGER INFO, ITYPE, LDA, LDB, N
24* ..
25* .. Array Arguments ..
26* COMPLEX*16 A( LDA, * ), B( LDB, * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> ZHEGS2 reduces a complex Hermitian-definite generalized
36*> eigenproblem to standard form.
37*>
38*> If ITYPE = 1, the problem is A*x = lambda*B*x,
39*> and A is overwritten by inv(U**H)*A*inv(U) or inv(L)*A*inv(L**H)
40*>
41*> If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or
42*> B*A*x = lambda*x, and A is overwritten by U*A*U**H or L**H *A*L.
43*>
44*> B must have been previously factorized as U**H *U or L*L**H by ZPOTRF.
45*> \endverbatim
46*
47* Arguments:
48* ==========
49*
50*> \param[in] ITYPE
51*> \verbatim
52*> ITYPE is INTEGER
53*> = 1: compute inv(U**H)*A*inv(U) or inv(L)*A*inv(L**H);
54*> = 2 or 3: compute U*A*U**H or L**H *A*L.
55*> \endverbatim
56*>
57*> \param[in] UPLO
58*> \verbatim
59*> UPLO is CHARACTER*1
60*> Specifies whether the upper or lower triangular part of the
61*> Hermitian matrix A is stored, and how B has been factorized.
62*> = 'U': Upper triangular
63*> = 'L': Lower triangular
64*> \endverbatim
65*>
66*> \param[in] N
67*> \verbatim
68*> N is INTEGER
69*> The order of the matrices A and B. N >= 0.
70*> \endverbatim
71*>
72*> \param[in,out] A
73*> \verbatim
74*> A is COMPLEX*16 array, dimension (LDA,N)
75*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading
76*> n by n upper triangular part of A contains the upper
77*> triangular part of the matrix A, and the strictly lower
78*> triangular part of A is not referenced. If UPLO = 'L', the
79*> leading n by n lower triangular part of A contains the lower
80*> triangular part of the matrix A, and the strictly upper
81*> triangular part of A is not referenced.
82*>
83*> On exit, if INFO = 0, the transformed matrix, stored in the
84*> same format as A.
85*> \endverbatim
86*>
87*> \param[in] LDA
88*> \verbatim
89*> LDA is INTEGER
90*> The leading dimension of the array A. LDA >= max(1,N).
91*> \endverbatim
92*>
93*> \param[in,out] B
94*> \verbatim
95*> B is COMPLEX*16 array, dimension (LDB,N)
96*> The triangular factor from the Cholesky factorization of B,
97*> as returned by ZPOTRF.
98*> B is modified by the routine but restored on exit.
99*> \endverbatim
100*>
101*> \param[in] LDB
102*> \verbatim
103*> LDB is INTEGER
104*> The leading dimension of the array B. LDB >= max(1,N).
105*> \endverbatim
106*>
107*> \param[out] INFO
108*> \verbatim
109*> INFO is INTEGER
110*> = 0: successful exit.
111*> < 0: if INFO = -i, the i-th argument had an illegal value.
112*> \endverbatim
113*
114* Authors:
115* ========
116*
117*> \author Univ. of Tennessee
118*> \author Univ. of California Berkeley
119*> \author Univ. of Colorado Denver
120*> \author NAG Ltd.
121*
122*> \ingroup hegs2
123*
124* =====================================================================
125 SUBROUTINE zhegs2( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
126*
127* -- LAPACK computational routine --
128* -- LAPACK is a software package provided by Univ. of Tennessee, --
129* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
130*
131* .. Scalar Arguments ..
132 CHARACTER UPLO
133 INTEGER INFO, ITYPE, LDA, LDB, N
134* ..
135* .. Array Arguments ..
136 COMPLEX*16 A( LDA, * ), B( LDB, * )
137* ..
138*
139* =====================================================================
140*
141* .. Parameters ..
142 DOUBLE PRECISION ONE, HALF
143 parameter( one = 1.0d+0, half = 0.5d+0 )
144 COMPLEX*16 CONE
145 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
146* ..
147* .. Local Scalars ..
148 LOGICAL UPPER
149 INTEGER K
150 DOUBLE PRECISION AKK, BKK
151 COMPLEX*16 CT
152* ..
153* .. External Subroutines ..
154 EXTERNAL xerbla, zaxpy, zdscal, zher2, zlacgv,
155 $ ztrmv,
156 $ ztrsv
157* ..
158* .. Intrinsic Functions ..
159 INTRINSIC max
160* ..
161* .. External Functions ..
162 LOGICAL LSAME
163 EXTERNAL lsame
164* ..
165* .. Executable Statements ..
166*
167* Test the input parameters.
168*
169 info = 0
170 upper = lsame( uplo, 'U' )
171 IF( itype.LT.1 .OR. itype.GT.3 ) THEN
172 info = -1
173 ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
174 info = -2
175 ELSE IF( n.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 = -7
181 END IF
182 IF( info.NE.0 ) THEN
183 CALL xerbla( 'ZHEGS2', -info )
184 RETURN
185 END IF
186*
187 IF( itype.EQ.1 ) THEN
188 IF( upper ) THEN
189*
190* Compute inv(U**H)*A*inv(U)
191*
192 DO 10 k = 1, n
193*
194* Update the upper triangle of A(k:n,k:n)
195*
196 akk = dble( a( k, k ) )
197 bkk = dble( b( k, k ) )
198 akk = akk / bkk**2
199 a( k, k ) = akk
200 IF( k.LT.n ) THEN
201 CALL zdscal( n-k, one / bkk, a( k, k+1 ), lda )
202 ct = -half*akk
203 CALL zlacgv( n-k, a( k, k+1 ), lda )
204 CALL zlacgv( n-k, b( k, k+1 ), ldb )
205 CALL zaxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
206 $ lda )
207 CALL zher2( uplo, n-k, -cone, a( k, k+1 ), lda,
208 $ b( k, k+1 ), ldb, a( k+1, k+1 ), lda )
209 CALL zaxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
210 $ lda )
211 CALL zlacgv( n-k, b( k, k+1 ), ldb )
212 CALL ztrsv( uplo, 'Conjugate transpose',
213 $ 'Non-unit',
214 $ n-k, b( k+1, k+1 ), ldb, a( k, k+1 ),
215 $ lda )
216 CALL zlacgv( n-k, a( k, k+1 ), lda )
217 END IF
218 10 CONTINUE
219 ELSE
220*
221* Compute inv(L)*A*inv(L**H)
222*
223 DO 20 k = 1, n
224*
225* Update the lower triangle of A(k:n,k:n)
226*
227 akk = dble( a( k, k ) )
228 bkk = dble( b( k, k ) )
229 akk = akk / bkk**2
230 a( k, k ) = akk
231 IF( k.LT.n ) THEN
232 CALL zdscal( n-k, one / bkk, a( k+1, k ), 1 )
233 ct = -half*akk
234 CALL zaxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ),
235 $ 1 )
236 CALL zher2( uplo, n-k, -cone, a( k+1, k ), 1,
237 $ b( k+1, k ), 1, a( k+1, k+1 ), lda )
238 CALL zaxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ),
239 $ 1 )
240 CALL ztrsv( uplo, 'No transpose', 'Non-unit', n-k,
241 $ b( k+1, k+1 ), ldb, a( k+1, k ), 1 )
242 END IF
243 20 CONTINUE
244 END IF
245 ELSE
246 IF( upper ) THEN
247*
248* Compute U*A*U**H
249*
250 DO 30 k = 1, n
251*
252* Update the upper triangle of A(1:k,1:k)
253*
254 akk = dble( a( k, k ) )
255 bkk = dble( b( k, k ) )
256 CALL ztrmv( uplo, 'No transpose', 'Non-unit', k-1, b,
257 $ ldb, a( 1, k ), 1 )
258 ct = half*akk
259 CALL zaxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
260 CALL zher2( uplo, k-1, cone, a( 1, k ), 1, b( 1, k ),
261 $ 1,
262 $ a, lda )
263 CALL zaxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
264 CALL zdscal( k-1, bkk, a( 1, k ), 1 )
265 a( k, k ) = akk*bkk**2
266 30 CONTINUE
267 ELSE
268*
269* Compute L**H *A*L
270*
271 DO 40 k = 1, n
272*
273* Update the lower triangle of A(1:k,1:k)
274*
275 akk = dble( a( k, k ) )
276 bkk = dble( b( k, k ) )
277 CALL zlacgv( k-1, a( k, 1 ), lda )
278 CALL ztrmv( uplo, 'Conjugate transpose', 'Non-unit',
279 $ k-1,
280 $ b, ldb, a( k, 1 ), lda )
281 ct = half*akk
282 CALL zlacgv( k-1, b( k, 1 ), ldb )
283 CALL zaxpy( k-1, ct, b( k, 1 ), ldb, a( k, 1 ), lda )
284 CALL zher2( uplo, k-1, cone, a( k, 1 ), lda, b( k,
285 $ 1 ),
286 $ ldb, a, lda )
287 CALL zaxpy( k-1, ct, b( k, 1 ), ldb, a( k, 1 ), lda )
288 CALL zlacgv( k-1, b( k, 1 ), ldb )
289 CALL zdscal( k-1, bkk, a( k, 1 ), lda )
290 CALL zlacgv( k-1, a( k, 1 ), lda )
291 a( k, k ) = akk*bkk**2
292 40 CONTINUE
293 END IF
294 END IF
295 RETURN
296*
297* End of ZHEGS2
298*
299 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
Definition zaxpy.f:88
subroutine zhegs2(itype, uplo, n, a, lda, b, ldb, info)
ZHEGS2 reduces a Hermitian definite generalized eigenproblem to standard form, using the factorizatio...
Definition zhegs2.f:126
subroutine zher2(uplo, n, alpha, x, incx, y, incy, a, lda)
ZHER2
Definition zher2.f:150
subroutine zlacgv(n, x, incx)
ZLACGV conjugates a complex vector.
Definition zlacgv.f:72
subroutine zdscal(n, da, zx, incx)
ZDSCAL
Definition zdscal.f:78
subroutine ztrmv(uplo, trans, diag, n, a, lda, x, incx)
ZTRMV
Definition ztrmv.f:147
subroutine ztrsv(uplo, trans, diag, n, a, lda, x, incx)
ZTRSV
Definition ztrsv.f:149