LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dspgst.f
Go to the documentation of this file.
1*> \brief \b DSPGST
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DSPGST + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dspgst.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dspgst.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dspgst.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DSPGST( ITYPE, UPLO, N, AP, BP, INFO )
20*
21* .. Scalar Arguments ..
22* CHARACTER UPLO
23* INTEGER INFO, ITYPE, N
24* ..
25* .. Array Arguments ..
26* DOUBLE PRECISION AP( * ), BP( * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> DSPGST reduces a real symmetric-definite generalized eigenproblem
36*> to standard form, using packed storage.
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 DPPTRF.
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*> = 'U': Upper triangle of A is stored and B is factored as
61*> U**T*U;
62*> = 'L': Lower triangle of A is stored and B is factored as
63*> L*L**T.
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] AP
73*> \verbatim
74*> AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
75*> On entry, the upper or lower triangle of the symmetric matrix
76*> A, packed columnwise in a linear array. The j-th column of A
77*> is stored in the array AP as follows:
78*> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
79*> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
80*>
81*> On exit, if INFO = 0, the transformed matrix, stored in the
82*> same format as A.
83*> \endverbatim
84*>
85*> \param[in] BP
86*> \verbatim
87*> BP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
88*> The triangular factor from the Cholesky factorization of B,
89*> stored in the same format as A, as returned by DPPTRF.
90*> \endverbatim
91*>
92*> \param[out] INFO
93*> \verbatim
94*> INFO is INTEGER
95*> = 0: successful exit
96*> < 0: if INFO = -i, the i-th argument had an illegal value
97*> \endverbatim
98*
99* Authors:
100* ========
101*
102*> \author Univ. of Tennessee
103*> \author Univ. of California Berkeley
104*> \author Univ. of Colorado Denver
105*> \author NAG Ltd.
106*
107*> \ingroup hpgst
108*
109* =====================================================================
110 SUBROUTINE dspgst( ITYPE, UPLO, N, AP, BP, INFO )
111*
112* -- LAPACK computational routine --
113* -- LAPACK is a software package provided by Univ. of Tennessee, --
114* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
115*
116* .. Scalar Arguments ..
117 CHARACTER UPLO
118 INTEGER INFO, ITYPE, N
119* ..
120* .. Array Arguments ..
121 DOUBLE PRECISION AP( * ), BP( * )
122* ..
123*
124* =====================================================================
125*
126* .. Parameters ..
127 DOUBLE PRECISION ONE, HALF
128 parameter( one = 1.0d0, half = 0.5d0 )
129* ..
130* .. Local Scalars ..
131 LOGICAL UPPER
132 INTEGER J, J1, J1J1, JJ, K, K1, K1K1, KK
133 DOUBLE PRECISION AJJ, AKK, BJJ, BKK, CT
134* ..
135* .. External Subroutines ..
136 EXTERNAL daxpy, dscal, dspmv, dspr2, dtpmv,
137 $ dtpsv,
138 $ xerbla
139* ..
140* .. External Functions ..
141 LOGICAL LSAME
142 DOUBLE PRECISION DDOT
143 EXTERNAL lsame, ddot
144* ..
145* .. Executable Statements ..
146*
147* Test the input parameters.
148*
149 info = 0
150 upper = lsame( uplo, 'U' )
151 IF( itype.LT.1 .OR. itype.GT.3 ) THEN
152 info = -1
153 ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
154 info = -2
155 ELSE IF( n.LT.0 ) THEN
156 info = -3
157 END IF
158 IF( info.NE.0 ) THEN
159 CALL xerbla( 'DSPGST', -info )
160 RETURN
161 END IF
162*
163 IF( itype.EQ.1 ) THEN
164 IF( upper ) THEN
165*
166* Compute inv(U**T)*A*inv(U)
167*
168* J1 and JJ are the indices of A(1,j) and A(j,j)
169*
170 jj = 0
171 DO 10 j = 1, n
172 j1 = jj + 1
173 jj = jj + j
174*
175* Compute the j-th column of the upper triangle of A
176*
177 bjj = bp( jj )
178 CALL dtpsv( uplo, 'Transpose', 'Nonunit', j, bp,
179 $ ap( j1 ), 1 )
180 CALL dspmv( uplo, j-1, -one, ap, bp( j1 ), 1, one,
181 $ ap( j1 ), 1 )
182 CALL dscal( j-1, one / bjj, ap( j1 ), 1 )
183 ap( jj ) = ( ap( jj )-ddot( j-1, ap( j1 ), 1,
184 $ bp( j1 ),
185 $ 1 ) ) / bjj
186 10 CONTINUE
187 ELSE
188*
189* Compute inv(L)*A*inv(L**T)
190*
191* KK and K1K1 are the indices of A(k,k) and A(k+1,k+1)
192*
193 kk = 1
194 DO 20 k = 1, n
195 k1k1 = kk + n - k + 1
196*
197* Update the lower triangle of A(k:n,k:n)
198*
199 akk = ap( kk )
200 bkk = bp( kk )
201 akk = akk / bkk**2
202 ap( kk ) = akk
203 IF( k.LT.n ) THEN
204 CALL dscal( n-k, one / bkk, ap( kk+1 ), 1 )
205 ct = -half*akk
206 CALL daxpy( n-k, ct, bp( kk+1 ), 1, ap( kk+1 ), 1 )
207 CALL dspr2( uplo, n-k, -one, ap( kk+1 ), 1,
208 $ bp( kk+1 ), 1, ap( k1k1 ) )
209 CALL daxpy( n-k, ct, bp( kk+1 ), 1, ap( kk+1 ), 1 )
210 CALL dtpsv( uplo, 'No transpose', 'Non-unit', n-k,
211 $ bp( k1k1 ), ap( kk+1 ), 1 )
212 END IF
213 kk = k1k1
214 20 CONTINUE
215 END IF
216 ELSE
217 IF( upper ) THEN
218*
219* Compute U*A*U**T
220*
221* K1 and KK are the indices of A(1,k) and A(k,k)
222*
223 kk = 0
224 DO 30 k = 1, n
225 k1 = kk + 1
226 kk = kk + k
227*
228* Update the upper triangle of A(1:k,1:k)
229*
230 akk = ap( kk )
231 bkk = bp( kk )
232 CALL dtpmv( uplo, 'No transpose', 'Non-unit', k-1, bp,
233 $ ap( k1 ), 1 )
234 ct = half*akk
235 CALL daxpy( k-1, ct, bp( k1 ), 1, ap( k1 ), 1 )
236 CALL dspr2( uplo, k-1, one, ap( k1 ), 1, bp( k1 ), 1,
237 $ ap )
238 CALL daxpy( k-1, ct, bp( k1 ), 1, ap( k1 ), 1 )
239 CALL dscal( k-1, bkk, ap( k1 ), 1 )
240 ap( kk ) = akk*bkk**2
241 30 CONTINUE
242 ELSE
243*
244* Compute L**T *A*L
245*
246* JJ and J1J1 are the indices of A(j,j) and A(j+1,j+1)
247*
248 jj = 1
249 DO 40 j = 1, n
250 j1j1 = jj + n - j + 1
251*
252* Compute the j-th column of the lower triangle of A
253*
254 ajj = ap( jj )
255 bjj = bp( jj )
256 ap( jj ) = ajj*bjj + ddot( n-j, ap( jj+1 ), 1,
257 $ bp( jj+1 ), 1 )
258 CALL dscal( n-j, bjj, ap( jj+1 ), 1 )
259 CALL dspmv( uplo, n-j, one, ap( j1j1 ), bp( jj+1 ), 1,
260 $ one, ap( jj+1 ), 1 )
261 CALL dtpmv( uplo, 'Transpose', 'Non-unit', n-j+1,
262 $ bp( jj ), ap( jj ), 1 )
263 jj = j1j1
264 40 CONTINUE
265 END IF
266 END IF
267 RETURN
268*
269* End of DSPGST
270*
271 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
Definition daxpy.f:89
subroutine dspgst(itype, uplo, n, ap, bp, info)
DSPGST
Definition dspgst.f:111
subroutine dspmv(uplo, n, alpha, ap, x, incx, beta, y, incy)
DSPMV
Definition dspmv.f:147
subroutine dspr2(uplo, n, alpha, x, incx, y, incy, ap)
DSPR2
Definition dspr2.f:142
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
subroutine dtpmv(uplo, trans, diag, n, ap, x, incx)
DTPMV
Definition dtpmv.f:142
subroutine dtpsv(uplo, trans, diag, n, ap, x, incx)
DTPSV
Definition dtpsv.f:144