LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
ssytrd.f
Go to the documentation of this file.
1*> \brief \b SSYTRD
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SSYTRD + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssytrd.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssytrd.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssytrd.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SSYTRD( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO )
20*
21* .. Scalar Arguments ..
22* CHARACTER UPLO
23* INTEGER INFO, LDA, LWORK, N
24* ..
25* .. Array Arguments ..
26* REAL A( LDA, * ), D( * ), E( * ), TAU( * ),
27* $ WORK( * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> SSYTRD reduces a real symmetric matrix A to real symmetric
37*> tridiagonal form T by an orthogonal similarity transformation:
38*> Q**T * A * Q = T.
39*> \endverbatim
40*
41* Arguments:
42* ==========
43*
44*> \param[in] UPLO
45*> \verbatim
46*> UPLO is CHARACTER*1
47*> = 'U': Upper triangle of A is stored;
48*> = 'L': Lower triangle of A is stored.
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 REAL 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 REAL 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 REAL 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 REAL array, dimension (N-1)
102*> The scalar factors of the elementary reflectors (see Further
103*> Details).
104*> \endverbatim
105*>
106*> \param[out] WORK
107*> \verbatim
108*> WORK is REAL array, dimension (MAX(1,LWORK))
109*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
110*> \endverbatim
111*>
112*> \param[in] LWORK
113*> \verbatim
114*> LWORK is INTEGER
115*> The dimension of the array WORK. LWORK >= 1.
116*> For optimum performance LWORK >= N*NB, where NB is the
117*> optimal blocksize.
118*>
119*> If LWORK = -1, then a workspace query is assumed; the routine
120*> only calculates the optimal size of the WORK array, returns
121*> this value as the first entry of the WORK array, and no error
122*> message related to LWORK is issued by XERBLA.
123*> \endverbatim
124*>
125*> \param[out] INFO
126*> \verbatim
127*> INFO is INTEGER
128*> = 0: successful exit
129*> < 0: if INFO = -i, the i-th argument had an illegal value
130*> \endverbatim
131*
132* Authors:
133* ========
134*
135*> \author Univ. of Tennessee
136*> \author Univ. of California Berkeley
137*> \author Univ. of Colorado Denver
138*> \author NAG Ltd.
139*
140*> \ingroup hetrd
141*
142*> \par Further Details:
143* =====================
144*>
145*> \verbatim
146*>
147*> If UPLO = 'U', the matrix Q is represented as a product of elementary
148*> reflectors
149*>
150*> Q = H(n-1) . . . H(2) H(1).
151*>
152*> Each H(i) has the form
153*>
154*> H(i) = I - tau * v * v**T
155*>
156*> where tau is a real scalar, and v is a real vector with
157*> v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
158*> A(1:i-1,i+1), and tau in TAU(i).
159*>
160*> If UPLO = 'L', the matrix Q is represented as a product of elementary
161*> reflectors
162*>
163*> Q = H(1) H(2) . . . H(n-1).
164*>
165*> Each H(i) has the form
166*>
167*> H(i) = I - tau * v * v**T
168*>
169*> where tau is a real scalar, and v is a real vector with
170*> v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
171*> and tau in TAU(i).
172*>
173*> The contents of A on exit are illustrated by the following examples
174*> with n = 5:
175*>
176*> if UPLO = 'U': if UPLO = 'L':
177*>
178*> ( d e v2 v3 v4 ) ( d )
179*> ( d e v3 v4 ) ( e d )
180*> ( d e v4 ) ( v1 e d )
181*> ( d e ) ( v1 v2 e d )
182*> ( d ) ( v1 v2 v3 e d )
183*>
184*> where d and e denote diagonal and off-diagonal elements of T, and vi
185*> denotes an element of the vector defining H(i).
186*> \endverbatim
187*>
188* =====================================================================
189 SUBROUTINE ssytrd( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK,
190 $ INFO )
191*
192* -- LAPACK computational routine --
193* -- LAPACK is a software package provided by Univ. of Tennessee, --
194* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
195*
196* .. Scalar Arguments ..
197 CHARACTER UPLO
198 INTEGER INFO, LDA, LWORK, N
199* ..
200* .. Array Arguments ..
201 REAL A( LDA, * ), D( * ), E( * ), TAU( * ),
202 $ work( * )
203* ..
204*
205* =====================================================================
206*
207* .. Parameters ..
208 REAL ONE
209 parameter( one = 1.0e+0 )
210* ..
211* .. Local Scalars ..
212 LOGICAL LQUERY, UPPER
213 INTEGER I, IINFO, IWS, J, KK, LDWORK, LWKOPT, NB,
214 $ nbmin, nx
215* ..
216* .. External Subroutines ..
217 EXTERNAL slatrd, ssyr2k, ssytd2, xerbla
218* ..
219* .. Intrinsic Functions ..
220 INTRINSIC max
221* ..
222* .. External Functions ..
223 LOGICAL LSAME
224 INTEGER ILAENV
225 REAL SROUNDUP_LWORK
226 EXTERNAL lsame, ilaenv, sroundup_lwork
227* ..
228* .. Executable Statements ..
229*
230* Test the input parameters
231*
232 info = 0
233 upper = lsame( uplo, 'U' )
234 lquery = ( lwork.EQ.-1 )
235 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
236 info = -1
237 ELSE IF( n.LT.0 ) THEN
238 info = -2
239 ELSE IF( lda.LT.max( 1, n ) ) THEN
240 info = -4
241 ELSE IF( lwork.LT.1 .AND. .NOT.lquery ) THEN
242 info = -9
243 END IF
244*
245 IF( info.EQ.0 ) THEN
246*
247* Determine the block size.
248*
249 nb = ilaenv( 1, 'SSYTRD', uplo, n, -1, -1, -1 )
250 lwkopt = max( 1, n*nb )
251 work( 1 ) = sroundup_lwork(lwkopt)
252 END IF
253*
254 IF( info.NE.0 ) THEN
255 CALL xerbla( 'SSYTRD', -info )
256 RETURN
257 ELSE IF( lquery ) THEN
258 RETURN
259 END IF
260*
261* Quick return if possible
262*
263 IF( n.EQ.0 ) THEN
264 work( 1 ) = 1
265 RETURN
266 END IF
267*
268 nx = n
269 iws = 1
270 IF( nb.GT.1 .AND. nb.LT.n ) THEN
271*
272* Determine when to cross over from blocked to unblocked code
273* (last block is always handled by unblocked code).
274*
275 nx = max( nb, ilaenv( 3, 'SSYTRD', uplo, n, -1, -1, -1 ) )
276 IF( nx.LT.n ) THEN
277*
278* Determine if workspace is large enough for blocked code.
279*
280 ldwork = n
281 iws = ldwork*nb
282 IF( lwork.LT.iws ) THEN
283*
284* Not enough workspace to use optimal NB: determine the
285* minimum value of NB, and reduce NB or force use of
286* unblocked code by setting NX = N.
287*
288 nb = max( lwork / ldwork, 1 )
289 nbmin = ilaenv( 2, 'SSYTRD', uplo, n, -1, -1, -1 )
290 IF( nb.LT.nbmin )
291 $ nx = n
292 END IF
293 ELSE
294 nx = n
295 END IF
296 ELSE
297 nb = 1
298 END IF
299*
300 IF( upper ) THEN
301*
302* Reduce the upper triangle of A.
303* Columns 1:kk are handled by the unblocked method.
304*
305 kk = n - ( ( n-nx+nb-1 ) / nb )*nb
306 DO 20 i = n - nb + 1, kk + 1, -nb
307*
308* Reduce columns i:i+nb-1 to tridiagonal form and form the
309* matrix W which is needed to update the unreduced part of
310* the matrix
311*
312 CALL slatrd( uplo, i+nb-1, nb, a, lda, e, tau, work,
313 $ ldwork )
314*
315* Update the unreduced submatrix A(1:i-1,1:i-1), using an
316* update of the form: A := A - V*W**T - W*V**T
317*
318 CALL ssyr2k( uplo, 'No transpose', i-1, nb, -one, a( 1,
319 $ i ),
320 $ lda, work, ldwork, one, a, lda )
321*
322* Copy superdiagonal elements back into A, and diagonal
323* elements into D
324*
325 DO 10 j = i, i + nb - 1
326 a( j-1, j ) = e( j-1 )
327 d( j ) = a( j, j )
328 10 CONTINUE
329 20 CONTINUE
330*
331* Use unblocked code to reduce the last or only block
332*
333 CALL ssytd2( uplo, kk, a, lda, d, e, tau, iinfo )
334 ELSE
335*
336* Reduce the lower triangle of A
337*
338 DO 40 i = 1, n - nx, nb
339*
340* Reduce columns i:i+nb-1 to tridiagonal form and form the
341* matrix W which is needed to update the unreduced part of
342* the matrix
343*
344 CALL slatrd( uplo, n-i+1, nb, a( i, i ), lda, e( i ),
345 $ tau( i ), work, ldwork )
346*
347* Update the unreduced submatrix A(i+ib:n,i+ib:n), using
348* an update of the form: A := A - V*W**T - W*V**T
349*
350 CALL ssyr2k( uplo, 'No transpose', n-i-nb+1, nb, -one,
351 $ a( i+nb, i ), lda, work( nb+1 ), ldwork, one,
352 $ a( i+nb, i+nb ), lda )
353*
354* Copy subdiagonal elements back into A, and diagonal
355* elements into D
356*
357 DO 30 j = i, i + nb - 1
358 a( j+1, j ) = e( j )
359 d( j ) = a( j, j )
360 30 CONTINUE
361 40 CONTINUE
362*
363* Use unblocked code to reduce the last or only block
364*
365 CALL ssytd2( uplo, n-i+1, a( i, i ), lda, d( i ), e( i ),
366 $ tau( i ), iinfo )
367 END IF
368*
369 work( 1 ) = sroundup_lwork(lwkopt)
370 RETURN
371*
372* End of SSYTRD
373*
374 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine ssyr2k(uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SSYR2K
Definition ssyr2k.f:192
subroutine ssytd2(uplo, n, a, lda, d, e, tau, info)
SSYTD2 reduces a symmetric matrix to real symmetric tridiagonal form by an orthogonal similarity tran...
Definition ssytd2.f:171
subroutine ssytrd(uplo, n, a, lda, d, e, tau, work, lwork, info)
SSYTRD
Definition ssytrd.f:191
subroutine slatrd(uplo, n, nb, a, lda, e, tau, w, ldw)
SLATRD reduces the first nb rows and columns of a symmetric/Hermitian matrix A to real tridiagonal fo...
Definition slatrd.f:196