LAPACK 3.3.0

chet01.f

Go to the documentation of this file.
00001       SUBROUTINE CHET01( 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       REAL               RESID
00012 *     ..
00013 *     .. Array Arguments ..
00014       INTEGER            IPIV( * )
00015       REAL               RWORK( * )
00016       COMPLEX            A( LDA, * ), AFAC( LDAFAC, * ), C( LDC, * )
00017 *     ..
00018 *
00019 *  Purpose
00020 *  =======
00021 *
00022 *  CHET01 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 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 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 CHETRF.
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 CHETRF.
00058 *
00059 *  C       (workspace) COMPLEX 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) REAL array, dimension (N)
00065 *
00066 *  RESID   (output) REAL
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       REAL               ZERO, ONE
00074       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00075       COMPLEX            CZERO, CONE
00076       PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
00077      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00078 *     ..
00079 *     .. Local Scalars ..
00080       INTEGER            I, INFO, J
00081       REAL               ANORM, EPS
00082 *     ..
00083 *     .. External Functions ..
00084       LOGICAL            LSAME
00085       REAL               CLANHE, SLAMCH
00086       EXTERNAL           LSAME, CLANHE, SLAMCH
00087 *     ..
00088 *     .. External Subroutines ..
00089       EXTERNAL           CLAVHE, CLASET
00090 *     ..
00091 *     .. Intrinsic Functions ..
00092       INTRINSIC          AIMAG, REAL
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 = SLAMCH( 'Epsilon' )
00106       ANORM = CLANHE( '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( AIMAG( 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 CLASET( 'Full', N, N, CZERO, CONE, C, LDC )
00121 *
00122 *     Call CLAVHE to form the product D * U' (or D * L' ).
00123 *
00124       CALL CLAVHE( UPLO, 'Conjugate', 'Non-unit', N, N, AFAC, LDAFAC,
00125      $             IPIV, C, LDC, INFO )
00126 *
00127 *     Call CLAVHE again to multiply by U (or L ).
00128 *
00129       CALL CLAVHE( 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 ) - REAL( A( J, J ) )
00140    30    CONTINUE
00141       ELSE
00142          DO 50 J = 1, N
00143             C( J, J ) = C( J, J ) - REAL( 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 = CLANHE( '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 / REAL( N ) ) / ANORM ) / EPS
00159       END IF
00160 *
00161       RETURN
00162 *
00163 *     End of CHET01
00164 *
00165       END
 All Files Functions