LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sgbt02.f
Go to the documentation of this file.
00001 *> \brief \b SGBT02
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 SGBT02( 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 *       REAL               A( LDA, * ), B( LDB, * ), X( LDX, * )
00021 *       ..
00022 *  
00023 *
00024 *> \par Purpose:
00025 *  =============
00026 *>
00027 *> \verbatim
00028 *>
00029 *> SGBT02 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 REAL 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 REAL 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 REAL 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 single_lin
00137 *
00138 *  =====================================================================
00139       SUBROUTINE SGBT02( 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       REAL               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 *     ..
00162 *     .. Local Scalars ..
00163       INTEGER            I1, I2, J, KD, N1
00164       REAL               ANORM, BNORM, EPS, XNORM
00165 *     ..
00166 *     .. External Functions ..
00167       LOGICAL            LSAME
00168       REAL               SASUM, SLAMCH
00169       EXTERNAL           LSAME, SASUM, SLAMCH
00170 *     ..
00171 *     .. External Subroutines ..
00172       EXTERNAL           SGBMV
00173 *     ..
00174 *     .. Intrinsic Functions ..
00175       INTRINSIC          MAX, MIN
00176 *     ..
00177 *     .. Executable Statements ..
00178 *
00179 *     Quick return if N = 0 pr NRHS = 0
00180 *
00181       IF( M.LE.0 .OR. N.LE.0 .OR. NRHS.LE.0 ) THEN
00182          RESID = ZERO
00183          RETURN
00184       END IF
00185 *
00186 *     Exit with RESID = 1/EPS if ANORM = 0.
00187 *
00188       EPS = SLAMCH( 'Epsilon' )
00189       KD = KU + 1
00190       ANORM = ZERO
00191       DO 10 J = 1, N
00192          I1 = MAX( KD+1-J, 1 )
00193          I2 = MIN( KD+M-J, KL+KD )
00194          ANORM = MAX( ANORM, SASUM( I2-I1+1, A( I1, J ), 1 ) )
00195    10 CONTINUE
00196       IF( ANORM.LE.ZERO ) THEN
00197          RESID = ONE / EPS
00198          RETURN
00199       END IF
00200 *
00201       IF( LSAME( TRANS, 'T' ) .OR. LSAME( TRANS, 'C' ) ) THEN
00202          N1 = N
00203       ELSE
00204          N1 = M
00205       END IF
00206 *
00207 *     Compute  B - A*X (or  B - A'*X )
00208 *
00209       DO 20 J = 1, NRHS
00210          CALL SGBMV( TRANS, M, N, KL, KU, -ONE, A, LDA, X( 1, J ), 1,
00211      $               ONE, B( 1, J ), 1 )
00212    20 CONTINUE
00213 *
00214 *     Compute the maximum over the number of right hand sides of
00215 *        norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
00216 *
00217       RESID = ZERO
00218       DO 30 J = 1, NRHS
00219          BNORM = SASUM( N1, B( 1, J ), 1 )
00220          XNORM = SASUM( N1, X( 1, J ), 1 )
00221          IF( XNORM.LE.ZERO ) THEN
00222             RESID = ONE / EPS
00223          ELSE
00224             RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
00225          END IF
00226    30 CONTINUE
00227 *
00228       RETURN
00229 *
00230 *     End of SGBT02
00231 *
00232       END
 All Files Functions