LAPACK 3.3.1
Linear Algebra PACKage
|
00001 DOUBLE PRECISION FUNCTION ZQRT17( TRANS, IRESID, M, N, NRHS, A, 00002 $ LDA, X, LDX, B, LDB, C, WORK, LWORK ) 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 TRANS 00010 INTEGER IRESID, LDA, LDB, LDX, LWORK, M, N, NRHS 00011 * .. 00012 * .. Array Arguments .. 00013 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDB, * ), 00014 $ WORK( LWORK ), X( LDX, * ) 00015 * .. 00016 * 00017 * Purpose 00018 * ======= 00019 * 00020 * ZQRT17 computes the ratio 00021 * 00022 * || R'*op(A) ||/(||A||*alpha*max(M,N,NRHS)*eps) 00023 * 00024 * where R = op(A)*X - B, op(A) is A or A', and 00025 * 00026 * alpha = ||B|| if IRESID = 1 (zero-residual problem) 00027 * alpha = ||R|| if IRESID = 2 (otherwise). 00028 * 00029 * Arguments 00030 * ========= 00031 * 00032 * TRANS (input) CHARACTER*1 00033 * Specifies whether or not the transpose of A is used. 00034 * = 'N': No transpose, op(A) = A. 00035 * = 'C': Conjugate transpose, op(A) = A'. 00036 * 00037 * IRESID (input) INTEGER 00038 * IRESID = 1 indicates zero-residual problem. 00039 * IRESID = 2 indicates non-zero residual. 00040 * 00041 * M (input) INTEGER 00042 * The number of rows of the matrix A. 00043 * If TRANS = 'N', the number of rows of the matrix B. 00044 * If TRANS = 'C', the number of rows of the matrix X. 00045 * 00046 * N (input) INTEGER 00047 * The number of columns of the matrix A. 00048 * If TRANS = 'N', the number of rows of the matrix X. 00049 * If TRANS = 'C', the number of rows of the matrix B. 00050 * 00051 * NRHS (input) INTEGER 00052 * The number of columns of the matrices X and B. 00053 * 00054 * A (input) COMPLEX*16 array, dimension (LDA,N) 00055 * The m-by-n matrix A. 00056 * 00057 * LDA (input) INTEGER 00058 * The leading dimension of the array A. LDA >= M. 00059 * 00060 * X (input) COMPLEX*16 array, dimension (LDX,NRHS) 00061 * If TRANS = 'N', the n-by-nrhs matrix X. 00062 * If TRANS = 'C', the m-by-nrhs matrix X. 00063 * 00064 * LDX (input) INTEGER 00065 * The leading dimension of the array X. 00066 * If TRANS = 'N', LDX >= N. 00067 * If TRANS = 'C', LDX >= M. 00068 * 00069 * B (input) COMPLEX*16 array, dimension (LDB,NRHS) 00070 * If TRANS = 'N', the m-by-nrhs matrix B. 00071 * If TRANS = 'C', the n-by-nrhs matrix B. 00072 * 00073 * LDB (input) INTEGER 00074 * The leading dimension of the array B. 00075 * If TRANS = 'N', LDB >= M. 00076 * If TRANS = 'C', LDB >= N. 00077 * 00078 * C (workspace) COMPLEX*16 array, dimension (LDB,NRHS) 00079 * 00080 * WORK (workspace) COMPLEX*16 array, dimension (LWORK) 00081 * 00082 * LWORK (input) INTEGER 00083 * The length of the array WORK. LWORK >= NRHS*(M+N). 00084 * 00085 * ===================================================================== 00086 * 00087 * .. Parameters .. 00088 DOUBLE PRECISION ZERO, ONE 00089 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 ) 00090 * .. 00091 * .. Local Scalars .. 00092 INTEGER INFO, ISCL, NCOLS, NROWS 00093 DOUBLE PRECISION BIGNUM, ERR, NORMA, NORMB, NORMRS, NORMX, 00094 $ SMLNUM 00095 * .. 00096 * .. Local Arrays .. 00097 DOUBLE PRECISION RWORK( 1 ) 00098 * .. 00099 * .. External Functions .. 00100 LOGICAL LSAME 00101 DOUBLE PRECISION DLAMCH, ZLANGE 00102 EXTERNAL LSAME, DLAMCH, ZLANGE 00103 * .. 00104 * .. External Subroutines .. 00105 EXTERNAL XERBLA, ZGEMM, ZLACPY, ZLASCL 00106 * .. 00107 * .. Intrinsic Functions .. 00108 INTRINSIC DBLE, DCMPLX, MAX 00109 * .. 00110 * .. Executable Statements .. 00111 * 00112 ZQRT17 = ZERO 00113 * 00114 IF( LSAME( TRANS, 'N' ) ) THEN 00115 NROWS = M 00116 NCOLS = N 00117 ELSE IF( LSAME( TRANS, 'C' ) ) THEN 00118 NROWS = N 00119 NCOLS = M 00120 ELSE 00121 CALL XERBLA( 'ZQRT17', 1 ) 00122 RETURN 00123 END IF 00124 * 00125 IF( LWORK.LT.NCOLS*NRHS ) THEN 00126 CALL XERBLA( 'ZQRT17', 13 ) 00127 RETURN 00128 END IF 00129 * 00130 IF( M.LE.0 .OR. N.LE.0 .OR. NRHS.LE.0 ) 00131 $ RETURN 00132 * 00133 NORMA = ZLANGE( 'One-norm', M, N, A, LDA, RWORK ) 00134 SMLNUM = DLAMCH( 'Safe minimum' ) / DLAMCH( 'Precision' ) 00135 BIGNUM = ONE / SMLNUM 00136 ISCL = 0 00137 * 00138 * compute residual and scale it 00139 * 00140 CALL ZLACPY( 'All', NROWS, NRHS, B, LDB, C, LDB ) 00141 CALL ZGEMM( TRANS, 'No transpose', NROWS, NRHS, NCOLS, 00142 $ DCMPLX( -ONE ), A, LDA, X, LDX, DCMPLX( ONE ), C, 00143 $ LDB ) 00144 NORMRS = ZLANGE( 'Max', NROWS, NRHS, C, LDB, RWORK ) 00145 IF( NORMRS.GT.SMLNUM ) THEN 00146 ISCL = 1 00147 CALL ZLASCL( 'General', 0, 0, NORMRS, ONE, NROWS, NRHS, C, LDB, 00148 $ INFO ) 00149 END IF 00150 * 00151 * compute R'*A 00152 * 00153 CALL ZGEMM( 'Conjugate transpose', TRANS, NRHS, NCOLS, NROWS, 00154 $ DCMPLX( ONE ), C, LDB, A, LDA, DCMPLX( ZERO ), WORK, 00155 $ NRHS ) 00156 * 00157 * compute and properly scale error 00158 * 00159 ERR = ZLANGE( 'One-norm', NRHS, NCOLS, WORK, NRHS, RWORK ) 00160 IF( NORMA.NE.ZERO ) 00161 $ ERR = ERR / NORMA 00162 * 00163 IF( ISCL.EQ.1 ) 00164 $ ERR = ERR*NORMRS 00165 * 00166 IF( IRESID.EQ.1 ) THEN 00167 NORMB = ZLANGE( 'One-norm', NROWS, NRHS, B, LDB, RWORK ) 00168 IF( NORMB.NE.ZERO ) 00169 $ ERR = ERR / NORMB 00170 ELSE 00171 NORMX = ZLANGE( 'One-norm', NCOLS, NRHS, X, LDX, RWORK ) 00172 IF( NORMX.NE.ZERO ) 00173 $ ERR = ERR / NORMX 00174 END IF 00175 * 00176 ZQRT17 = ERR / ( DLAMCH( 'Epsilon' )*DBLE( MAX( M, N, NRHS ) ) ) 00177 RETURN 00178 * 00179 * End of ZQRT17 00180 * 00181 END