LAPACK 3.3.1
Linear Algebra PACKage

zhpt01.f

Go to the documentation of this file.
00001       SUBROUTINE ZHPT01( UPLO, N, A, AFAC, IPIV, C, LDC, RWORK, RESID )
00002 *
00003 *  -- LAPACK test routine (version 3.1) --
00004 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00005 *     November 2006
00006 *
00007 *     .. Scalar Arguments ..
00008       CHARACTER          UPLO
00009       INTEGER            LDC, N
00010       DOUBLE PRECISION   RESID
00011 *     ..
00012 *     .. Array Arguments ..
00013       INTEGER            IPIV( * )
00014       DOUBLE PRECISION   RWORK( * )
00015       COMPLEX*16         A( * ), AFAC( * ), C( LDC, * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  ZHPT01 reconstructs a Hermitian indefinite packed matrix A from its
00022 *  block L*D*L' or U*D*U' factorization and computes the residual
00023 *     norm( C - A ) / ( N * norm(A) * EPS ),
00024 *  where C is the reconstructed matrix, EPS is the machine epsilon,
00025 *  L' is the conjugate transpose of L, and U' is the conjugate transpose
00026 *  of U.
00027 *
00028 *  Arguments
00029 *  ==========
00030 *
00031 *  UPLO    (input) CHARACTER*1
00032 *          Specifies whether the upper or lower triangular part of the
00033 *          Hermitian matrix A is stored:
00034 *          = 'U':  Upper triangular
00035 *          = 'L':  Lower triangular
00036 *
00037 *  N       (input) INTEGER
00038 *          The number of rows and columns of the matrix A.  N >= 0.
00039 *
00040 *  A       (input) COMPLEX*16 array, dimension (N*(N+1)/2)
00041 *          The original Hermitian matrix A, stored as a packed
00042 *          triangular matrix.
00043 *
00044 *  AFAC    (input) COMPLEX*16 array, dimension (N*(N+1)/2)
00045 *          The factored form of the matrix A, stored as a packed
00046 *          triangular matrix.  AFAC contains the block diagonal matrix D
00047 *          and the multipliers used to obtain the factor L or U from the
00048 *          block L*D*L' or U*D*U' factorization as computed by ZHPTRF.
00049 *
00050 *  IPIV    (input) INTEGER array, dimension (N)
00051 *          The pivot indices from ZHPTRF.
00052 *
00053 *  C       (workspace) COMPLEX*16 array, dimension (LDC,N)
00054 *
00055 *  LDC     (integer) INTEGER
00056 *          The leading dimension of the array C.  LDC >= max(1,N).
00057 *
00058 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (N)
00059 *
00060 *  RESID   (output) DOUBLE PRECISION
00061 *          If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS )
00062 *          If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS )
00063 *
00064 *  =====================================================================
00065 *
00066 *     .. Parameters ..
00067       DOUBLE PRECISION   ZERO, ONE
00068       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00069       COMPLEX*16         CZERO, CONE
00070       PARAMETER          ( CZERO = ( 0.0D+0, 0.0D+0 ),
00071      $                   CONE = ( 1.0D+0, 0.0D+0 ) )
00072 *     ..
00073 *     .. Local Scalars ..
00074       INTEGER            I, INFO, J, JC
00075       DOUBLE PRECISION   ANORM, EPS
00076 *     ..
00077 *     .. External Functions ..
00078       LOGICAL            LSAME
00079       DOUBLE PRECISION   DLAMCH, ZLANHE, ZLANHP
00080       EXTERNAL           LSAME, DLAMCH, ZLANHE, ZLANHP
00081 *     ..
00082 *     .. External Subroutines ..
00083       EXTERNAL           ZLASET, ZLAVHP
00084 *     ..
00085 *     .. Intrinsic Functions ..
00086       INTRINSIC          DBLE, DIMAG
00087 *     ..
00088 *     .. Executable Statements ..
00089 *
00090 *     Quick exit if N = 0.
00091 *
00092       IF( N.LE.0 ) THEN
00093          RESID = ZERO
00094          RETURN
00095       END IF
00096 *
00097 *     Determine EPS and the norm of A.
00098 *
00099       EPS = DLAMCH( 'Epsilon' )
00100       ANORM = ZLANHP( '1', UPLO, N, A, RWORK )
00101 *
00102 *     Check the imaginary parts of the diagonal elements and return with
00103 *     an error code if any are nonzero.
00104 *
00105       JC = 1
00106       IF( LSAME( UPLO, 'U' ) ) THEN
00107          DO 10 J = 1, N
00108             IF( DIMAG( AFAC( JC ) ).NE.ZERO ) THEN
00109                RESID = ONE / EPS
00110                RETURN
00111             END IF
00112             JC = JC + J + 1
00113    10    CONTINUE
00114       ELSE
00115          DO 20 J = 1, N
00116             IF( DIMAG( AFAC( JC ) ).NE.ZERO ) THEN
00117                RESID = ONE / EPS
00118                RETURN
00119             END IF
00120             JC = JC + N - J + 1
00121    20    CONTINUE
00122       END IF
00123 *
00124 *     Initialize C to the identity matrix.
00125 *
00126       CALL ZLASET( 'Full', N, N, CZERO, CONE, C, LDC )
00127 *
00128 *     Call ZLAVHP to form the product D * U' (or D * L' ).
00129 *
00130       CALL ZLAVHP( UPLO, 'Conjugate', 'Non-unit', N, N, AFAC, IPIV, C,
00131      $             LDC, INFO )
00132 *
00133 *     Call ZLAVHP again to multiply by U ( or L ).
00134 *
00135       CALL ZLAVHP( UPLO, 'No transpose', 'Unit', N, N, AFAC, IPIV, C,
00136      $             LDC, INFO )
00137 *
00138 *     Compute the difference  C - A .
00139 *
00140       IF( LSAME( UPLO, 'U' ) ) THEN
00141          JC = 0
00142          DO 40 J = 1, N
00143             DO 30 I = 1, J - 1
00144                C( I, J ) = C( I, J ) - A( JC+I )
00145    30       CONTINUE
00146             C( J, J ) = C( J, J ) - DBLE( A( JC+J ) )
00147             JC = JC + J
00148    40    CONTINUE
00149       ELSE
00150          JC = 1
00151          DO 60 J = 1, N
00152             C( J, J ) = C( J, J ) - DBLE( A( JC ) )
00153             DO 50 I = J + 1, N
00154                C( I, J ) = C( I, J ) - A( JC+I-J )
00155    50       CONTINUE
00156             JC = JC + N - J + 1
00157    60    CONTINUE
00158       END IF
00159 *
00160 *     Compute norm( C - A ) / ( N * norm(A) * EPS )
00161 *
00162       RESID = ZLANHE( '1', UPLO, N, C, LDC, RWORK )
00163 *
00164       IF( ANORM.LE.ZERO ) THEN
00165          IF( RESID.NE.ZERO )
00166      $      RESID = ONE / EPS
00167       ELSE
00168          RESID = ( ( RESID / DBLE( N ) ) / ANORM ) / EPS
00169       END IF
00170 *
00171       RETURN
00172 *
00173 *     End of ZHPT01
00174 *
00175       END
 All Files Functions