LAPACK  3.4.2 LAPACK: Linear Algebra PACKage
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 *> \htmlonly
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsygs2.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsygs2.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsygs2.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE DSYGS2( 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 * DOUBLE PRECISION A( LDA, * ), B( LDB, * )
29 * ..
30 *
31 *
32 *> \par Purpose:
33 * =============
34 *>
35 *> \verbatim
36 *>
37 *> DSYGS2 reduces a real symmetric-definite generalized eigenproblem
38 *> to standard form.
39 *>
40 *> If ITYPE = 1, the problem is A*x = lambda*B*x,
41 *> and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T)
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**T or L**T *A*L.
45 *>
46 *> B must have been previously factorized as U**T *U or L*L**T by DPOTRF.
47 *> \endverbatim
48 *
49 * Arguments:
50 * ==========
51 *
52 *> \param[in] ITYPE
53 *> \verbatim
54 *> ITYPE is INTEGER
55 *> = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T);
56 *> = 2 or 3: compute U*A*U**T or L**T *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 *> symmetric 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 DOUBLE PRECISION array, dimension (LDA,N)
77 *> On entry, the symmetric 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] B
96 *> \verbatim
97 *> B is DOUBLE PRECISION array, dimension (LDB,N)
98 *> The triangular factor from the Cholesky factorization of B,
99 *> as returned by DPOTRF.
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 doubleSYcomputational
126 *
127 * =====================================================================
128  SUBROUTINE dsygs2( 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  DOUBLE PRECISION a( lda, * ), b( ldb, * )
141 * ..
142 *
143 * =====================================================================
144 *
145 * .. Parameters ..
146  DOUBLE PRECISION one, half
147  parameter( one = 1.0d0, half = 0.5d0 )
148 * ..
149 * .. Local Scalars ..
150  LOGICAL upper
151  INTEGER k
152  DOUBLE PRECISION akk, bkk, ct
153 * ..
154 * .. External Subroutines ..
155  EXTERNAL daxpy, dscal, dsyr2, dtrmv, dtrsv, xerbla
156 * ..
157 * .. Intrinsic Functions ..
158  INTRINSIC max
159 * ..
160 * .. External Functions ..
161  LOGICAL lsame
162  EXTERNAL lsame
163 * ..
164 * .. Executable Statements ..
165 *
166 * Test the input parameters.
167 *
168  info = 0
169  upper = lsame( uplo, 'U' )
170  IF( itype.LT.1 .OR. itype.GT.3 ) THEN
171  info = -1
172  ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
173  info = -2
174  ELSE IF( n.LT.0 ) THEN
175  info = -3
176  ELSE IF( lda.LT.max( 1, n ) ) THEN
177  info = -5
178  ELSE IF( ldb.LT.max( 1, n ) ) THEN
179  info = -7
180  END IF
181  IF( info.NE.0 ) THEN
182  CALL xerbla( 'DSYGS2', -info )
183  return
184  END IF
185 *
186  IF( itype.EQ.1 ) THEN
187  IF( upper ) THEN
188 *
189 * Compute inv(U**T)*A*inv(U)
190 *
191  DO 10 k = 1, n
192 *
193 * Update the upper triangle of A(k:n,k:n)
194 *
195  akk = a( k, k )
196  bkk = b( k, k )
197  akk = akk / bkk**2
198  a( k, k ) = akk
199  IF( k.LT.n ) THEN
200  CALL dscal( n-k, one / bkk, a( k, k+1 ), lda )
201  ct = -half*akk
202  CALL daxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
203  \$ lda )
204  CALL dsyr2( uplo, n-k, -one, a( k, k+1 ), lda,
205  \$ b( k, k+1 ), ldb, a( k+1, k+1 ), lda )
206  CALL daxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
207  \$ lda )
208  CALL dtrsv( uplo, 'Transpose', 'Non-unit', n-k,
209  \$ b( k+1, k+1 ), ldb, a( k, k+1 ), lda )
210  END IF
211  10 continue
212  ELSE
213 *
214 * Compute inv(L)*A*inv(L**T)
215 *
216  DO 20 k = 1, n
217 *
218 * Update the lower triangle of A(k:n,k:n)
219 *
220  akk = a( k, k )
221  bkk = b( k, k )
222  akk = akk / bkk**2
223  a( k, k ) = akk
224  IF( k.LT.n ) THEN
225  CALL dscal( n-k, one / bkk, a( k+1, k ), 1 )
226  ct = -half*akk
227  CALL daxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ), 1 )
228  CALL dsyr2( uplo, n-k, -one, a( k+1, k ), 1,
229  \$ b( k+1, k ), 1, a( k+1, k+1 ), lda )
230  CALL daxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ), 1 )
231  CALL dtrsv( uplo, 'No transpose', 'Non-unit', n-k,
232  \$ b( k+1, k+1 ), ldb, a( k+1, k ), 1 )
233  END IF
234  20 continue
235  END IF
236  ELSE
237  IF( upper ) THEN
238 *
239 * Compute U*A*U**T
240 *
241  DO 30 k = 1, n
242 *
243 * Update the upper triangle of A(1:k,1:k)
244 *
245  akk = a( k, k )
246  bkk = b( k, k )
247  CALL dtrmv( uplo, 'No transpose', 'Non-unit', k-1, b,
248  \$ ldb, a( 1, k ), 1 )
249  ct = half*akk
250  CALL daxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
251  CALL dsyr2( uplo, k-1, one, a( 1, k ), 1, b( 1, k ), 1,
252  \$ a, lda )
253  CALL daxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
254  CALL dscal( k-1, bkk, a( 1, k ), 1 )
255  a( k, k ) = akk*bkk**2
256  30 continue
257  ELSE
258 *
259 * Compute L**T *A*L
260 *
261  DO 40 k = 1, n
262 *
263 * Update the lower triangle of A(1:k,1:k)
264 *
265  akk = a( k, k )
266  bkk = b( k, k )
267  CALL dtrmv( uplo, 'Transpose', 'Non-unit', k-1, b, 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