LAPACK 3.12.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches

◆ 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.```

Definition at line 226 of file zhpt21.f.

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