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

◆ chetd2()

subroutine chetd2 ( character uplo,
integer n,
complex, dimension( lda, * ) a,
integer lda,
real, dimension( * ) d,
real, dimension( * ) e,
complex, dimension( * ) tau,
integer info )

CHETD2 reduces a Hermitian matrix to real symmetric tridiagonal form by an unitary similarity transformation (unblocked algorithm).

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

Purpose:
!>
!> CHETD2 reduces a complex Hermitian matrix A to real symmetric
!> tridiagonal form T by a unitary similarity transformation:
!> Q**H * A * Q = T.
!> 
Parameters
[in]UPLO
!>          UPLO is CHARACTER*1
!>          Specifies whether the upper or lower triangular part of the
!>          Hermitian matrix A is stored:
!>          = 'U':  Upper triangular
!>          = 'L':  Lower triangular
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in,out]A
!>          A is COMPLEX array, dimension (LDA,N)
!>          On entry, the Hermitian matrix A.  If UPLO = 'U', the leading
!>          n-by-n upper triangular part of A contains the upper
!>          triangular part of the matrix A, and the strictly lower
!>          triangular part of A is not referenced.  If UPLO = 'L', the
!>          leading n-by-n lower triangular part of A contains the lower
!>          triangular part of the matrix A, and the strictly upper
!>          triangular part of A is not referenced.
!>          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 unitary
!>          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 unitary matrix Q as a product
!>          of elementary reflectors. See Further Details.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,N).
!> 
[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 COMPLEX 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**H
!>
!>  where tau is a complex scalar, and v is a complex vector with
!>  v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
!>  A(1:i-1,i+1), and tau 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**H
!>
!>  where tau is a complex scalar, and v is a complex vector with
!>  v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
!>  and tau in TAU(i).
!>
!>  The contents of A on exit are illustrated by the following examples
!>  with n = 5:
!>
!>  if UPLO = 'U':                       if UPLO = 'L':
!>
!>    (  d   e   v2  v3  v4 )              (  d                  )
!>    (      d   e   v3  v4 )              (  e   d              )
!>    (          d   e   v4 )              (  v1  e   d          )
!>    (              d   e  )              (  v1  v2  e   d      )
!>    (                  d  )              (  v1  v2  v3  e   d  )
!>
!>  where d and e denote diagonal and off-diagonal elements of T, and vi
!>  denotes an element of the vector defining H(i).
!> 

Definition at line 172 of file chetd2.f.

173*
174* -- LAPACK computational routine --
175* -- LAPACK is a software package provided by Univ. of Tennessee, --
176* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
177*
178* .. Scalar Arguments ..
179 CHARACTER UPLO
180 INTEGER INFO, LDA, N
181* ..
182* .. Array Arguments ..
183 REAL D( * ), E( * )
184 COMPLEX A( LDA, * ), TAU( * )
185* ..
186*
187* =====================================================================
188*
189* .. Parameters ..
190 COMPLEX ONE, ZERO, HALF
191 parameter( one = ( 1.0e+0, 0.0e+0 ),
192 $ zero = ( 0.0e+0, 0.0e+0 ),
193 $ half = ( 0.5e+0, 0.0e+0 ) )
194* ..
195* .. Local Scalars ..
196 LOGICAL UPPER
197 INTEGER I
198 COMPLEX ALPHA, TAUI
199* ..
200* .. External Subroutines ..
201 EXTERNAL caxpy, chemv, cher2, clarfg, xerbla
202* ..
203* .. External Functions ..
204 LOGICAL LSAME
205 COMPLEX CDOTC
206 EXTERNAL lsame, cdotc
207* ..
208* .. Intrinsic Functions ..
209 INTRINSIC max, min, real
210* ..
211* .. Executable Statements ..
212*
213* Test the input parameters
214*
215 info = 0
216 upper = lsame( uplo, 'U' )
217 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
218 info = -1
219 ELSE IF( n.LT.0 ) THEN
220 info = -2
221 ELSE IF( lda.LT.max( 1, n ) ) THEN
222 info = -4
223 END IF
224 IF( info.NE.0 ) THEN
225 CALL xerbla( 'CHETD2', -info )
226 RETURN
227 END IF
228*
229* Quick return if possible
230*
231 IF( n.LE.0 )
232 $ RETURN
233*
234 IF( upper ) THEN
235*
236* Reduce the upper triangle of A
237*
238 a( n, n ) = real( a( n, n ) )
239 DO 10 i = n - 1, 1, -1
240*
241* Generate elementary reflector H(i) = I - tau * v * v**H
242* to annihilate A(1:i-1,i+1)
243*
244 alpha = a( i, i+1 )
245 CALL clarfg( i, alpha, a( 1, i+1 ), 1, taui )
246 e( i ) = real( alpha )
247*
248 IF( taui.NE.zero ) THEN
249*
250* Apply H(i) from both sides to A(1:i,1:i)
251*
252 a( i, i+1 ) = one
253*
254* Compute x := tau * A * v storing x in TAU(1:i)
255*
256 CALL chemv( uplo, i, taui, a, lda, a( 1, i+1 ), 1,
257 $ zero,
258 $ tau, 1 )
259*
260* Compute w := x - 1/2 * tau * (x**H * v) * v
261*
262 alpha = -half*taui*cdotc( i, tau, 1, a( 1, i+1 ), 1 )
263 CALL caxpy( i, alpha, a( 1, i+1 ), 1, tau, 1 )
264*
265* Apply the transformation as a rank-2 update:
266* A := A - v * w**H - w * v**H
267*
268 CALL cher2( uplo, i, -one, a( 1, i+1 ), 1, tau, 1, a,
269 $ lda )
270*
271 ELSE
272 a( i, i ) = real( a( i, i ) )
273 END IF
274 a( i, i+1 ) = e( i )
275 d( i+1 ) = real( a( i+1, i+1 ) )
276 tau( i ) = taui
277 10 CONTINUE
278 d( 1 ) = real( a( 1, 1 ) )
279 ELSE
280*
281* Reduce the lower triangle of A
282*
283 a( 1, 1 ) = real( a( 1, 1 ) )
284 DO 20 i = 1, n - 1
285*
286* Generate elementary reflector H(i) = I - tau * v * v**H
287* to annihilate A(i+2:n,i)
288*
289 alpha = a( i+1, i )
290 CALL clarfg( n-i, alpha, a( min( i+2, n ), i ), 1, taui )
291 e( i ) = real( alpha )
292*
293 IF( taui.NE.zero ) THEN
294*
295* Apply H(i) from both sides to A(i+1:n,i+1:n)
296*
297 a( i+1, i ) = one
298*
299* Compute x := tau * A * v storing y in TAU(i:n-1)
300*
301 CALL chemv( uplo, n-i, taui, a( i+1, i+1 ), lda,
302 $ a( i+1, i ), 1, zero, tau( i ), 1 )
303*
304* Compute w := x - 1/2 * tau * (x**H * v) * v
305*
306 alpha = -half*taui*cdotc( n-i, tau( i ), 1, a( i+1,
307 $ i ),
308 $ 1 )
309 CALL caxpy( n-i, alpha, a( i+1, i ), 1, tau( i ), 1 )
310*
311* Apply the transformation as a rank-2 update:
312* A := A - v * w**H - w * v**H
313*
314 CALL cher2( uplo, n-i, -one, a( i+1, i ), 1, tau( i ),
315 $ 1,
316 $ a( i+1, i+1 ), lda )
317*
318 ELSE
319 a( i+1, i+1 ) = real( a( i+1, i+1 ) )
320 END IF
321 a( i+1, i ) = e( i )
322 d( i ) = real( a( i, i ) )
323 tau( i ) = taui
324 20 CONTINUE
325 d( n ) = real( a( n, n ) )
326 END IF
327*
328 RETURN
329*
330* End of CHETD2
331*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine caxpy(n, ca, cx, incx, cy, incy)
CAXPY
Definition caxpy.f:88
complex function cdotc(n, cx, incx, cy, incy)
CDOTC
Definition cdotc.f:83
subroutine chemv(uplo, n, alpha, a, lda, x, incx, beta, y, incy)
CHEMV
Definition chemv.f:154
subroutine cher2(uplo, n, alpha, x, incx, y, incy, a, lda)
CHER2
Definition cher2.f:150
subroutine clarfg(n, alpha, x, incx, tau)
CLARFG generates an elementary reflector (Householder matrix).
Definition clarfg.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: