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