1*> \brief \b CHPT01 2* 3* =========== DOCUMENTATION =========== 4* 5* Online html documentation available at 6* http://www.netlib.org/lapack/explore-html/ 7* 8* Definition: 9* =========== 10* 11* SUBROUTINE CHPT01( UPLO, N, A, AFAC, IPIV, C, LDC, RWORK, RESID ) 12* 13* .. Scalar Arguments .. 14* CHARACTER UPLO 15* INTEGER LDC, N 16* REAL RESID 17* .. 18* .. Array Arguments .. 19* INTEGER IPIV( * ) 20* REAL RWORK( * ) 21* COMPLEX A( * ), AFAC( * ), C( LDC, * ) 22* .. 23* 24* 25*> \par Purpose: 26* ============= 27*> 28*> \verbatim 29*> 30*> CHPT01 reconstructs a Hermitian indefinite packed matrix A from its 31*> block L*D*L' or U*D*U' factorization and computes the residual 32*> norm( C - A ) / ( N * norm(A) * EPS ), 33*> where C is the reconstructed matrix, EPS is the machine epsilon, 34*> L' is the conjugate transpose of L, and U' is the conjugate transpose 35*> of U. 36*> \endverbatim 37* 38* Arguments: 39* ========== 40* 41*> \param[in] UPLO 42*> \verbatim 43*> UPLO is CHARACTER*1 44*> Specifies whether the upper or lower triangular part of the 45*> Hermitian matrix A is stored: 46*> = 'U': Upper triangular 47*> = 'L': Lower triangular 48*> \endverbatim 49*> 50*> \param[in] N 51*> \verbatim 52*> N is INTEGER 53*> The number of rows and columns of the matrix A. N >= 0. 54*> \endverbatim 55*> 56*> \param[in] A 57*> \verbatim 58*> A is COMPLEX array, dimension (N*(N+1)/2) 59*> The original Hermitian matrix A, stored as a packed 60*> triangular matrix. 61*> \endverbatim 62*> 63*> \param[in] AFAC 64*> \verbatim 65*> AFAC is COMPLEX array, dimension (N*(N+1)/2) 66*> The factored form of the matrix A, stored as a packed 67*> triangular matrix. AFAC contains the block diagonal matrix D 68*> and the multipliers used to obtain the factor L or U from the 69*> block L*D*L' or U*D*U' factorization as computed by CHPTRF. 70*> \endverbatim 71*> 72*> \param[in] IPIV 73*> \verbatim 74*> IPIV is INTEGER array, dimension (N) 75*> The pivot indices from CHPTRF. 76*> \endverbatim 77*> 78*> \param[out] C 79*> \verbatim 80*> C is COMPLEX array, dimension (LDC,N) 81*> \endverbatim 82*> 83*> \param[in] LDC 84*> \verbatim 85*> LDC is INTEGER 86*> The leading dimension of the array C. LDC >= max(1,N). 87*> \endverbatim 88*> 89*> \param[out] RWORK 90*> \verbatim 91*> RWORK is REAL array, dimension (N) 92*> \endverbatim 93*> 94*> \param[out] RESID 95*> \verbatim 96*> RESID is REAL 97*> If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS ) 98*> If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS ) 99*> \endverbatim 100* 101* Authors: 102* ======== 103* 104*> \author Univ. of Tennessee 105*> \author Univ. of California Berkeley 106*> \author Univ. of Colorado Denver 107*> \author NAG Ltd. 108* 109*> \ingroup complex_lin 110* 111* ===================================================================== 112 SUBROUTINE CHPT01( UPLO, N, A, AFAC, IPIV, C, LDC, RWORK, RESID ) 113* 114* -- LAPACK test routine -- 115* -- LAPACK is a software package provided by Univ. of Tennessee, -- 116* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 117* 118* .. Scalar Arguments .. 119 CHARACTER UPLO 120 INTEGER LDC, N 121 REAL RESID 122* .. 123* .. Array Arguments .. 124 INTEGER IPIV( * ) 125 REAL RWORK( * ) 126 COMPLEX A( * ), AFAC( * ), C( LDC, * ) 127* .. 128* 129* ===================================================================== 130* 131* .. Parameters .. 132 REAL ZERO, ONE 133 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 134 COMPLEX CZERO, CONE 135 PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ), 136 $ CONE = ( 1.0E+0, 0.0E+0 ) ) 137* .. 138* .. Local Scalars .. 139 INTEGER I, INFO, J, JC 140 REAL ANORM, EPS 141* .. 142* .. External Functions .. 143 LOGICAL LSAME 144 REAL CLANHE, CLANHP, SLAMCH 145 EXTERNAL LSAME, CLANHE, CLANHP, SLAMCH 146* .. 147* .. External Subroutines .. 148 EXTERNAL CLAVHP, CLASET 149* .. 150* .. Intrinsic Functions .. 151 INTRINSIC AIMAG, REAL 152* .. 153* .. Executable Statements .. 154* 155* Quick exit if N = 0. 156* 157 IF( N.LE.0 ) THEN 158 RESID = ZERO 159 RETURN 160 END IF 161* 162* Determine EPS and the norm of A. 163* 164 EPS = SLAMCH( 'Epsilon' ) 165 ANORM = CLANHP( '1', UPLO, N, A, RWORK ) 166* 167* Check the imaginary parts of the diagonal elements and return with 168* an error code if any are nonzero. 169* 170 JC = 1 171 IF( LSAME( UPLO, 'U' ) ) THEN 172 DO 10 J = 1, N 173 IF( AIMAG( AFAC( JC ) ).NE.ZERO ) THEN 174 RESID = ONE / EPS 175 RETURN 176 END IF 177 JC = JC + J + 1 178 10 CONTINUE 179 ELSE 180 DO 20 J = 1, N 181 IF( AIMAG( AFAC( JC ) ).NE.ZERO ) THEN 182 RESID = ONE / EPS 183 RETURN 184 END IF 185 JC = JC + N - J + 1 186 20 CONTINUE 187 END IF 188* 189* Initialize C to the identity matrix. 190* 191 CALL CLASET( 'Full', N, N, CZERO, CONE, C, LDC ) 192* 193* Call CLAVHP to form the product D * U' (or D * L' ). 194* 195 CALL CLAVHP( UPLO, 'Conjugate', 'Non-unit', N, N, AFAC, IPIV, C, 196 $ LDC, INFO ) 197* 198* Call CLAVHP again to multiply by U ( or L ). 199* 200 CALL CLAVHP( UPLO, 'No transpose', 'Unit', N, N, AFAC, IPIV, C, 201 $ LDC, INFO ) 202* 203* Compute the difference C - A . 204* 205 IF( LSAME( UPLO, 'U' ) ) THEN 206 JC = 0 207 DO 40 J = 1, N 208 DO 30 I = 1, J - 1 209 C( I, J ) = C( I, J ) - A( JC+I ) 210 30 CONTINUE 211 C( J, J ) = C( J, J ) - REAL( A( JC+J ) ) 212 JC = JC + J 213 40 CONTINUE 214 ELSE 215 JC = 1 216 DO 60 J = 1, N 217 C( J, J ) = C( J, J ) - REAL( A( JC ) ) 218 DO 50 I = J + 1, N 219 C( I, J ) = C( I, J ) - A( JC+I-J ) 220 50 CONTINUE 221 JC = JC + N - J + 1 222 60 CONTINUE 223 END IF 224* 225* Compute norm( C - A ) / ( N * norm(A) * EPS ) 226* 227 RESID = CLANHE( '1', UPLO, N, C, LDC, RWORK ) 228* 229 IF( ANORM.LE.ZERO ) THEN 230 IF( RESID.NE.ZERO ) 231 $ RESID = ONE / EPS 232 ELSE 233 RESID = ( ( RESID / REAL( N ) ) / ANORM ) / EPS 234 END IF 235* 236 RETURN 237* 238* End of CHPT01 239* 240 END 241