LAPACK  3.9.0
LAPACK: Linear Algebra PACKage

◆ zhpt21()

subroutine zhpt21 ( integer  ITYPE,
character  UPLO,
integer  N,
integer  KBAND,
complex*16, dimension( * )  AP,
double precision, dimension( * )  D,
double precision, dimension( * )  E,
complex*16, dimension( ldu, * )  U,
integer  LDU,
complex*16, dimension( * )  VP,
complex*16, dimension( * )  TAU,
complex*16, dimension( * )  WORK,
double precision, dimension( * )  RWORK,
double precision, dimension( 2 )  RESULT 
)

ZHPT21

Purpose:
 ZHPT21  generally checks a decomposition of the form

         A = U S U**H

 where **H means conjugate transpose, A is hermitian, U is
 unitary, and S is diagonal (if KBAND=0) or (real) symmetric
 tridiagonal (if KBAND=1).  If ITYPE=1, then U is represented as
 a dense matrix, otherwise the U is expressed as a product of
 Householder transformations, whose vectors are stored in the
 array "V" and whose scaling constants are in "TAU"; we shall
 use the letter "V" to refer to the product of Householder
 transformations (which should be equal to U).

 Specifically, if ITYPE=1, then:

         RESULT(1) = | A - U S U**H | / ( |A| n ulp ) and
         RESULT(2) = | I - U U**H | / ( n ulp )

 If ITYPE=2, then:

         RESULT(1) = | A - V S V**H | / ( |A| n ulp )

 If ITYPE=3, then:

         RESULT(1) = | I - U V**H | / ( n ulp )

 Packed storage means that, for example, if UPLO='U', then the columns
 of the upper triangle of A are stored one after another, so that
 A(1,j+1) immediately follows A(j,j) in the array AP.  Similarly, if
 UPLO='L', then the columns of the lower triangle of A are stored one
 after another in AP, so that A(j+1,j+1) immediately follows A(n,j)
 in the array AP.  This means that A(i,j) is stored in:

    AP( i + j*(j-1)/2 )                 if UPLO='U'

    AP( i + (2*n-j)*(j-1)/2 )           if UPLO='L'

 The array VP bears the same relation to the matrix V that A does to
 AP.

 For ITYPE > 1, the transformation U is expressed as a product
 of Householder transformations:

    If UPLO='U', then  V = H(n-1)...H(1),  where

        H(j) = I  -  tau(j) v(j) v(j)**H

    and the first j-1 elements of v(j) are stored in V(1:j-1,j+1),
    (i.e., VP( j*(j+1)/2 + 1 : j*(j+1)/2 + j-1 ) ),
    the j-th element is 1, and the last n-j elements are 0.

    If UPLO='L', then  V = H(1)...H(n-1),  where

        H(j) = I  -  tau(j) v(j) v(j)**H

    and the first j elements of v(j) are 0, the (j+1)-st is 1, and the
    (j+2)-nd through n-th elements are stored in V(j+2:n,j) (i.e.,
    in VP( (2*n-j)*(j-1)/2 + j+2 : (2*n-j)*(j-1)/2 + n ) .)
Parameters
[in]ITYPE
          ITYPE is INTEGER
          Specifies the type of tests to be performed.
          1: U expressed as a dense unitary matrix:
             RESULT(1) = | A - U S U**H | / ( |A| n ulp )   and
             RESULT(2) = | I - U U**H | / ( n ulp )

          2: U expressed as a product V of Housholder transformations:
             RESULT(1) = | A - V S V**H | / ( |A| n ulp )

          3: U expressed both as a dense unitary matrix and
             as a product of Housholder transformations:
             RESULT(1) = | I - U V**H | / ( n ulp )
[in]UPLO
          UPLO is CHARACTER
          If UPLO='U', the upper triangle of A and V will be used and
          the (strictly) lower triangle will not be referenced.
          If UPLO='L', the lower triangle of A and V will be used and
          the (strictly) upper triangle will not be referenced.
[in]N
          N is INTEGER
          The size of the matrix.  If it is zero, ZHPT21 does nothing.
          It must be at least zero.
[in]KBAND
          KBAND is INTEGER
          The bandwidth of the matrix.  It may only be zero or one.
          If zero, then S is diagonal, and E is not referenced.  If
          one, then S is symmetric tri-diagonal.
[in]AP
          AP is COMPLEX*16 array, dimension (N*(N+1)/2)
          The original (unfactored) matrix.  It is assumed to be
          hermitian, and contains the columns of just the upper
          triangle (UPLO='U') or only the lower triangle (UPLO='L'),
          packed one after another.
[in]D
          D is DOUBLE PRECISION array, dimension (N)
          The diagonal of the (symmetric tri-) diagonal matrix.
[in]E
          E is DOUBLE PRECISION array, dimension (N)
          The off-diagonal of the (symmetric tri-) diagonal matrix.
          E(1) is the (1,2) and (2,1) element, E(2) is the (2,3) and
          (3,2) element, etc.
          Not referenced if KBAND=0.
[in]U
          U is COMPLEX*16 array, dimension (LDU, N)
          If ITYPE=1 or 3, this contains the unitary matrix in
          the decomposition, expressed as a dense matrix.  If ITYPE=2,
          then it is not referenced.
[in]LDU
          LDU is INTEGER
          The leading dimension of U.  LDU must be at least N and
          at least 1.
[in]VP
          VP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
          If ITYPE=2 or 3, the columns of this array contain the
          Householder vectors used to describe the unitary matrix
          in the decomposition, as described in purpose.
          *NOTE* If ITYPE=2 or 3, V is modified and restored.  The
          subdiagonal (if UPLO='L') or the superdiagonal (if UPLO='U')
          is set to one, and later reset to its original value, during
          the course of the calculation.
          If ITYPE=1, then it is neither referenced nor modified.
[in]TAU
          TAU is COMPLEX*16 array, dimension (N)
          If ITYPE >= 2, then TAU(j) is the scalar factor of
          v(j) v(j)**H in the Householder transformation H(j) of
          the product  U = H(1)...H(n-2)
          If ITYPE < 2, then TAU is not referenced.
[out]WORK
          WORK is COMPLEX*16 array, dimension (N**2)
          Workspace.
[out]RWORK
          RWORK is DOUBLE PRECISION array, dimension (N)
          Workspace.
[out]RESULT
          RESULT is DOUBLE PRECISION array, dimension (2)
          The values computed by the two tests described above.  The
          values are currently limited to 1/ulp, to avoid overflow.
          RESULT(1) is always modified.  RESULT(2) is modified only
          if ITYPE=1.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
December 2016

Definition at line 230 of file zhpt21.f.

230 *
231 * -- LAPACK test routine (version 3.7.0) --
232 * -- LAPACK is a software package provided by Univ. of Tennessee, --
233 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
234 * December 2016
235 *
236 * .. Scalar Arguments ..
237  CHARACTER UPLO
238  INTEGER ITYPE, KBAND, LDU, N
239 * ..
240 * .. Array Arguments ..
241  DOUBLE PRECISION D( * ), E( * ), RESULT( 2 ), RWORK( * )
242  COMPLEX*16 AP( * ), TAU( * ), U( LDU, * ), VP( * ),
243  $ WORK( * )
244 * ..
245 *
246 * =====================================================================
247 *
248 * .. Parameters ..
249  DOUBLE PRECISION ZERO, ONE, TEN
250  parameter( zero = 0.0d+0, one = 1.0d+0, ten = 10.0d+0 )
251  DOUBLE PRECISION HALF
252  parameter( half = 1.0d+0 / 2.0d+0 )
253  COMPLEX*16 CZERO, CONE
254  parameter( czero = ( 0.0d+0, 0.0d+0 ),
255  $ cone = ( 1.0d+0, 0.0d+0 ) )
256 * ..
257 * .. Local Scalars ..
258  LOGICAL LOWER
259  CHARACTER CUPLO
260  INTEGER IINFO, J, JP, JP1, JR, LAP
261  DOUBLE PRECISION ANORM, ULP, UNFL, WNORM
262  COMPLEX*16 TEMP, VSAVE
263 * ..
264 * .. External Functions ..
265  LOGICAL LSAME
266  DOUBLE PRECISION DLAMCH, ZLANGE, ZLANHP
267  COMPLEX*16 ZDOTC
268  EXTERNAL lsame, dlamch, zlange, zlanhp, zdotc
269 * ..
270 * .. External Subroutines ..
271  EXTERNAL zaxpy, zcopy, zgemm, zhpmv, zhpr, zhpr2,
272  $ zlacpy, zlaset, zupmtr
273 * ..
274 * .. Intrinsic Functions ..
275  INTRINSIC dble, dcmplx, max, min
276 * ..
277 * .. Executable Statements ..
278 *
279 * Constants
280 *
281  result( 1 ) = zero
282  IF( itype.EQ.1 )
283  $ result( 2 ) = zero
284  IF( n.LE.0 )
285  $ RETURN
286 *
287  lap = ( n*( n+1 ) ) / 2
288 *
289  IF( lsame( uplo, 'U' ) ) THEN
290  lower = .false.
291  cuplo = 'U'
292  ELSE
293  lower = .true.
294  cuplo = 'L'
295  END IF
296 *
297  unfl = dlamch( 'Safe minimum' )
298  ulp = dlamch( 'Epsilon' )*dlamch( 'Base' )
299 *
300 * Some Error Checks
301 *
302  IF( itype.LT.1 .OR. itype.GT.3 ) THEN
303  result( 1 ) = ten / ulp
304  RETURN
305  END IF
306 *
307 * Do Test 1
308 *
309 * Norm of A:
310 *
311  IF( itype.EQ.3 ) THEN
312  anorm = one
313  ELSE
314  anorm = max( zlanhp( '1', cuplo, n, ap, rwork ), unfl )
315  END IF
316 *
317 * Compute error matrix:
318 *
319  IF( itype.EQ.1 ) THEN
320 *
321 * ITYPE=1: error = A - U S U**H
322 *
323  CALL zlaset( 'Full', n, n, czero, czero, work, n )
324  CALL zcopy( lap, ap, 1, work, 1 )
325 *
326  DO 10 j = 1, n
327  CALL zhpr( cuplo, n, -d( j ), u( 1, j ), 1, work )
328  10 CONTINUE
329 *
330  IF( n.GT.1 .AND. kband.EQ.1 ) THEN
331  DO 20 j = 1, n - 1
332  CALL zhpr2( cuplo, n, -dcmplx( e( j ) ), u( 1, j ), 1,
333  $ u( 1, j-1 ), 1, work )
334  20 CONTINUE
335  END IF
336  wnorm = zlanhp( '1', cuplo, n, work, rwork )
337 *
338  ELSE IF( itype.EQ.2 ) THEN
339 *
340 * ITYPE=2: error = V S V**H - A
341 *
342  CALL zlaset( 'Full', n, n, czero, czero, work, n )
343 *
344  IF( lower ) THEN
345  work( lap ) = d( n )
346  DO 40 j = n - 1, 1, -1
347  jp = ( ( 2*n-j )*( j-1 ) ) / 2
348  jp1 = jp + n - j
349  IF( kband.EQ.1 ) THEN
350  work( jp+j+1 ) = ( cone-tau( j ) )*e( j )
351  DO 30 jr = j + 2, n
352  work( jp+jr ) = -tau( j )*e( j )*vp( jp+jr )
353  30 CONTINUE
354  END IF
355 *
356  IF( tau( j ).NE.czero ) THEN
357  vsave = vp( jp+j+1 )
358  vp( jp+j+1 ) = cone
359  CALL zhpmv( 'L', n-j, cone, work( jp1+j+1 ),
360  $ vp( jp+j+1 ), 1, czero, work( lap+1 ), 1 )
361  temp = -half*tau( j )*zdotc( n-j, work( lap+1 ), 1,
362  $ vp( jp+j+1 ), 1 )
363  CALL zaxpy( n-j, temp, vp( jp+j+1 ), 1, work( lap+1 ),
364  $ 1 )
365  CALL zhpr2( 'L', n-j, -tau( j ), vp( jp+j+1 ), 1,
366  $ work( lap+1 ), 1, work( jp1+j+1 ) )
367 *
368  vp( jp+j+1 ) = vsave
369  END IF
370  work( jp+j ) = d( j )
371  40 CONTINUE
372  ELSE
373  work( 1 ) = d( 1 )
374  DO 60 j = 1, n - 1
375  jp = ( j*( j-1 ) ) / 2
376  jp1 = jp + j
377  IF( kband.EQ.1 ) THEN
378  work( jp1+j ) = ( cone-tau( j ) )*e( j )
379  DO 50 jr = 1, j - 1
380  work( jp1+jr ) = -tau( j )*e( j )*vp( jp1+jr )
381  50 CONTINUE
382  END IF
383 *
384  IF( tau( j ).NE.czero ) THEN
385  vsave = vp( jp1+j )
386  vp( jp1+j ) = cone
387  CALL zhpmv( 'U', j, cone, work, vp( jp1+1 ), 1, czero,
388  $ work( lap+1 ), 1 )
389  temp = -half*tau( j )*zdotc( j, work( lap+1 ), 1,
390  $ vp( jp1+1 ), 1 )
391  CALL zaxpy( j, temp, vp( jp1+1 ), 1, work( lap+1 ),
392  $ 1 )
393  CALL zhpr2( 'U', j, -tau( j ), vp( jp1+1 ), 1,
394  $ work( lap+1 ), 1, work )
395  vp( jp1+j ) = vsave
396  END IF
397  work( jp1+j+1 ) = d( j+1 )
398  60 CONTINUE
399  END IF
400 *
401  DO 70 j = 1, lap
402  work( j ) = work( j ) - ap( j )
403  70 CONTINUE
404  wnorm = zlanhp( '1', cuplo, n, work, rwork )
405 *
406  ELSE IF( itype.EQ.3 ) THEN
407 *
408 * ITYPE=3: error = U V**H - I
409 *
410  IF( n.LT.2 )
411  $ RETURN
412  CALL zlacpy( ' ', n, n, u, ldu, work, n )
413  CALL zupmtr( 'R', cuplo, 'C', n, n, vp, tau, work, n,
414  $ work( n**2+1 ), iinfo )
415  IF( iinfo.NE.0 ) THEN
416  result( 1 ) = ten / ulp
417  RETURN
418  END IF
419 *
420  DO 80 j = 1, n
421  work( ( n+1 )*( j-1 )+1 ) = work( ( n+1 )*( j-1 )+1 ) - cone
422  80 CONTINUE
423 *
424  wnorm = zlange( '1', n, n, work, n, rwork )
425  END IF
426 *
427  IF( anorm.GT.wnorm ) THEN
428  result( 1 ) = ( wnorm / anorm ) / ( n*ulp )
429  ELSE
430  IF( anorm.LT.one ) THEN
431  result( 1 ) = ( min( wnorm, n*anorm ) / anorm ) / ( n*ulp )
432  ELSE
433  result( 1 ) = min( wnorm / anorm, dble( n ) ) / ( n*ulp )
434  END IF
435  END IF
436 *
437 * Do Test 2
438 *
439 * Compute U U**H - I
440 *
441  IF( itype.EQ.1 ) THEN
442  CALL zgemm( 'N', 'C', n, n, n, cone, u, ldu, u, ldu, czero,
443  $ work, n )
444 *
445  DO 90 j = 1, n
446  work( ( n+1 )*( j-1 )+1 ) = work( ( n+1 )*( j-1 )+1 ) - cone
447  90 CONTINUE
448 *
449  result( 2 ) = min( zlange( '1', n, n, work, n, rwork ),
450  $ dble( n ) ) / ( n*ulp )
451  END IF
452 *
453  RETURN
454 *
455 * End of ZHPT21
456 *
Here is the call graph for this function:
Here is the caller graph for this function:
zaxpy
subroutine zaxpy(N, ZA, ZX, INCX, ZY, INCY)
ZAXPY
Definition: zaxpy.f:90
zlange
double precision function zlange(NORM, M, N, A, LDA, WORK)
ZLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition: zlange.f:117
zdotc
complex *16 function zdotc(N, ZX, INCX, ZY, INCY)
ZDOTC
Definition: zdotc.f:85
zhpr2
subroutine zhpr2(UPLO, N, ALPHA, X, INCX, Y, INCY, AP)
ZHPR2
Definition: zhpr2.f:147
zcopy
subroutine zcopy(N, ZX, INCX, ZY, INCY)
ZCOPY
Definition: zcopy.f:83
zgemm
subroutine zgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
ZGEMM
Definition: zgemm.f:189
zupmtr
subroutine zupmtr(SIDE, UPLO, TRANS, M, N, AP, TAU, C, LDC, WORK, INFO)
ZUPMTR
Definition: zupmtr.f:152
zlaset
subroutine zlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: zlaset.f:108
zlacpy
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
Definition: zlacpy.f:105
zhpmv
subroutine zhpmv(UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY)
ZHPMV
Definition: zhpmv.f:151
lsame
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
zhpr
subroutine zhpr(UPLO, N, ALPHA, X, INCX, AP)
ZHPR
Definition: zhpr.f:132
zlanhp
double precision function zlanhp(NORM, UPLO, N, AP, WORK)
ZLANHP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: zlanhp.f:119
dlamch
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:70