LAPACK 3.3.1
Linear Algebra PACKage

zhet01.f

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