1 SUBROUTINE DLATRD( UPLO, N, NB, A, LDA, E, TAU, W, LDW )
3 ! -- LAPACK auxiliary routine (version 3.1) --
4 ! Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
7 ! .. Scalar Arguments ..
9 INTEGER LDA, LDW, N, NB
11 ! .. Array Arguments ..
12 DOUBLE PRECISION A( LDA, * ), E( * ), TAU( * ), W( LDW, * )
18 ! DLATRD reduces NB rows and columns of a real symmetric matrix A to
19 ! symmetric tridiagonal form by an orthogonal similarity
20 ! transformation Q' * A * Q, and returns the matrices V and W which are
21 ! needed to apply the transformation to the unreduced part of A.
23 ! If UPLO = 'U', DLATRD reduces the last NB rows and columns of a
24 ! matrix, of which the upper triangle is supplied;
25 ! if UPLO = 'L', DLATRD reduces the first NB rows and columns of a
26 ! matrix, of which the lower triangle is supplied.
28 ! This is an auxiliary routine called by DSYTRD.
33 ! UPLO (input) CHARACTER*1
34 ! Specifies whether the upper or lower triangular part of the
35 ! symmetric matrix A is stored:
36 ! = 'U': Upper triangular
37 ! = 'L': Lower triangular
40 ! The order of the matrix A.
43 ! The number of rows and columns to be reduced.
45 ! A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
46 ! On entry, the symmetric matrix A. If UPLO = 'U', the leading
47 ! n-by-n upper triangular part of A contains the upper
48 ! triangular part of the matrix A, and the strictly lower
49 ! triangular part of A is not referenced. If UPLO = 'L', the
50 ! leading n-by-n lower triangular part of A contains the lower
51 ! triangular part of the matrix A, and the strictly upper
52 ! triangular part of A is not referenced.
54 ! if UPLO = 'U', the last NB columns have been reduced to
55 ! tridiagonal form, with the diagonal elements overwriting
56 ! the diagonal elements of A; the elements above the diagonal
57 ! with the array TAU, represent the orthogonal matrix Q as a
58 ! product of elementary reflectors;
59 ! if UPLO = 'L', the first NB columns have been reduced to
60 ! tridiagonal form, with the diagonal elements overwriting
61 ! the diagonal elements of A; the elements below the diagonal
62 ! with the array TAU, represent the orthogonal matrix Q as a
63 ! product of elementary reflectors.
64 ! See Further Details.
67 ! The leading dimension of the array A. LDA >= (1,N).
69 ! E (output) DOUBLE PRECISION array, dimension (N-1)
70 ! If UPLO = 'U', E(n-nb:n-1) contains the superdiagonal
71 ! elements of the last NB columns of the reduced matrix;
72 ! if UPLO = 'L', E(1:nb) contains the subdiagonal elements of
73 ! the first NB columns of the reduced matrix.
75 ! TAU (output) DOUBLE PRECISION array, dimension (N-1)
76 ! The scalar factors of the elementary reflectors, stored in
77 ! TAU(n-nb:n-1) if UPLO = 'U', and in TAU(1:nb) if UPLO = 'L'.
78 ! See Further Details.
80 ! W (output) DOUBLE PRECISION array, dimension (LDW,NB)
81 ! The n-by-nb matrix W required to update the unreduced part
85 ! The leading dimension of the array W. LDW >= max(1,N).
90 ! If UPLO = 'U', the matrix Q is represented as a product of elementary
93 ! Q = H(n) H(n-1) . . . H(n-nb+1).
95 ! Each H(i) has the form
97 ! H(i) = I - tau * v * v'
99 ! where tau is a real scalar, and v is a real vector with
100 ! v(i:n) = 0 and v(i-1) = 1; v(1:i-1) is stored on exit in A(1:i-1,i),
101 ! and tau in TAU(i-1).
103 ! If UPLO = 'L', the matrix Q is represented as a product of elementary
106 ! Q = H(1) H(2) . . . H(nb).
108 ! Each H(i) has the form
110 ! H(i) = I - tau * v * v'
112 ! where tau is a real scalar, and v is a real vector with
113 ! v(1:i) = 0 and v(i+1) = 1; v(i+1:n) is stored on exit in A(i+1:n,i),
116 ! The elements of the vectors v together form the n-by-nb matrix V
117 ! which is needed, with W, to apply the transformation to the unreduced
118 ! part of the matrix, using a symmetric rank-2k update of the form:
119 ! A := A - V*W' - W*V'.
121 ! The contents of A on exit are illustrated by the following examples
122 ! with n = 5 and nb = 2:
124 ! if UPLO = 'U': if UPLO = 'L':
126 ! ( a a a v4 v5 ) ( d )
127 ! ( a a v4 v5 ) ( 1 d )
128 ! ( a 1 v5 ) ( v1 1 a )
129 ! ( d 1 ) ( v1 v2 a a )
130 ! ( d ) ( v1 v2 a a a )
132 ! where d denotes a diagonal element of the reduced matrix, a denotes
133 ! an element of the original matrix that is unchanged, and vi denotes
134 ! an element of the vector defining H(i).
136 ! =====================================================================
139 DOUBLE PRECISION ZERO, ONE, HALF
140 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, HALF = 0.5D+0 )
142 ! .. Local Scalars ..
144 DOUBLE PRECISION ALPHA
146 ! .. External Subroutines ..
147 ! EXTERNAL DAXPY, DGEMV, DLARFG, DSCAL, DSYMV
149 ! .. External Functions ..
151 ! DOUBLE PRECISION DDOT
152 ! EXTERNAL LSAME, DDOT
154 ! .. Intrinsic Functions ..
157 ! .. Executable Statements ..
159 ! Quick return if possible
164 IF( LSAME( UPLO, 'U' ) ) THEN
166 ! Reduce last NB columns of upper triangle
168 DO 10 I = N, N - NB + 1, -1
174 CALL DGEMV( 'No transpose', I, N-I, -ONE, A( 1, I+1 ), &
175 LDA, W( I, IW+1 ), LDW, ONE, A( 1, I ), 1 )
176 CALL DGEMV( 'No transpose', I, N-I, -ONE, W( 1, IW+1 ), &
177 LDW, A( I, I+1 ), LDA, ONE, A( 1, I ), 1 )
181 ! Generate elementary reflector H(i) to annihilate
184 CALL DLARFG( I-1, A( I-1, I ), A( 1, I ), 1, TAU( I-1 ) )
185 E( I-1 ) = A( I-1, I )
190 CALL DSYMV( 'Upper', I-1, ONE, A, LDA, A( 1, I ), 1, &
191 ZERO, W( 1, IW ), 1 )
193 CALL DGEMV( 'Transpose', I-1, N-I, ONE, W( 1, IW+1 ), &
194 LDW, A( 1, I ), 1, ZERO, W( I+1, IW ), 1 )
195 CALL DGEMV( 'No transpose', I-1, N-I, -ONE, &
196 A( 1, I+1 ), LDA, W( I+1, IW ), 1, ONE, &
198 CALL DGEMV( 'Transpose', I-1, N-I, ONE, A( 1, I+1 ), &
199 LDA, A( 1, I ), 1, ZERO, W( I+1, IW ), 1 )
200 CALL DGEMV( 'No transpose', I-1, N-I, -ONE, &
201 W( 1, IW+1 ), LDW, W( I+1, IW ), 1, ONE, &
204 CALL DSCAL( I-1, TAU( I-1 ), W( 1, IW ), 1 )
205 ALPHA = -HALF*TAU( I-1 )*DDOT( I-1, W( 1, IW ), 1, &
207 CALL DAXPY( I-1, ALPHA, A( 1, I ), 1, W( 1, IW ), 1 )
213 ! Reduce first NB columns of lower triangle
219 CALL DGEMV( 'No transpose', N-I+1, I-1, -ONE, A( I, 1 ), &
220 LDA, W( I, 1 ), LDW, ONE, A( I, I ), 1 )
221 CALL DGEMV( 'No transpose', N-I+1, I-1, -ONE, W( I, 1 ), &
222 LDW, A( I, 1 ), LDA, ONE, A( I, I ), 1 )
225 ! Generate elementary reflector H(i) to annihilate
228 CALL DLARFG( N-I, A( I+1, I ), A( MIN( I+2, N ), I ), 1, &
235 CALL DSYMV( 'Lower', N-I, ONE, A( I+1, I+1 ), LDA, &
236 A( I+1, I ), 1, ZERO, W( I+1, I ), 1 )
237 CALL DGEMV( 'Transpose', N-I, I-1, ONE, W( I+1, 1 ), LDW, &
238 A( I+1, I ), 1, ZERO, W( 1, I ), 1 )
239 CALL DGEMV( 'No transpose', N-I, I-1, -ONE, A( I+1, 1 ), &
240 LDA, W( 1, I ), 1, ONE, W( I+1, I ), 1 )
241 CALL DGEMV( 'Transpose', N-I, I-1, ONE, A( I+1, 1 ), LDA, &
242 A( I+1, I ), 1, ZERO, W( 1, I ), 1 )
243 CALL DGEMV( 'No transpose', N-I, I-1, -ONE, W( I+1, 1 ), &
244 LDW, W( 1, I ), 1, ONE, W( I+1, I ), 1 )
245 CALL DSCAL( N-I, TAU( I ), W( I+1, I ), 1 )
246 ALPHA = -HALF*TAU( I )*DDOT( N-I, W( I+1, I ), 1, &
248 CALL DAXPY( N-I, ALPHA, A( I+1, I ), 1, W( I+1, I ), 1 )
258 END SUBROUTINE DLATRD