LAPACK 3.3.1
Linear Algebra PACKage

cqrt17.f

Go to the documentation of this file.
00001       REAL             FUNCTION CQRT17( 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            A( LDA, * ), B( LDB, * ), C( LDB, * ),
00014      $                   WORK( LWORK ), X( LDX, * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  CQRT17 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 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 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 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 array, dimension (LDB,NRHS)
00079 *
00080 *  WORK    (workspace) COMPLEX 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       REAL               ZERO, ONE
00089       PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
00090 *     ..
00091 *     .. Local Scalars ..
00092       INTEGER            INFO, ISCL, NCOLS, NROWS
00093       REAL               BIGNUM, ERR, NORMA, NORMB, NORMRS, NORMX,
00094      $                   SMLNUM
00095 *     ..
00096 *     .. Local Arrays ..
00097       REAL               RWORK( 1 )
00098 *     ..
00099 *     .. External Functions ..
00100       LOGICAL            LSAME
00101       REAL               CLANGE, SLAMCH
00102       EXTERNAL           LSAME, CLANGE, SLAMCH
00103 *     ..
00104 *     .. External Subroutines ..
00105       EXTERNAL           CGEMM, CLACPY, CLASCL, XERBLA
00106 *     ..
00107 *     .. Intrinsic Functions ..
00108       INTRINSIC          CMPLX, MAX, REAL
00109 *     ..
00110 *     .. Executable Statements ..
00111 *
00112       CQRT17 = 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( 'CQRT17', 1 )
00122          RETURN
00123       END IF
00124 *
00125       IF( LWORK.LT.NCOLS*NRHS ) THEN
00126          CALL XERBLA( 'CQRT17', 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 = CLANGE( 'One-norm', M, N, A, LDA, RWORK )
00134       SMLNUM = SLAMCH( 'Safe minimum' ) / SLAMCH( 'Precision' )
00135       BIGNUM = ONE / SMLNUM
00136       ISCL = 0
00137 *
00138 *     compute residual and scale it
00139 *
00140       CALL CLACPY( 'All', NROWS, NRHS, B, LDB, C, LDB )
00141       CALL CGEMM( TRANS, 'No transpose', NROWS, NRHS, NCOLS,
00142      $            CMPLX( -ONE ), A, LDA, X, LDX, CMPLX( ONE ), C, LDB )
00143       NORMRS = CLANGE( 'Max', NROWS, NRHS, C, LDB, RWORK )
00144       IF( NORMRS.GT.SMLNUM ) THEN
00145          ISCL = 1
00146          CALL CLASCL( 'General', 0, 0, NORMRS, ONE, NROWS, NRHS, C, LDB,
00147      $                INFO )
00148       END IF
00149 *
00150 *     compute R'*A
00151 *
00152       CALL CGEMM( 'Conjugate transpose', TRANS, NRHS, NCOLS, NROWS,
00153      $            CMPLX( ONE ), C, LDB, A, LDA, CMPLX( ZERO ), WORK,
00154      $            NRHS )
00155 *
00156 *     compute and properly scale error
00157 *
00158       ERR = CLANGE( 'One-norm', NRHS, NCOLS, WORK, NRHS, RWORK )
00159       IF( NORMA.NE.ZERO )
00160      $   ERR = ERR / NORMA
00161 *
00162       IF( ISCL.EQ.1 )
00163      $   ERR = ERR*NORMRS
00164 *
00165       IF( IRESID.EQ.1 ) THEN
00166          NORMB = CLANGE( 'One-norm', NROWS, NRHS, B, LDB, RWORK )
00167          IF( NORMB.NE.ZERO )
00168      $      ERR = ERR / NORMB
00169       ELSE
00170          NORMX = CLANGE( 'One-norm', NCOLS, NRHS, X, LDX, RWORK )
00171          IF( NORMX.NE.ZERO )
00172      $      ERR = ERR / NORMX
00173       END IF
00174 *
00175       CQRT17 = ERR / ( SLAMCH( 'Epsilon' )*REAL( MAX( M, N, NRHS ) ) )
00176       RETURN
00177 *
00178 *     End of CQRT17
00179 *
00180       END
 All Files Functions