LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE CHPT01( 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 REAL RESID 00011 * .. 00012 * .. Array Arguments .. 00013 INTEGER IPIV( * ) 00014 REAL RWORK( * ) 00015 COMPLEX A( * ), AFAC( * ), C( LDC, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * CHPT01 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 array, dimension (N*(N+1)/2) 00041 * The original Hermitian matrix A, stored as a packed 00042 * triangular matrix. 00043 * 00044 * AFAC (input) COMPLEX 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 CHPTRF. 00049 * 00050 * IPIV (input) INTEGER array, dimension (N) 00051 * The pivot indices from CHPTRF. 00052 * 00053 * C (workspace) COMPLEX 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) REAL array, dimension (N) 00059 * 00060 * RESID (output) REAL 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 REAL ZERO, ONE 00068 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00069 COMPLEX CZERO, CONE 00070 PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ), 00071 $ CONE = ( 1.0E+0, 0.0E+0 ) ) 00072 * .. 00073 * .. Local Scalars .. 00074 INTEGER I, INFO, J, JC 00075 REAL ANORM, EPS 00076 * .. 00077 * .. External Functions .. 00078 LOGICAL LSAME 00079 REAL CLANHE, CLANHP, SLAMCH 00080 EXTERNAL LSAME, CLANHE, CLANHP, SLAMCH 00081 * .. 00082 * .. External Subroutines .. 00083 EXTERNAL CLAVHP, CLASET 00084 * .. 00085 * .. Intrinsic Functions .. 00086 INTRINSIC AIMAG, REAL 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 = SLAMCH( 'Epsilon' ) 00100 ANORM = CLANHP( '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( AIMAG( 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( AIMAG( 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 CLASET( 'Full', N, N, CZERO, CONE, C, LDC ) 00127 * 00128 * Call CLAVHP to form the product D * U' (or D * L' ). 00129 * 00130 CALL CLAVHP( UPLO, 'Conjugate', 'Non-unit', N, N, AFAC, IPIV, C, 00131 $ LDC, INFO ) 00132 * 00133 * Call CLAVHP again to multiply by U ( or L ). 00134 * 00135 CALL CLAVHP( 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 ) - REAL( 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 ) - REAL( 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 = CLANHE( '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 / REAL( N ) ) / ANORM ) / EPS 00169 END IF 00170 * 00171 RETURN 00172 * 00173 * End of CHPT01 00174 * 00175 END