LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
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 *> \htmlonly
9 *> Download ZHEGS2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhegs2.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhegs2.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhegs2.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE ZHEGS2( 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*16 A( LDA, * ), B( LDB, * )
29 * ..
30 *
31 *
32 *> \par Purpose:
33 * =============
34 *>
35 *> \verbatim
36 *>
37 *> ZHEGS2 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*16 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*16 array, dimension (LDB,N)
98 *> The triangular factor from the Cholesky factorization of B,
99 *> as returned by ZPOTRF.
100 *> \endverbatim
101 *>
102 *> \param[in] LDB
103 *> \verbatim
104 *> LDB is INTEGER
105 *> The leading dimension of the array B. LDB >= max(1,N).
106 *> \endverbatim
107 *>
108 *> \param[out] INFO
109 *> \verbatim
110 *> INFO is INTEGER
111 *> = 0: successful exit.
112 *> < 0: if INFO = -i, the i-th argument had an illegal value.
113 *> \endverbatim
114 *
115 * Authors:
116 * ========
117 *
118 *> \author Univ. of Tennessee
119 *> \author Univ. of California Berkeley
120 *> \author Univ. of Colorado Denver
121 *> \author NAG Ltd.
122 *
123 *> \date September 2012
124 *
125 *> \ingroup complex16HEcomputational
126 *
127 * =====================================================================
128  SUBROUTINE zhegs2( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
129 *
130 * -- LAPACK computational routine (version 3.4.2) --
131 * -- LAPACK is a software package provided by Univ. of Tennessee, --
132 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
133 * September 2012
134 *
135 * .. Scalar Arguments ..
136  CHARACTER uplo
137  INTEGER info, itype, lda, ldb, n
138 * ..
139 * .. Array Arguments ..
140  COMPLEX*16 a( lda, * ), b( ldb, * )
141 * ..
142 *
143 * =====================================================================
144 *
145 * .. Parameters ..
146  DOUBLE PRECISION one, half
147  parameter( one = 1.0d+0, half = 0.5d+0 )
148  COMPLEX*16 cone
149  parameter( cone = ( 1.0d+0, 0.0d+0 ) )
150 * ..
151 * .. Local Scalars ..
152  LOGICAL upper
153  INTEGER k
154  DOUBLE PRECISION akk, bkk
155  COMPLEX*16 ct
156 * ..
157 * .. External Subroutines ..
158  EXTERNAL xerbla, zaxpy, zdscal, zher2, zlacgv, ztrmv,
159  $ ztrsv
160 * ..
161 * .. Intrinsic Functions ..
162  INTRINSIC max
163 * ..
164 * .. External Functions ..
165  LOGICAL lsame
166  EXTERNAL lsame
167 * ..
168 * .. Executable Statements ..
169 *
170 * Test the input parameters.
171 *
172  info = 0
173  upper = lsame( uplo, 'U' )
174  IF( itype.LT.1 .OR. itype.GT.3 ) THEN
175  info = -1
176  ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
177  info = -2
178  ELSE IF( n.LT.0 ) THEN
179  info = -3
180  ELSE IF( lda.LT.max( 1, n ) ) THEN
181  info = -5
182  ELSE IF( ldb.LT.max( 1, n ) ) THEN
183  info = -7
184  END IF
185  IF( info.NE.0 ) THEN
186  CALL xerbla( 'ZHEGS2', -info )
187  return
188  END IF
189 *
190  IF( itype.EQ.1 ) THEN
191  IF( upper ) THEN
192 *
193 * Compute inv(U**H)*A*inv(U)
194 *
195  DO 10 k = 1, n
196 *
197 * Update the upper triangle of A(k:n,k:n)
198 *
199  akk = a( k, k )
200  bkk = b( k, k )
201  akk = akk / bkk**2
202  a( k, k ) = akk
203  IF( k.LT.n ) THEN
204  CALL zdscal( n-k, one / bkk, a( k, k+1 ), lda )
205  ct = -half*akk
206  CALL zlacgv( n-k, a( k, k+1 ), lda )
207  CALL zlacgv( n-k, b( k, k+1 ), ldb )
208  CALL zaxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
209  $ lda )
210  CALL zher2( uplo, n-k, -cone, a( k, k+1 ), lda,
211  $ b( k, k+1 ), ldb, a( k+1, k+1 ), lda )
212  CALL zaxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
213  $ lda )
214  CALL zlacgv( n-k, b( k, k+1 ), ldb )
215  CALL ztrsv( uplo, 'Conjugate transpose', 'Non-unit',
216  $ n-k, b( k+1, k+1 ), ldb, a( k, k+1 ),
217  $ lda )
218  CALL zlacgv( n-k, a( k, k+1 ), lda )
219  END IF
220  10 continue
221  ELSE
222 *
223 * Compute inv(L)*A*inv(L**H)
224 *
225  DO 20 k = 1, n
226 *
227 * Update the lower triangle of A(k:n,k:n)
228 *
229  akk = a( k, k )
230  bkk = b( k, k )
231  akk = akk / bkk**2
232  a( k, k ) = akk
233  IF( k.LT.n ) THEN
234  CALL zdscal( n-k, one / bkk, a( k+1, k ), 1 )
235  ct = -half*akk
236  CALL zaxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ), 1 )
237  CALL zher2( uplo, n-k, -cone, a( k+1, k ), 1,
238  $ b( k+1, k ), 1, a( k+1, k+1 ), lda )
239  CALL zaxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ), 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 = a( k, k )
255  bkk = 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 ), 1,
261  $ a, lda )
262  CALL zaxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
263  CALL zdscal( k-1, bkk, a( 1, k ), 1 )
264  a( k, k ) = akk*bkk**2
265  30 continue
266  ELSE
267 *
268 * Compute L**H *A*L
269 *
270  DO 40 k = 1, n
271 *
272 * Update the lower triangle of A(1:k,1:k)
273 *
274  akk = a( k, k )
275  bkk = b( k, k )
276  CALL zlacgv( k-1, a( k, 1 ), lda )
277  CALL ztrmv( uplo, 'Conjugate transpose', 'Non-unit', k-1,
278  $ b, ldb, a( k, 1 ), lda )
279  ct = half*akk
280  CALL zlacgv( k-1, b( k, 1 ), ldb )
281  CALL zaxpy( k-1, ct, b( k, 1 ), ldb, a( k, 1 ), lda )
282  CALL zher2( uplo, k-1, cone, a( k, 1 ), lda, b( k, 1 ),
283  $ ldb, a, lda )
284  CALL zaxpy( k-1, ct, b( k, 1 ), ldb, a( k, 1 ), lda )
285  CALL zlacgv( k-1, b( k, 1 ), ldb )
286  CALL zdscal( k-1, bkk, a( k, 1 ), lda )
287  CALL zlacgv( k-1, a( k, 1 ), lda )
288  a( k, k ) = akk*bkk**2
289  40 continue
290  END IF
291  END IF
292  return
293 *
294 * End of ZHEGS2
295 *
296  END