LAPACK 3.3.0
|
00001 SUBROUTINE ZGTT01( N, DL, D, DU, DLF, DF, DUF, DU2, IPIV, WORK, 00002 $ LDWORK, 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 INTEGER LDWORK, N 00010 DOUBLE PRECISION RESID 00011 * .. 00012 * .. Array Arguments .. 00013 INTEGER IPIV( * ) 00014 DOUBLE PRECISION RWORK( * ) 00015 COMPLEX*16 D( * ), DF( * ), DL( * ), DLF( * ), DU( * ), 00016 $ DU2( * ), DUF( * ), WORK( LDWORK, * ) 00017 * .. 00018 * 00019 * Purpose 00020 * ======= 00021 * 00022 * ZGTT01 reconstructs a tridiagonal matrix A from its LU factorization 00023 * and computes the residual 00024 * norm(L*U - A) / ( norm(A) * EPS ), 00025 * where EPS is the machine epsilon. 00026 * 00027 * Arguments 00028 * ========= 00029 * 00030 * N (input) INTEGTER 00031 * The order of the matrix A. N >= 0. 00032 * 00033 * DL (input) COMPLEX*16 array, dimension (N-1) 00034 * The (n-1) sub-diagonal elements of A. 00035 * 00036 * D (input) COMPLEX*16 array, dimension (N) 00037 * The diagonal elements of A. 00038 * 00039 * DU (input) COMPLEX*16 array, dimension (N-1) 00040 * The (n-1) super-diagonal elements of A. 00041 * 00042 * DLF (input) COMPLEX*16 array, dimension (N-1) 00043 * The (n-1) multipliers that define the matrix L from the 00044 * LU factorization of A. 00045 * 00046 * DF (input) COMPLEX*16 array, dimension (N) 00047 * The n diagonal elements of the upper triangular matrix U from 00048 * the LU factorization of A. 00049 * 00050 * DUF (input) COMPLEX*16 array, dimension (N-1) 00051 * The (n-1) elements of the first super-diagonal of U. 00052 * 00053 * DU2 (input) COMPLEX*16 array, dimension (N-2) 00054 * The (n-2) elements of the second super-diagonal of U. 00055 * 00056 * IPIV (input) INTEGER array, dimension (N) 00057 * The pivot indices; for 1 <= i <= n, row i of the matrix was 00058 * interchanged with row IPIV(i). IPIV(i) will always be either 00059 * i or i+1; IPIV(i) = i indicates a row interchange was not 00060 * required. 00061 * 00062 * WORK (workspace) COMPLEX*16 array, dimension (LDWORK,N) 00063 * 00064 * LDWORK (input) INTEGER 00065 * The leading dimension of the array WORK. LDWORK >= max(1,N). 00066 * 00067 * RWORK (workspace) DOUBLE PRECISION array, dimension (N) 00068 * 00069 * RESID (output) DOUBLE PRECISION 00070 * The scaled residual: norm(L*U - A) / (norm(A) * EPS) 00071 * 00072 * ===================================================================== 00073 * 00074 * .. Parameters .. 00075 DOUBLE PRECISION ONE, ZERO 00076 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) 00077 * .. 00078 * .. Local Scalars .. 00079 INTEGER I, IP, J, LASTJ 00080 DOUBLE PRECISION ANORM, EPS 00081 COMPLEX*16 LI 00082 * .. 00083 * .. External Functions .. 00084 DOUBLE PRECISION DLAMCH, ZLANGT, ZLANHS 00085 EXTERNAL DLAMCH, ZLANGT, ZLANHS 00086 * .. 00087 * .. Intrinsic Functions .. 00088 INTRINSIC MIN 00089 * .. 00090 * .. External Subroutines .. 00091 EXTERNAL ZAXPY, ZSWAP 00092 * .. 00093 * .. Executable Statements .. 00094 * 00095 * Quick return if possible 00096 * 00097 IF( N.LE.0 ) THEN 00098 RESID = ZERO 00099 RETURN 00100 END IF 00101 * 00102 EPS = DLAMCH( 'Epsilon' ) 00103 * 00104 * Copy the matrix U to WORK. 00105 * 00106 DO 20 J = 1, N 00107 DO 10 I = 1, N 00108 WORK( I, J ) = ZERO 00109 10 CONTINUE 00110 20 CONTINUE 00111 DO 30 I = 1, N 00112 IF( I.EQ.1 ) THEN 00113 WORK( I, I ) = DF( I ) 00114 IF( N.GE.2 ) 00115 $ WORK( I, I+1 ) = DUF( I ) 00116 IF( N.GE.3 ) 00117 $ WORK( I, I+2 ) = DU2( I ) 00118 ELSE IF( I.EQ.N ) THEN 00119 WORK( I, I ) = DF( I ) 00120 ELSE 00121 WORK( I, I ) = DF( I ) 00122 WORK( I, I+1 ) = DUF( I ) 00123 IF( I.LT.N-1 ) 00124 $ WORK( I, I+2 ) = DU2( I ) 00125 END IF 00126 30 CONTINUE 00127 * 00128 * Multiply on the left by L. 00129 * 00130 LASTJ = N 00131 DO 40 I = N - 1, 1, -1 00132 LI = DLF( I ) 00133 CALL ZAXPY( LASTJ-I+1, LI, WORK( I, I ), LDWORK, 00134 $ WORK( I+1, I ), LDWORK ) 00135 IP = IPIV( I ) 00136 IF( IP.EQ.I ) THEN 00137 LASTJ = MIN( I+2, N ) 00138 ELSE 00139 CALL ZSWAP( LASTJ-I+1, WORK( I, I ), LDWORK, WORK( I+1, I ), 00140 $ LDWORK ) 00141 END IF 00142 40 CONTINUE 00143 * 00144 * Subtract the matrix A. 00145 * 00146 WORK( 1, 1 ) = WORK( 1, 1 ) - D( 1 ) 00147 IF( N.GT.1 ) THEN 00148 WORK( 1, 2 ) = WORK( 1, 2 ) - DU( 1 ) 00149 WORK( N, N-1 ) = WORK( N, N-1 ) - DL( N-1 ) 00150 WORK( N, N ) = WORK( N, N ) - D( N ) 00151 DO 50 I = 2, N - 1 00152 WORK( I, I-1 ) = WORK( I, I-1 ) - DL( I-1 ) 00153 WORK( I, I ) = WORK( I, I ) - D( I ) 00154 WORK( I, I+1 ) = WORK( I, I+1 ) - DU( I ) 00155 50 CONTINUE 00156 END IF 00157 * 00158 * Compute the 1-norm of the tridiagonal matrix A. 00159 * 00160 ANORM = ZLANGT( '1', N, DL, D, DU ) 00161 * 00162 * Compute the 1-norm of WORK, which is only guaranteed to be 00163 * upper Hessenberg. 00164 * 00165 RESID = ZLANHS( '1', N, WORK, LDWORK, RWORK ) 00166 * 00167 * Compute norm(L*U - A) / (norm(A) * EPS) 00168 * 00169 IF( ANORM.LE.ZERO ) THEN 00170 IF( RESID.NE.ZERO ) 00171 $ RESID = ONE / EPS 00172 ELSE 00173 RESID = ( RESID / ANORM ) / EPS 00174 END IF 00175 * 00176 RETURN 00177 * 00178 * End of ZGTT01 00179 * 00180 END