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