LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dsygs2.f
Go to the documentation of this file.
1*> \brief \b DSYGS2 reduces a symmetric definite generalized eigenproblem to standard form, using the factorization results obtained from spotrf (unblocked algorithm).
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DSYGS2 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsygs2.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsygs2.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsygs2.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DSYGS2( 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* DOUBLE PRECISION A( LDA, * ), B( LDB, * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> DSYGS2 reduces a real symmetric-definite generalized eigenproblem
36*> to standard form.
37*>
38*> If ITYPE = 1, the problem is A*x = lambda*B*x,
39*> and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T)
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**T or L**T *A*L.
43*>
44*> B must have been previously factorized as U**T *U or L*L**T by DPOTRF.
45*> \endverbatim
46*
47* Arguments:
48* ==========
49*
50*> \param[in] ITYPE
51*> \verbatim
52*> ITYPE is INTEGER
53*> = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T);
54*> = 2 or 3: compute U*A*U**T or L**T *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*> symmetric 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 DOUBLE PRECISION array, dimension (LDA,N)
75*> On entry, the symmetric 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] B
94*> \verbatim
95*> B is DOUBLE PRECISION array, dimension (LDB,N)
96*> The triangular factor from the Cholesky factorization of B,
97*> as returned by DPOTRF.
98*> \endverbatim
99*>
100*> \param[in] LDB
101*> \verbatim
102*> LDB is INTEGER
103*> The leading dimension of the array B. LDB >= max(1,N).
104*> \endverbatim
105*>
106*> \param[out] INFO
107*> \verbatim
108*> INFO is INTEGER
109*> = 0: successful exit.
110*> < 0: if INFO = -i, the i-th argument had an illegal value.
111*> \endverbatim
112*
113* Authors:
114* ========
115*
116*> \author Univ. of Tennessee
117*> \author Univ. of California Berkeley
118*> \author Univ. of Colorado Denver
119*> \author NAG Ltd.
120*
121*> \ingroup hegs2
122*
123* =====================================================================
124 SUBROUTINE dsygs2( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
125*
126* -- LAPACK computational routine --
127* -- LAPACK is a software package provided by Univ. of Tennessee, --
128* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
129*
130* .. Scalar Arguments ..
131 CHARACTER UPLO
132 INTEGER INFO, ITYPE, LDA, LDB, N
133* ..
134* .. Array Arguments ..
135 DOUBLE PRECISION A( LDA, * ), B( LDB, * )
136* ..
137*
138* =====================================================================
139*
140* .. Parameters ..
141 DOUBLE PRECISION ONE, HALF
142 parameter( one = 1.0d0, half = 0.5d0 )
143* ..
144* .. Local Scalars ..
145 LOGICAL UPPER
146 INTEGER K
147 DOUBLE PRECISION AKK, BKK, CT
148* ..
149* .. External Subroutines ..
150 EXTERNAL daxpy, dscal, dsyr2, dtrmv, dtrsv,
151 $ xerbla
152* ..
153* .. Intrinsic Functions ..
154 INTRINSIC max
155* ..
156* .. External Functions ..
157 LOGICAL LSAME
158 EXTERNAL lsame
159* ..
160* .. Executable Statements ..
161*
162* Test the input parameters.
163*
164 info = 0
165 upper = lsame( uplo, 'U' )
166 IF( itype.LT.1 .OR. itype.GT.3 ) THEN
167 info = -1
168 ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
169 info = -2
170 ELSE IF( n.LT.0 ) THEN
171 info = -3
172 ELSE IF( lda.LT.max( 1, n ) ) THEN
173 info = -5
174 ELSE IF( ldb.LT.max( 1, n ) ) THEN
175 info = -7
176 END IF
177 IF( info.NE.0 ) THEN
178 CALL xerbla( 'DSYGS2', -info )
179 RETURN
180 END IF
181*
182 IF( itype.EQ.1 ) THEN
183 IF( upper ) THEN
184*
185* Compute inv(U**T)*A*inv(U)
186*
187 DO 10 k = 1, n
188*
189* Update the upper triangle of A(k:n,k:n)
190*
191 akk = a( k, k )
192 bkk = b( k, k )
193 akk = akk / bkk**2
194 a( k, k ) = akk
195 IF( k.LT.n ) THEN
196 CALL dscal( n-k, one / bkk, a( k, k+1 ), lda )
197 ct = -half*akk
198 CALL daxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
199 $ lda )
200 CALL dsyr2( uplo, n-k, -one, a( k, k+1 ), lda,
201 $ b( k, k+1 ), ldb, a( k+1, k+1 ), lda )
202 CALL daxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
203 $ lda )
204 CALL dtrsv( uplo, 'Transpose', 'Non-unit', n-k,
205 $ b( k+1, k+1 ), ldb, a( k, k+1 ), lda )
206 END IF
207 10 CONTINUE
208 ELSE
209*
210* Compute inv(L)*A*inv(L**T)
211*
212 DO 20 k = 1, n
213*
214* Update the lower triangle of A(k:n,k:n)
215*
216 akk = a( k, k )
217 bkk = b( k, k )
218 akk = akk / bkk**2
219 a( k, k ) = akk
220 IF( k.LT.n ) THEN
221 CALL dscal( n-k, one / bkk, a( k+1, k ), 1 )
222 ct = -half*akk
223 CALL daxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ),
224 $ 1 )
225 CALL dsyr2( uplo, n-k, -one, a( k+1, k ), 1,
226 $ b( k+1, k ), 1, a( k+1, k+1 ), lda )
227 CALL daxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ),
228 $ 1 )
229 CALL dtrsv( uplo, 'No transpose', 'Non-unit', n-k,
230 $ b( k+1, k+1 ), ldb, a( k+1, k ), 1 )
231 END IF
232 20 CONTINUE
233 END IF
234 ELSE
235 IF( upper ) THEN
236*
237* Compute U*A*U**T
238*
239 DO 30 k = 1, n
240*
241* Update the upper triangle of A(1:k,1:k)
242*
243 akk = a( k, k )
244 bkk = b( k, k )
245 CALL dtrmv( uplo, 'No transpose', 'Non-unit', k-1, b,
246 $ ldb, a( 1, k ), 1 )
247 ct = half*akk
248 CALL daxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
249 CALL dsyr2( uplo, k-1, one, a( 1, k ), 1, b( 1, k ),
250 $ 1,
251 $ a, lda )
252 CALL daxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
253 CALL dscal( k-1, bkk, a( 1, k ), 1 )
254 a( k, k ) = akk*bkk**2
255 30 CONTINUE
256 ELSE
257*
258* Compute L**T *A*L
259*
260 DO 40 k = 1, n
261*
262* Update the lower triangle of A(1:k,1:k)
263*
264 akk = a( k, k )
265 bkk = b( k, k )
266 CALL dtrmv( uplo, 'Transpose', 'Non-unit', k-1, b,
267 $ ldb,
268 $ a( k, 1 ), lda )
269 ct = half*akk
270 CALL daxpy( k-1, ct, b( k, 1 ), ldb, a( k, 1 ), lda )
271 CALL dsyr2( uplo, k-1, one, a( k, 1 ), lda, b( k, 1 ),
272 $ ldb, a, lda )
273 CALL daxpy( k-1, ct, b( k, 1 ), ldb, a( k, 1 ), lda )
274 CALL dscal( k-1, bkk, a( k, 1 ), lda )
275 a( k, k ) = akk*bkk**2
276 40 CONTINUE
277 END IF
278 END IF
279 RETURN
280*
281* End of DSYGS2
282*
283 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
Definition daxpy.f:89
subroutine dsygs2(itype, uplo, n, a, lda, b, ldb, info)
DSYGS2 reduces a symmetric definite generalized eigenproblem to standard form, using the factorizatio...
Definition dsygs2.f:125
subroutine dsyr2(uplo, n, alpha, x, incx, y, incy, a, lda)
DSYR2
Definition dsyr2.f:147
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
subroutine dtrmv(uplo, trans, diag, n, a, lda, x, incx)
DTRMV
Definition dtrmv.f:147
subroutine dtrsv(uplo, trans, diag, n, a, lda, x, incx)
DTRSV
Definition dtrsv.f:143