LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cget04.f
Go to the documentation of this file.
00001 *> \brief \b CGET04
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 CGET04( N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID )
00012 * 
00013 *       .. Scalar Arguments ..
00014 *       INTEGER            LDX, LDXACT, N, NRHS
00015 *       REAL               RCOND, RESID
00016 *       ..
00017 *       .. Array Arguments ..
00018 *       COMPLEX            X( LDX, * ), XACT( LDXACT, * )
00019 *       ..
00020 *  
00021 *
00022 *> \par Purpose:
00023 *  =============
00024 *>
00025 *> \verbatim
00026 *>
00027 *> CGET04 computes the difference between a computed solution and the
00028 *> true solution to a system of linear equations.
00029 *>
00030 *> RESID =  ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ),
00031 *> where RCOND is the reciprocal of the condition number and EPS is the
00032 *> machine epsilon.
00033 *> \endverbatim
00034 *
00035 *  Arguments:
00036 *  ==========
00037 *
00038 *> \param[in] N
00039 *> \verbatim
00040 *>          N is INTEGER
00041 *>          The number of rows of the matrices X and XACT.  N >= 0.
00042 *> \endverbatim
00043 *>
00044 *> \param[in] NRHS
00045 *> \verbatim
00046 *>          NRHS is INTEGER
00047 *>          The number of columns of the matrices X and XACT.  NRHS >= 0.
00048 *> \endverbatim
00049 *>
00050 *> \param[in] X
00051 *> \verbatim
00052 *>          X is COMPLEX array, dimension (LDX,NRHS)
00053 *>          The computed solution vectors.  Each vector is stored as a
00054 *>          column of the matrix X.
00055 *> \endverbatim
00056 *>
00057 *> \param[in] LDX
00058 *> \verbatim
00059 *>          LDX is INTEGER
00060 *>          The leading dimension of the array X.  LDX >= max(1,N).
00061 *> \endverbatim
00062 *>
00063 *> \param[in] XACT
00064 *> \verbatim
00065 *>          XACT is COMPLEX array, dimension (LDX,NRHS)
00066 *>          The exact solution vectors.  Each vector is stored as a
00067 *>          column of the matrix XACT.
00068 *> \endverbatim
00069 *>
00070 *> \param[in] LDXACT
00071 *> \verbatim
00072 *>          LDXACT is INTEGER
00073 *>          The leading dimension of the array XACT.  LDXACT >= max(1,N).
00074 *> \endverbatim
00075 *>
00076 *> \param[in] RCOND
00077 *> \verbatim
00078 *>          RCOND is REAL
00079 *>          The reciprocal of the condition number of the coefficient
00080 *>          matrix in the system of equations.
00081 *> \endverbatim
00082 *>
00083 *> \param[out] RESID
00084 *> \verbatim
00085 *>          RESID is REAL
00086 *>          The maximum over the NRHS solution vectors of
00087 *>          ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS )
00088 *> \endverbatim
00089 *
00090 *  Authors:
00091 *  ========
00092 *
00093 *> \author Univ. of Tennessee 
00094 *> \author Univ. of California Berkeley 
00095 *> \author Univ. of Colorado Denver 
00096 *> \author NAG Ltd. 
00097 *
00098 *> \date November 2011
00099 *
00100 *> \ingroup complex_lin
00101 *
00102 *  =====================================================================
00103       SUBROUTINE CGET04( N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID )
00104 *
00105 *  -- LAPACK test routine (version 3.4.0) --
00106 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00107 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00108 *     November 2011
00109 *
00110 *     .. Scalar Arguments ..
00111       INTEGER            LDX, LDXACT, N, NRHS
00112       REAL               RCOND, RESID
00113 *     ..
00114 *     .. Array Arguments ..
00115       COMPLEX            X( LDX, * ), XACT( LDXACT, * )
00116 *     ..
00117 *
00118 *  =====================================================================
00119 *
00120 *     .. Parameters ..
00121       REAL               ZERO
00122       PARAMETER          ( ZERO = 0.0E+0 )
00123 *     ..
00124 *     .. Local Scalars ..
00125       INTEGER            I, IX, J
00126       REAL               DIFFNM, EPS, XNORM
00127       COMPLEX            ZDUM
00128 *     ..
00129 *     .. External Functions ..
00130       INTEGER            ICAMAX
00131       REAL               SLAMCH
00132       EXTERNAL           ICAMAX, SLAMCH
00133 *     ..
00134 *     .. Intrinsic Functions ..
00135       INTRINSIC          ABS, AIMAG, MAX, REAL
00136 *     ..
00137 *     .. Statement Functions ..
00138       REAL               CABS1
00139 *     ..
00140 *     .. Statement Function definitions ..
00141       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
00142 *     ..
00143 *     .. Executable Statements ..
00144 *
00145 *     Quick exit if N = 0 or NRHS = 0.
00146 *
00147       IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00148          RESID = ZERO
00149          RETURN
00150       END IF
00151 *
00152 *     Exit with RESID = 1/EPS if RCOND is invalid.
00153 *
00154       EPS = SLAMCH( 'Epsilon' )
00155       IF( RCOND.LT.ZERO ) THEN
00156          RESID = 1.0 / EPS
00157          RETURN
00158       END IF
00159 *
00160 *     Compute the maximum of
00161 *        norm(X - XACT) / ( norm(XACT) * EPS )
00162 *     over all the vectors X and XACT .
00163 *
00164       RESID = ZERO
00165       DO 20 J = 1, NRHS
00166          IX = ICAMAX( N, XACT( 1, J ), 1 )
00167          XNORM = CABS1( XACT( IX, J ) )
00168          DIFFNM = ZERO
00169          DO 10 I = 1, N
00170             DIFFNM = MAX( DIFFNM, CABS1( X( I, J )-XACT( I, J ) ) )
00171    10    CONTINUE
00172          IF( XNORM.LE.ZERO ) THEN
00173             IF( DIFFNM.GT.ZERO )
00174      $         RESID = 1.0 / EPS
00175          ELSE
00176             RESID = MAX( RESID, ( DIFFNM / XNORM )*RCOND )
00177          END IF
00178    20 CONTINUE
00179       IF( RESID*EPS.LT.1.0 )
00180      $   RESID = RESID / EPS
00181 *
00182       RETURN
00183 *
00184 *     End of CGET04
00185 *
00186       END
 All Files Functions