LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
zqrt16.f
Go to the documentation of this file.
00001 *> \brief \b ZQRT16
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE ZQRT16( TRANS, M, N, NRHS, A, LDA, X, LDX, B, LDB,
00012 *                          RWORK, RESID )
00013 * 
00014 *       .. Scalar Arguments ..
00015 *       CHARACTER          TRANS
00016 *       INTEGER            LDA, LDB, LDX, M, N, NRHS
00017 *       DOUBLE PRECISION   RESID
00018 *       ..
00019 *       .. Array Arguments ..
00020 *       DOUBLE PRECISION   RWORK( * )
00021 *       COMPLEX*16         A( LDA, * ), B( LDB, * ), X( LDX, * )
00022 *       ..
00023 *  
00024 *
00025 *> \par Purpose:
00026 *  =============
00027 *>
00028 *> \verbatim
00029 *>
00030 *> ZQRT16 computes the residual for a solution of a system of linear
00031 *> equations  A*x = b  or  A'*x = b:
00032 *>    RESID = norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ),
00033 *> where EPS is the machine epsilon.
00034 *> \endverbatim
00035 *
00036 *  Arguments:
00037 *  ==========
00038 *
00039 *> \param[in] TRANS
00040 *> \verbatim
00041 *>          TRANS is CHARACTER*1
00042 *>          Specifies the form of the system of equations:
00043 *>          = 'N':  A *x = b
00044 *>          = 'T':  A^T*x = b, where A^T is the transpose of A
00045 *>          = 'C':  A^H*x = b, where A^H is the conjugate transpose of A
00046 *> \endverbatim
00047 *>
00048 *> \param[in] M
00049 *> \verbatim
00050 *>          M is INTEGER
00051 *>          The number of rows of the matrix A.  M >= 0.
00052 *> \endverbatim
00053 *>
00054 *> \param[in] N
00055 *> \verbatim
00056 *>          N is INTEGER
00057 *>          The number of columns of the matrix A.  N >= 0.
00058 *> \endverbatim
00059 *>
00060 *> \param[in] NRHS
00061 *> \verbatim
00062 *>          NRHS is INTEGER
00063 *>          The number of columns of B, the matrix of right hand sides.
00064 *>          NRHS >= 0.
00065 *> \endverbatim
00066 *>
00067 *> \param[in] A
00068 *> \verbatim
00069 *>          A is COMPLEX*16 array, dimension (LDA,N)
00070 *>          The original M x N matrix A.
00071 *> \endverbatim
00072 *>
00073 *> \param[in] LDA
00074 *> \verbatim
00075 *>          LDA is INTEGER
00076 *>          The leading dimension of the array A.  LDA >= max(1,M).
00077 *> \endverbatim
00078 *>
00079 *> \param[in] X
00080 *> \verbatim
00081 *>          X is COMPLEX*16 array, dimension (LDX,NRHS)
00082 *>          The computed solution vectors for the system of linear
00083 *>          equations.
00084 *> \endverbatim
00085 *>
00086 *> \param[in] LDX
00087 *> \verbatim
00088 *>          LDX is INTEGER
00089 *>          The leading dimension of the array X.  If TRANS = 'N',
00090 *>          LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M).
00091 *> \endverbatim
00092 *>
00093 *> \param[in,out] B
00094 *> \verbatim
00095 *>          B is COMPLEX*16 array, dimension (LDB,NRHS)
00096 *>          On entry, the right hand side vectors for the system of
00097 *>          linear equations.
00098 *>          On exit, B is overwritten with the difference B - A*X.
00099 *> \endverbatim
00100 *>
00101 *> \param[in] LDB
00102 *> \verbatim
00103 *>          LDB is INTEGER
00104 *>          The leading dimension of the array B.  IF TRANS = 'N',
00105 *>          LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
00106 *> \endverbatim
00107 *>
00108 *> \param[out] RWORK
00109 *> \verbatim
00110 *>          RWORK is DOUBLE PRECISION array, dimension (M)
00111 *> \endverbatim
00112 *>
00113 *> \param[out] RESID
00114 *> \verbatim
00115 *>          RESID is DOUBLE PRECISION
00116 *>          The maximum over the number of right hand sides of
00117 *>          norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ).
00118 *> \endverbatim
00119 *
00120 *  Authors:
00121 *  ========
00122 *
00123 *> \author Univ. of Tennessee 
00124 *> \author Univ. of California Berkeley 
00125 *> \author Univ. of Colorado Denver 
00126 *> \author NAG Ltd. 
00127 *
00128 *> \date November 2011
00129 *
00130 *> \ingroup complex16_lin
00131 *
00132 *  =====================================================================
00133       SUBROUTINE ZQRT16( TRANS, M, N, NRHS, A, LDA, X, LDX, B, LDB,
00134      $                   RWORK, RESID )
00135 *
00136 *  -- LAPACK test routine (version 3.4.0) --
00137 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00138 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00139 *     November 2011
00140 *
00141 *     .. Scalar Arguments ..
00142       CHARACTER          TRANS
00143       INTEGER            LDA, LDB, LDX, M, N, NRHS
00144       DOUBLE PRECISION   RESID
00145 *     ..
00146 *     .. Array Arguments ..
00147       DOUBLE PRECISION   RWORK( * )
00148       COMPLEX*16         A( LDA, * ), B( LDB, * ), X( LDX, * )
00149 *     ..
00150 *
00151 *  =====================================================================
00152 *
00153 *     .. Parameters ..
00154       DOUBLE PRECISION   ZERO, ONE
00155       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00156       COMPLEX*16         CONE
00157       PARAMETER          ( CONE = ( 1.0D+0, 0.0D+0 ) )
00158 *     ..
00159 *     .. Local Scalars ..
00160       INTEGER            J, N1, N2
00161       DOUBLE PRECISION   ANORM, BNORM, EPS, XNORM
00162 *     ..
00163 *     .. External Functions ..
00164       LOGICAL            LSAME
00165       DOUBLE PRECISION   DLAMCH, DZASUM, ZLANGE
00166       EXTERNAL           LSAME, DLAMCH, DZASUM, ZLANGE
00167 *     ..
00168 *     .. External Subroutines ..
00169       EXTERNAL           ZGEMM
00170 *     ..
00171 *     .. Intrinsic Functions ..
00172       INTRINSIC          MAX
00173 *     ..
00174 *     .. Executable Statements ..
00175 *
00176 *     Quick exit if M = 0 or N = 0 or NRHS = 0
00177 *
00178       IF( M.LE.0 .OR. N.LE.0 .OR. NRHS.EQ.0 ) THEN
00179          RESID = ZERO
00180          RETURN
00181       END IF
00182 *
00183       IF( LSAME( TRANS, 'T' ) .OR. LSAME( TRANS, 'C' ) ) THEN
00184          ANORM = ZLANGE( 'I', M, N, A, LDA, RWORK )
00185          N1 = N
00186          N2 = M
00187       ELSE
00188          ANORM = ZLANGE( '1', M, N, A, LDA, RWORK )
00189          N1 = M
00190          N2 = N
00191       END IF
00192 *
00193       EPS = DLAMCH( 'Epsilon' )
00194 *
00195 *     Compute  B - A*X  (or  B - A'*X ) and store in B.
00196 *
00197       CALL ZGEMM( TRANS, 'No transpose', N1, NRHS, N2, -CONE, A, LDA, X,
00198      $            LDX, CONE, B, LDB )
00199 *
00200 *     Compute the maximum over the number of right hand sides of
00201 *        norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ) .
00202 *
00203       RESID = ZERO
00204       DO 10 J = 1, NRHS
00205          BNORM = DZASUM( N1, B( 1, J ), 1 )
00206          XNORM = DZASUM( N2, X( 1, J ), 1 )
00207          IF( ANORM.EQ.ZERO .AND. BNORM.EQ.ZERO ) THEN
00208             RESID = ZERO
00209          ELSE IF( ANORM.LE.ZERO .OR. XNORM.LE.ZERO ) THEN
00210             RESID = ONE / EPS
00211          ELSE
00212             RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) /
00213      $              ( MAX( M, N )*EPS ) )
00214          END IF
00215    10 CONTINUE
00216 *
00217       RETURN
00218 *
00219 *     End of ZQRT16
00220 *
00221       END
 All Files Functions