LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ ssptrd()

subroutine ssptrd ( character uplo,
integer n,
real, dimension( * ) ap,
real, dimension( * ) d,
real, dimension( * ) e,
real, dimension( * ) tau,
integer info )

SSPTRD

Download SSPTRD + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SSPTRD reduces a real symmetric matrix A stored in packed form to
!> symmetric tridiagonal form T by an orthogonal similarity
!> transformation: Q**T * A * Q = T.
!> 
Parameters
[in]UPLO
!>          UPLO is CHARACTER*1
!>          = 'U':  Upper triangle of A is stored;
!>          = 'L':  Lower triangle of A is stored.
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in,out]AP
!>          AP is REAL array, dimension (N*(N+1)/2)
!>          On entry, the upper or lower triangle of the symmetric matrix
!>          A, packed columnwise in a linear array.  The j-th column of A
!>          is stored in the array AP as follows:
!>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
!>          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
!>          On exit, if UPLO = 'U', the diagonal and first superdiagonal
!>          of A are overwritten by the corresponding elements of the
!>          tridiagonal matrix T, and the elements above the first
!>          superdiagonal, with the array TAU, represent the orthogonal
!>          matrix Q as a product of elementary reflectors; if UPLO
!>          = 'L', the diagonal and first subdiagonal of A are over-
!>          written by the corresponding elements of the tridiagonal
!>          matrix T, and the elements below the first subdiagonal, with
!>          the array TAU, represent the orthogonal matrix Q as a product
!>          of elementary reflectors. See Further Details.
!> 
[out]D
!>          D is REAL array, dimension (N)
!>          The diagonal elements of the tridiagonal matrix T:
!>          D(i) = A(i,i).
!> 
[out]E
!>          E is REAL array, dimension (N-1)
!>          The off-diagonal elements of the tridiagonal matrix T:
!>          E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
!> 
[out]TAU
!>          TAU is REAL array, dimension (N-1)
!>          The scalar factors of the elementary reflectors (see Further
!>          Details).
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!>
!>  If UPLO = 'U', the matrix Q is represented as a product of elementary
!>  reflectors
!>
!>     Q = H(n-1) . . . H(2) H(1).
!>
!>  Each H(i) has the form
!>
!>     H(i) = I - tau * v * v**T
!>
!>  where tau is a real scalar, and v is a real vector with
!>  v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in AP,
!>  overwriting A(1:i-1,i+1), and tau is stored in TAU(i).
!>
!>  If UPLO = 'L', the matrix Q is represented as a product of elementary
!>  reflectors
!>
!>     Q = H(1) H(2) . . . H(n-1).
!>
!>  Each H(i) has the form
!>
!>     H(i) = I - tau * v * v**T
!>
!>  where tau is a real scalar, and v is a real vector with
!>  v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in AP,
!>  overwriting A(i+2:n,i), and tau is stored in TAU(i).
!> 

Definition at line 147 of file ssptrd.f.

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 REAL AP( * ), D( * ), E( * ), TAU( * )
159* ..
160*
161* =====================================================================
162*
163* .. Parameters ..
164 REAL ONE, ZERO, HALF
165 parameter( one = 1.0, zero = 0.0, half = 1.0 / 2.0 )
166* ..
167* .. Local Scalars ..
168 LOGICAL UPPER
169 INTEGER I, I1, I1I1, II
170 REAL ALPHA, TAUI
171* ..
172* .. External Subroutines ..
173 EXTERNAL saxpy, slarfg, sspmv, sspr2, xerbla
174* ..
175* .. External Functions ..
176 LOGICAL LSAME
177 REAL SDOT
178 EXTERNAL lsame, sdot
179* ..
180* .. Executable Statements ..
181*
182* Test the input parameters
183*
184 info = 0
185 upper = lsame( uplo, 'U' )
186 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
187 info = -1
188 ELSE IF( n.LT.0 ) THEN
189 info = -2
190 END IF
191 IF( info.NE.0 ) THEN
192 CALL xerbla( 'SSPTRD', -info )
193 RETURN
194 END IF
195*
196* Quick return if possible
197*
198 IF( n.LE.0 )
199 $ RETURN
200*
201 IF( upper ) THEN
202*
203* Reduce the upper triangle of A.
204* I1 is the index in AP of A(1,I+1).
205*
206 i1 = n*( n-1 ) / 2 + 1
207 DO 10 i = n - 1, 1, -1
208*
209* Generate elementary reflector H(i) = I - tau * v * v**T
210* to annihilate A(1:i-1,i+1)
211*
212 CALL slarfg( i, ap( i1+i-1 ), ap( i1 ), 1, taui )
213 e( i ) = ap( i1+i-1 )
214*
215 IF( taui.NE.zero ) THEN
216*
217* Apply H(i) from both sides to A(1:i,1:i)
218*
219 ap( i1+i-1 ) = one
220*
221* Compute y := tau * A * v storing y in TAU(1:i)
222*
223 CALL sspmv( uplo, i, taui, ap, ap( i1 ), 1, zero, tau,
224 $ 1 )
225*
226* Compute w := y - 1/2 * tau * (y**T *v) * v
227*
228 alpha = -half*taui*sdot( i, tau, 1, ap( i1 ), 1 )
229 CALL saxpy( i, alpha, ap( i1 ), 1, tau, 1 )
230*
231* Apply the transformation as a rank-2 update:
232* A := A - v * w**T - w * v**T
233*
234 CALL sspr2( uplo, i, -one, ap( i1 ), 1, tau, 1, ap )
235*
236 ap( i1+i-1 ) = e( i )
237 END IF
238 d( i+1 ) = ap( i1+i )
239 tau( i ) = taui
240 i1 = i1 - i
241 10 CONTINUE
242 d( 1 ) = ap( 1 )
243 ELSE
244*
245* Reduce the lower triangle of A. II is the index in AP of
246* A(i,i) and I1I1 is the index of A(i+1,i+1).
247*
248 ii = 1
249 DO 20 i = 1, n - 1
250 i1i1 = ii + n - i + 1
251*
252* Generate elementary reflector H(i) = I - tau * v * v**T
253* to annihilate A(i+2:n,i)
254*
255 CALL slarfg( n-i, ap( ii+1 ), ap( ii+2 ), 1, taui )
256 e( i ) = ap( ii+1 )
257*
258 IF( taui.NE.zero ) THEN
259*
260* Apply H(i) from both sides to A(i+1:n,i+1:n)
261*
262 ap( ii+1 ) = one
263*
264* Compute y := tau * A * v storing y in TAU(i:n-1)
265*
266 CALL sspmv( uplo, n-i, taui, ap( i1i1 ), ap( ii+1 ),
267 $ 1,
268 $ zero, tau( i ), 1 )
269*
270* Compute w := y - 1/2 * tau * (y**T *v) * v
271*
272 alpha = -half*taui*sdot( n-i, tau( i ), 1, ap( ii+1 ),
273 $ 1 )
274 CALL saxpy( n-i, alpha, ap( ii+1 ), 1, tau( i ), 1 )
275*
276* Apply the transformation as a rank-2 update:
277* A := A - v * w**T - w * v**T
278*
279 CALL sspr2( uplo, n-i, -one, ap( ii+1 ), 1, tau( i ),
280 $ 1,
281 $ ap( i1i1 ) )
282*
283 ap( ii+1 ) = e( i )
284 END IF
285 d( i ) = ap( ii )
286 tau( i ) = taui
287 ii = i1i1
288 20 CONTINUE
289 d( n ) = ap( ii )
290 END IF
291*
292 RETURN
293*
294* End of SSPTRD
295*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine saxpy(n, sa, sx, incx, sy, incy)
SAXPY
Definition saxpy.f:89
real function sdot(n, sx, incx, sy, incy)
SDOT
Definition sdot.f:82
subroutine sspmv(uplo, n, alpha, ap, x, incx, beta, y, incy)
SSPMV
Definition sspmv.f:147
subroutine sspr2(uplo, n, alpha, x, incx, y, incy, ap)
SSPR2
Definition sspr2.f:142
subroutine slarfg(n, alpha, x, incx, tau)
SLARFG generates an elementary reflector (Householder matrix).
Definition slarfg.f:104
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
Here is the call graph for this function:
Here is the caller graph for this function: