LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

◆ ssygs2()

subroutine ssygs2 ( integer itype,
character uplo,
integer n,
real, dimension( lda, * ) a,
integer lda,
real, dimension( ldb, * ) b,
integer ldb,
integer info )

SSYGS2 reduces a symmetric definite generalized eigenproblem to standard form, using the factorization results obtained from spotrf (unblocked algorithm).

Download SSYGS2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!> !> SSYGS2 reduces a real symmetric-definite generalized eigenproblem !> to standard form. !> !> If ITYPE = 1, the problem is A*x = lambda*B*x, !> and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T) !> !> If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or !> B*A*x = lambda*x, and A is overwritten by U*A*U**T or L**T *A*L. !> !> B must have been previously factorized as U**T *U or L*L**T by SPOTRF. !>
Parameters
[in]ITYPE
!> ITYPE is INTEGER !> = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T); !> = 2 or 3: compute U*A*U**T or L**T *A*L. !>
[in]UPLO
!> UPLO is CHARACTER*1 !> Specifies whether the upper or lower triangular part of the !> symmetric matrix A is stored, and how B has been factorized. !> = 'U': Upper triangular !> = 'L': Lower triangular !>
[in]N
!> N is INTEGER !> The order of the matrices A and B. N >= 0. !>
[in,out]A
!> A is REAL array, dimension (LDA,N) !> On entry, the symmetric matrix A. If UPLO = 'U', the leading !> n by n upper triangular part of A contains the upper !> triangular part of the matrix A, and the strictly lower !> triangular part of A is not referenced. If UPLO = 'L', the !> leading n by n lower triangular part of A contains the lower !> triangular part of the matrix A, and the strictly upper !> triangular part of A is not referenced. !> !> On exit, if INFO = 0, the transformed matrix, stored in the !> same format as A. !>
[in]LDA
!> LDA is INTEGER !> The leading dimension of the array A. LDA >= max(1,N). !>
[in]B
!> B is REAL array, dimension (LDB,N) !> The triangular factor from the Cholesky factorization of B, !> as returned by SPOTRF. !>
[in]LDB
!> LDB is INTEGER !> The leading dimension of the array B. LDB >= max(1,N). !>
[out]INFO
!> INFO is INTEGER !> = 0: successful exit. !> < 0: if INFO = -i, the i-th argument had an illegal value. !>
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 124 of file ssygs2.f.

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 REAL A( LDA, * ), B( LDB, * )
136* ..
137*
138* =====================================================================
139*
140* .. Parameters ..
141 REAL ONE, HALF
142 parameter( one = 1.0, half = 0.5 )
143* ..
144* .. Local Scalars ..
145 LOGICAL UPPER
146 INTEGER K
147 REAL AKK, BKK, CT
148* ..
149* .. External Subroutines ..
150 EXTERNAL saxpy, sscal, ssyr2, strmv, strsv,
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( 'SSYGS2', -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 sscal( n-k, one / bkk, a( k, k+1 ), lda )
197 ct = -half*akk
198 CALL saxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
199 $ lda )
200 CALL ssyr2( uplo, n-k, -one, a( k, k+1 ), lda,
201 $ b( k, k+1 ), ldb, a( k+1, k+1 ), lda )
202 CALL saxpy( n-k, ct, b( k, k+1 ), ldb, a( k, k+1 ),
203 $ lda )
204 CALL strsv( 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 sscal( n-k, one / bkk, a( k+1, k ), 1 )
222 ct = -half*akk
223 CALL saxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ),
224 $ 1 )
225 CALL ssyr2( uplo, n-k, -one, a( k+1, k ), 1,
226 $ b( k+1, k ), 1, a( k+1, k+1 ), lda )
227 CALL saxpy( n-k, ct, b( k+1, k ), 1, a( k+1, k ),
228 $ 1 )
229 CALL strsv( 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 strmv( uplo, 'No transpose', 'Non-unit', k-1, b,
246 $ ldb, a( 1, k ), 1 )
247 ct = half*akk
248 CALL saxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
249 CALL ssyr2( uplo, k-1, one, a( 1, k ), 1, b( 1, k ),
250 $ 1,
251 $ a, lda )
252 CALL saxpy( k-1, ct, b( 1, k ), 1, a( 1, k ), 1 )
253 CALL sscal( 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 strmv( uplo, 'Transpose', 'Non-unit', k-1, b,
267 $ ldb,
268 $ a( k, 1 ), lda )
269 ct = half*akk
270 CALL saxpy( k-1, ct, b( k, 1 ), ldb, a( k, 1 ), lda )
271 CALL ssyr2( uplo, k-1, one, a( k, 1 ), lda, b( k, 1 ),
272 $ ldb, a, lda )
273 CALL saxpy( k-1, ct, b( k, 1 ), ldb, a( k, 1 ), lda )
274 CALL sscal( 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 SSYGS2
282*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine saxpy(n, sa, sx, incx, sy, incy)
SAXPY
Definition saxpy.f:89
subroutine ssyr2(uplo, n, alpha, x, incx, y, incy, a, lda)
SSYR2
Definition ssyr2.f:147
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine strmv(uplo, trans, diag, n, a, lda, x, incx)
STRMV
Definition strmv.f:147
subroutine strsv(uplo, trans, diag, n, a, lda, x, incx)
STRSV
Definition strsv.f:149
Here is the call graph for this function:
Here is the caller graph for this function: