LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dsptrd.f
Go to the documentation of this file.
1*> \brief \b DSPTRD
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DSPTRD + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsptrd.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsptrd.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsptrd.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DSPTRD( UPLO, N, AP, D, E, TAU, INFO )
20*
21* .. Scalar Arguments ..
22* CHARACTER UPLO
23* INTEGER INFO, N
24* ..
25* .. Array Arguments ..
26* DOUBLE PRECISION AP( * ), D( * ), E( * ), TAU( * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> DSPTRD reduces a real symmetric matrix A stored in packed form to
36*> symmetric tridiagonal form T by an orthogonal similarity
37*> transformation: Q**T * A * Q = T.
38*> \endverbatim
39*
40* Arguments:
41* ==========
42*
43*> \param[in] UPLO
44*> \verbatim
45*> UPLO is CHARACTER*1
46*> = 'U': Upper triangle of A is stored;
47*> = 'L': Lower triangle of A is stored.
48*> \endverbatim
49*>
50*> \param[in] N
51*> \verbatim
52*> N is INTEGER
53*> The order of the matrix A. N >= 0.
54*> \endverbatim
55*>
56*> \param[in,out] AP
57*> \verbatim
58*> AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
59*> On entry, the upper or lower triangle of the symmetric matrix
60*> A, packed columnwise in a linear array. The j-th column of A
61*> is stored in the array AP as follows:
62*> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
63*> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
64*> On exit, if UPLO = 'U', the diagonal and first superdiagonal
65*> of A are overwritten by the corresponding elements of the
66*> tridiagonal matrix T, and the elements above the first
67*> superdiagonal, with the array TAU, represent the orthogonal
68*> matrix Q as a product of elementary reflectors; if UPLO
69*> = 'L', the diagonal and first subdiagonal of A are over-
70*> written by the corresponding elements of the tridiagonal
71*> matrix T, and the elements below the first subdiagonal, with
72*> the array TAU, represent the orthogonal matrix Q as a product
73*> of elementary reflectors. See Further Details.
74*> \endverbatim
75*>
76*> \param[out] D
77*> \verbatim
78*> D is DOUBLE PRECISION array, dimension (N)
79*> The diagonal elements of the tridiagonal matrix T:
80*> D(i) = A(i,i).
81*> \endverbatim
82*>
83*> \param[out] E
84*> \verbatim
85*> E is DOUBLE PRECISION array, dimension (N-1)
86*> The off-diagonal elements of the tridiagonal matrix T:
87*> E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
88*> \endverbatim
89*>
90*> \param[out] TAU
91*> \verbatim
92*> TAU is DOUBLE PRECISION array, dimension (N-1)
93*> The scalar factors of the elementary reflectors (see Further
94*> Details).
95*> \endverbatim
96*>
97*> \param[out] INFO
98*> \verbatim
99*> INFO is INTEGER
100*> = 0: successful exit
101*> < 0: if INFO = -i, the i-th argument had an illegal value
102*> \endverbatim
103*
104* Authors:
105* ========
106*
107*> \author Univ. of Tennessee
108*> \author Univ. of California Berkeley
109*> \author Univ. of Colorado Denver
110*> \author NAG Ltd.
111*
112*> \ingroup hptrd
113*
114*> \par Further Details:
115* =====================
116*>
117*> \verbatim
118*>
119*> If UPLO = 'U', the matrix Q is represented as a product of elementary
120*> reflectors
121*>
122*> Q = H(n-1) . . . H(2) H(1).
123*>
124*> Each H(i) has the form
125*>
126*> H(i) = I - tau * v * v**T
127*>
128*> where tau is a real scalar, and v is a real vector with
129*> v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in AP,
130*> overwriting A(1:i-1,i+1), and tau is stored in TAU(i).
131*>
132*> If UPLO = 'L', the matrix Q is represented as a product of elementary
133*> reflectors
134*>
135*> Q = H(1) H(2) . . . H(n-1).
136*>
137*> Each H(i) has the form
138*>
139*> H(i) = I - tau * v * v**T
140*>
141*> where tau is a real scalar, and v is a real vector with
142*> v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in AP,
143*> overwriting A(i+2:n,i), and tau is stored in TAU(i).
144*> \endverbatim
145*>
146* =====================================================================
147 SUBROUTINE dsptrd( UPLO, N, AP, D, E, TAU, INFO )
148*
149* -- LAPACK computational routine --
150* -- LAPACK is a software package provided by Univ. of Tennessee, --
151* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
152*
153* .. Scalar Arguments ..
154 CHARACTER UPLO
155 INTEGER INFO, N
156* ..
157* .. Array Arguments ..
158 DOUBLE PRECISION AP( * ), D( * ), E( * ), TAU( * )
159* ..
160*
161* =====================================================================
162*
163* .. Parameters ..
164 DOUBLE PRECISION ONE, ZERO, HALF
165 parameter( one = 1.0d0, zero = 0.0d0,
166 $ half = 1.0d0 / 2.0d0 )
167* ..
168* .. Local Scalars ..
169 LOGICAL UPPER
170 INTEGER I, I1, I1I1, II
171 DOUBLE PRECISION ALPHA, TAUI
172* ..
173* .. External Subroutines ..
174 EXTERNAL daxpy, dlarfg, dspmv, dspr2, xerbla
175* ..
176* .. External Functions ..
177 LOGICAL LSAME
178 DOUBLE PRECISION DDOT
179 EXTERNAL lsame, ddot
180* ..
181* .. Executable Statements ..
182*
183* Test the input parameters
184*
185 info = 0
186 upper = lsame( uplo, 'U' )
187 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
188 info = -1
189 ELSE IF( n.LT.0 ) THEN
190 info = -2
191 END IF
192 IF( info.NE.0 ) THEN
193 CALL xerbla( 'DSPTRD', -info )
194 RETURN
195 END IF
196*
197* Quick return if possible
198*
199 IF( n.LE.0 )
200 $ RETURN
201*
202 IF( upper ) THEN
203*
204* Reduce the upper triangle of A.
205* I1 is the index in AP of A(1,I+1).
206*
207 i1 = n*( n-1 ) / 2 + 1
208 DO 10 i = n - 1, 1, -1
209*
210* Generate elementary reflector H(i) = I - tau * v * v**T
211* to annihilate A(1:i-1,i+1)
212*
213 CALL dlarfg( i, ap( i1+i-1 ), ap( i1 ), 1, taui )
214 e( i ) = ap( i1+i-1 )
215*
216 IF( taui.NE.zero ) THEN
217*
218* Apply H(i) from both sides to A(1:i,1:i)
219*
220 ap( i1+i-1 ) = one
221*
222* Compute y := tau * A * v storing y in TAU(1:i)
223*
224 CALL dspmv( uplo, i, taui, ap, ap( i1 ), 1, zero, tau,
225 $ 1 )
226*
227* Compute w := y - 1/2 * tau * (y**T *v) * v
228*
229 alpha = -half*taui*ddot( i, tau, 1, ap( i1 ), 1 )
230 CALL daxpy( i, alpha, ap( i1 ), 1, tau, 1 )
231*
232* Apply the transformation as a rank-2 update:
233* A := A - v * w**T - w * v**T
234*
235 CALL dspr2( uplo, i, -one, ap( i1 ), 1, tau, 1, ap )
236*
237 ap( i1+i-1 ) = e( i )
238 END IF
239 d( i+1 ) = ap( i1+i )
240 tau( i ) = taui
241 i1 = i1 - i
242 10 CONTINUE
243 d( 1 ) = ap( 1 )
244 ELSE
245*
246* Reduce the lower triangle of A. II is the index in AP of
247* A(i,i) and I1I1 is the index of A(i+1,i+1).
248*
249 ii = 1
250 DO 20 i = 1, n - 1
251 i1i1 = ii + n - i + 1
252*
253* Generate elementary reflector H(i) = I - tau * v * v**T
254* to annihilate A(i+2:n,i)
255*
256 CALL dlarfg( n-i, ap( ii+1 ), ap( ii+2 ), 1, taui )
257 e( i ) = ap( ii+1 )
258*
259 IF( taui.NE.zero ) THEN
260*
261* Apply H(i) from both sides to A(i+1:n,i+1:n)
262*
263 ap( ii+1 ) = one
264*
265* Compute y := tau * A * v storing y in TAU(i:n-1)
266*
267 CALL dspmv( uplo, n-i, taui, ap( i1i1 ), ap( ii+1 ),
268 $ 1,
269 $ zero, tau( i ), 1 )
270*
271* Compute w := y - 1/2 * tau * (y**T *v) * v
272*
273 alpha = -half*taui*ddot( n-i, tau( i ), 1, ap( ii+1 ),
274 $ 1 )
275 CALL daxpy( n-i, alpha, ap( ii+1 ), 1, tau( i ), 1 )
276*
277* Apply the transformation as a rank-2 update:
278* A := A - v * w**T - w * v**T
279*
280 CALL dspr2( uplo, n-i, -one, ap( ii+1 ), 1, tau( i ),
281 $ 1,
282 $ ap( i1i1 ) )
283*
284 ap( ii+1 ) = e( i )
285 END IF
286 d( i ) = ap( ii )
287 tau( i ) = taui
288 ii = i1i1
289 20 CONTINUE
290 d( n ) = ap( ii )
291 END IF
292*
293 RETURN
294*
295* End of DSPTRD
296*
297 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
Definition daxpy.f:89
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 dsptrd(uplo, n, ap, d, e, tau, info)
DSPTRD
Definition dsptrd.f:148
subroutine dlarfg(n, alpha, x, incx, tau)
DLARFG generates an elementary reflector (Householder matrix).
Definition dlarfg.f:104