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