LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
zgtsvx.f
Go to the documentation of this file.
00001 *> \brief \b ZGTSVX
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download ZGTSVX + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgtsvx.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgtsvx.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgtsvx.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE ZGTSVX( FACT, TRANS, N, NRHS, DL, D, DU, DLF, DF, DUF,
00022 *                          DU2, IPIV, B, LDB, X, LDX, RCOND, FERR, BERR,
00023 *                          WORK, RWORK, INFO )
00024 * 
00025 *       .. Scalar Arguments ..
00026 *       CHARACTER          FACT, TRANS
00027 *       INTEGER            INFO, LDB, LDX, N, NRHS
00028 *       DOUBLE PRECISION   RCOND
00029 *       ..
00030 *       .. Array Arguments ..
00031 *       INTEGER            IPIV( * )
00032 *       DOUBLE PRECISION   BERR( * ), FERR( * ), RWORK( * )
00033 *       COMPLEX*16         B( LDB, * ), D( * ), DF( * ), DL( * ),
00034 *      $                   DLF( * ), DU( * ), DU2( * ), DUF( * ),
00035 *      $                   WORK( * ), X( LDX, * )
00036 *       ..
00037 *  
00038 *
00039 *> \par Purpose:
00040 *  =============
00041 *>
00042 *> \verbatim
00043 *>
00044 *> ZGTSVX uses the LU factorization to compute the solution to a complex
00045 *> system of linear equations A * X = B, A**T * X = B, or A**H * X = B,
00046 *> where A is a tridiagonal matrix of order N and X and B are N-by-NRHS
00047 *> matrices.
00048 *>
00049 *> Error bounds on the solution and a condition estimate are also
00050 *> provided.
00051 *> \endverbatim
00052 *
00053 *> \par Description:
00054 *  =================
00055 *>
00056 *> \verbatim
00057 *>
00058 *> The following steps are performed:
00059 *>
00060 *> 1. If FACT = 'N', the LU decomposition is used to factor the matrix A
00061 *>    as A = L * U, where L is a product of permutation and unit lower
00062 *>    bidiagonal matrices and U is upper triangular with nonzeros in
00063 *>    only the main diagonal and first two superdiagonals.
00064 *>
00065 *> 2. If some U(i,i)=0, so that U is exactly singular, then the routine
00066 *>    returns with INFO = i. Otherwise, the factored form of A is used
00067 *>    to estimate the condition number of the matrix A.  If the
00068 *>    reciprocal of the condition number is less than machine precision,
00069 *>    INFO = N+1 is returned as a warning, but the routine still goes on
00070 *>    to solve for X and compute error bounds as described below.
00071 *>
00072 *> 3. The system of equations is solved for X using the factored form
00073 *>    of A.
00074 *>
00075 *> 4. Iterative refinement is applied to improve the computed solution
00076 *>    matrix and calculate error bounds and backward error estimates
00077 *>    for it.
00078 *> \endverbatim
00079 *
00080 *  Arguments:
00081 *  ==========
00082 *
00083 *> \param[in] FACT
00084 *> \verbatim
00085 *>          FACT is CHARACTER*1
00086 *>          Specifies whether or not the factored form of A has been
00087 *>          supplied on entry.
00088 *>          = 'F':  DLF, DF, DUF, DU2, and IPIV contain the factored form
00089 *>                  of A; DL, D, DU, DLF, DF, DUF, DU2 and IPIV will not
00090 *>                  be modified.
00091 *>          = 'N':  The matrix will be copied to DLF, DF, and DUF
00092 *>                  and factored.
00093 *> \endverbatim
00094 *>
00095 *> \param[in] TRANS
00096 *> \verbatim
00097 *>          TRANS is CHARACTER*1
00098 *>          Specifies the form of the system of equations:
00099 *>          = 'N':  A * X = B     (No transpose)
00100 *>          = 'T':  A**T * X = B  (Transpose)
00101 *>          = 'C':  A**H * X = B  (Conjugate transpose)
00102 *> \endverbatim
00103 *>
00104 *> \param[in] N
00105 *> \verbatim
00106 *>          N is INTEGER
00107 *>          The order of the matrix A.  N >= 0.
00108 *> \endverbatim
00109 *>
00110 *> \param[in] NRHS
00111 *> \verbatim
00112 *>          NRHS is INTEGER
00113 *>          The number of right hand sides, i.e., the number of columns
00114 *>          of the matrix B.  NRHS >= 0.
00115 *> \endverbatim
00116 *>
00117 *> \param[in] DL
00118 *> \verbatim
00119 *>          DL is COMPLEX*16 array, dimension (N-1)
00120 *>          The (n-1) subdiagonal elements of A.
00121 *> \endverbatim
00122 *>
00123 *> \param[in] D
00124 *> \verbatim
00125 *>          D is COMPLEX*16 array, dimension (N)
00126 *>          The n diagonal elements of A.
00127 *> \endverbatim
00128 *>
00129 *> \param[in] DU
00130 *> \verbatim
00131 *>          DU is COMPLEX*16 array, dimension (N-1)
00132 *>          The (n-1) superdiagonal elements of A.
00133 *> \endverbatim
00134 *>
00135 *> \param[in,out] DLF
00136 *> \verbatim
00137 *>          DLF is COMPLEX*16 array, dimension (N-1)
00138 *>          If FACT = 'F', then DLF is an input argument and on entry
00139 *>          contains the (n-1) multipliers that define the matrix L from
00140 *>          the LU factorization of A as computed by ZGTTRF.
00141 *>
00142 *>          If FACT = 'N', then DLF is an output argument and on exit
00143 *>          contains the (n-1) multipliers that define the matrix L from
00144 *>          the LU factorization of A.
00145 *> \endverbatim
00146 *>
00147 *> \param[in,out] DF
00148 *> \verbatim
00149 *>          DF is COMPLEX*16 array, dimension (N)
00150 *>          If FACT = 'F', then DF is an input argument and on entry
00151 *>          contains the n diagonal elements of the upper triangular
00152 *>          matrix U from the LU factorization of A.
00153 *>
00154 *>          If FACT = 'N', then DF is an output argument and on exit
00155 *>          contains the n diagonal elements of the upper triangular
00156 *>          matrix U from the LU factorization of A.
00157 *> \endverbatim
00158 *>
00159 *> \param[in,out] DUF
00160 *> \verbatim
00161 *>          DUF is COMPLEX*16 array, dimension (N-1)
00162 *>          If FACT = 'F', then DUF is an input argument and on entry
00163 *>          contains the (n-1) elements of the first superdiagonal of U.
00164 *>
00165 *>          If FACT = 'N', then DUF is an output argument and on exit
00166 *>          contains the (n-1) elements of the first superdiagonal of U.
00167 *> \endverbatim
00168 *>
00169 *> \param[in,out] DU2
00170 *> \verbatim
00171 *>          DU2 is COMPLEX*16 array, dimension (N-2)
00172 *>          If FACT = 'F', then DU2 is an input argument and on entry
00173 *>          contains the (n-2) elements of the second superdiagonal of
00174 *>          U.
00175 *>
00176 *>          If FACT = 'N', then DU2 is an output argument and on exit
00177 *>          contains the (n-2) elements of the second superdiagonal of
00178 *>          U.
00179 *> \endverbatim
00180 *>
00181 *> \param[in,out] IPIV
00182 *> \verbatim
00183 *>          IPIV is INTEGER array, dimension (N)
00184 *>          If FACT = 'F', then IPIV is an input argument and on entry
00185 *>          contains the pivot indices from the LU factorization of A as
00186 *>          computed by ZGTTRF.
00187 *>
00188 *>          If FACT = 'N', then IPIV is an output argument and on exit
00189 *>          contains the pivot indices from the LU factorization of A;
00190 *>          row i of the matrix was interchanged with row IPIV(i).
00191 *>          IPIV(i) will always be either i or i+1; IPIV(i) = i indicates
00192 *>          a row interchange was not required.
00193 *> \endverbatim
00194 *>
00195 *> \param[in] B
00196 *> \verbatim
00197 *>          B is COMPLEX*16 array, dimension (LDB,NRHS)
00198 *>          The N-by-NRHS right hand side matrix B.
00199 *> \endverbatim
00200 *>
00201 *> \param[in] LDB
00202 *> \verbatim
00203 *>          LDB is INTEGER
00204 *>          The leading dimension of the array B.  LDB >= max(1,N).
00205 *> \endverbatim
00206 *>
00207 *> \param[out] X
00208 *> \verbatim
00209 *>          X is COMPLEX*16 array, dimension (LDX,NRHS)
00210 *>          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
00211 *> \endverbatim
00212 *>
00213 *> \param[in] LDX
00214 *> \verbatim
00215 *>          LDX is INTEGER
00216 *>          The leading dimension of the array X.  LDX >= max(1,N).
00217 *> \endverbatim
00218 *>
00219 *> \param[out] RCOND
00220 *> \verbatim
00221 *>          RCOND is DOUBLE PRECISION
00222 *>          The estimate of the reciprocal condition number of the matrix
00223 *>          A.  If RCOND is less than the machine precision (in
00224 *>          particular, if RCOND = 0), the matrix is singular to working
00225 *>          precision.  This condition is indicated by a return code of
00226 *>          INFO > 0.
00227 *> \endverbatim
00228 *>
00229 *> \param[out] FERR
00230 *> \verbatim
00231 *>          FERR is DOUBLE PRECISION array, dimension (NRHS)
00232 *>          The estimated forward error bound for each solution vector
00233 *>          X(j) (the j-th column of the solution matrix X).
00234 *>          If XTRUE is the true solution corresponding to X(j), FERR(j)
00235 *>          is an estimated upper bound for the magnitude of the largest
00236 *>          element in (X(j) - XTRUE) divided by the magnitude of the
00237 *>          largest element in X(j).  The estimate is as reliable as
00238 *>          the estimate for RCOND, and is almost always a slight
00239 *>          overestimate of the true error.
00240 *> \endverbatim
00241 *>
00242 *> \param[out] BERR
00243 *> \verbatim
00244 *>          BERR is DOUBLE PRECISION array, dimension (NRHS)
00245 *>          The componentwise relative backward error of each solution
00246 *>          vector X(j) (i.e., the smallest relative change in
00247 *>          any element of A or B that makes X(j) an exact solution).
00248 *> \endverbatim
00249 *>
00250 *> \param[out] WORK
00251 *> \verbatim
00252 *>          WORK is COMPLEX*16 array, dimension (2*N)
00253 *> \endverbatim
00254 *>
00255 *> \param[out] RWORK
00256 *> \verbatim
00257 *>          RWORK is DOUBLE PRECISION array, dimension (N)
00258 *> \endverbatim
00259 *>
00260 *> \param[out] INFO
00261 *> \verbatim
00262 *>          INFO is INTEGER
00263 *>          = 0:  successful exit
00264 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00265 *>          > 0:  if INFO = i, and i is
00266 *>                <= N:  U(i,i) is exactly zero.  The factorization
00267 *>                       has not been completed unless i = N, but the
00268 *>                       factor U is exactly singular, so the solution
00269 *>                       and error bounds could not be computed.
00270 *>                       RCOND = 0 is returned.
00271 *>                = N+1: U is nonsingular, but RCOND is less than machine
00272 *>                       precision, meaning that the matrix is singular
00273 *>                       to working precision.  Nevertheless, the
00274 *>                       solution and error bounds are computed because
00275 *>                       there are a number of situations where the
00276 *>                       computed solution can be more accurate than the
00277 *>                       value of RCOND would suggest.
00278 *> \endverbatim
00279 *
00280 *  Authors:
00281 *  ========
00282 *
00283 *> \author Univ. of Tennessee 
00284 *> \author Univ. of California Berkeley 
00285 *> \author Univ. of Colorado Denver 
00286 *> \author NAG Ltd. 
00287 *
00288 *> \date April 2012
00289 *
00290 *> \ingroup complex16OTHERcomputational
00291 *
00292 *  =====================================================================
00293       SUBROUTINE ZGTSVX( FACT, TRANS, N, NRHS, DL, D, DU, DLF, DF, DUF,
00294      $                   DU2, IPIV, B, LDB, X, LDX, RCOND, FERR, BERR,
00295      $                   WORK, RWORK, INFO )
00296 *
00297 *  -- LAPACK computational routine (version 3.4.1) --
00298 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00299 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00300 *     April 2012
00301 *
00302 *     .. Scalar Arguments ..
00303       CHARACTER          FACT, TRANS
00304       INTEGER            INFO, LDB, LDX, N, NRHS
00305       DOUBLE PRECISION   RCOND
00306 *     ..
00307 *     .. Array Arguments ..
00308       INTEGER            IPIV( * )
00309       DOUBLE PRECISION   BERR( * ), FERR( * ), RWORK( * )
00310       COMPLEX*16         B( LDB, * ), D( * ), DF( * ), DL( * ),
00311      $                   DLF( * ), DU( * ), DU2( * ), DUF( * ),
00312      $                   WORK( * ), X( LDX, * )
00313 *     ..
00314 *
00315 *  =====================================================================
00316 *
00317 *     .. Parameters ..
00318       DOUBLE PRECISION   ZERO
00319       PARAMETER          ( ZERO = 0.0D+0 )
00320 *     ..
00321 *     .. Local Scalars ..
00322       LOGICAL            NOFACT, NOTRAN
00323       CHARACTER          NORM
00324       DOUBLE PRECISION   ANORM
00325 *     ..
00326 *     .. External Functions ..
00327       LOGICAL            LSAME
00328       DOUBLE PRECISION   DLAMCH, ZLANGT
00329       EXTERNAL           LSAME, DLAMCH, ZLANGT
00330 *     ..
00331 *     .. External Subroutines ..
00332       EXTERNAL           XERBLA, ZCOPY, ZGTCON, ZGTRFS, ZGTTRF, ZGTTRS,
00333      $                   ZLACPY
00334 *     ..
00335 *     .. Intrinsic Functions ..
00336       INTRINSIC          MAX
00337 *     ..
00338 *     .. Executable Statements ..
00339 *
00340       INFO = 0
00341       NOFACT = LSAME( FACT, 'N' )
00342       NOTRAN = LSAME( TRANS, 'N' )
00343       IF( .NOT.NOFACT .AND. .NOT.LSAME( FACT, 'F' ) ) THEN
00344          INFO = -1
00345       ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
00346      $         LSAME( TRANS, 'C' ) ) THEN
00347          INFO = -2
00348       ELSE IF( N.LT.0 ) THEN
00349          INFO = -3
00350       ELSE IF( NRHS.LT.0 ) THEN
00351          INFO = -4
00352       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00353          INFO = -14
00354       ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
00355          INFO = -16
00356       END IF
00357       IF( INFO.NE.0 ) THEN
00358          CALL XERBLA( 'ZGTSVX', -INFO )
00359          RETURN
00360       END IF
00361 *
00362       IF( NOFACT ) THEN
00363 *
00364 *        Compute the LU factorization of A.
00365 *
00366          CALL ZCOPY( N, D, 1, DF, 1 )
00367          IF( N.GT.1 ) THEN
00368             CALL ZCOPY( N-1, DL, 1, DLF, 1 )
00369             CALL ZCOPY( N-1, DU, 1, DUF, 1 )
00370          END IF
00371          CALL ZGTTRF( N, DLF, DF, DUF, DU2, IPIV, INFO )
00372 *
00373 *        Return if INFO is non-zero.
00374 *
00375          IF( INFO.GT.0 )THEN
00376             RCOND = ZERO
00377             RETURN
00378          END IF
00379       END IF
00380 *
00381 *     Compute the norm of the matrix A.
00382 *
00383       IF( NOTRAN ) THEN
00384          NORM = '1'
00385       ELSE
00386          NORM = 'I'
00387       END IF
00388       ANORM = ZLANGT( NORM, N, DL, D, DU )
00389 *
00390 *     Compute the reciprocal of the condition number of A.
00391 *
00392       CALL ZGTCON( NORM, N, DLF, DF, DUF, DU2, IPIV, ANORM, RCOND, WORK,
00393      $             INFO )
00394 *
00395 *     Compute the solution vectors X.
00396 *
00397       CALL ZLACPY( 'Full', N, NRHS, B, LDB, X, LDX )
00398       CALL ZGTTRS( TRANS, N, NRHS, DLF, DF, DUF, DU2, IPIV, X, LDX,
00399      $             INFO )
00400 *
00401 *     Use iterative refinement to improve the computed solutions and
00402 *     compute error bounds and backward error estimates for them.
00403 *
00404       CALL ZGTRFS( TRANS, N, NRHS, DL, D, DU, DLF, DF, DUF, DU2, IPIV,
00405      $             B, LDB, X, LDX, FERR, BERR, WORK, RWORK, INFO )
00406 *
00407 *     Set INFO = N+1 if the matrix is singular to working precision.
00408 *
00409       IF( RCOND.LT.DLAMCH( 'Epsilon' ) )
00410      $   INFO = N + 1
00411 *
00412       RETURN
00413 *
00414 *     End of ZGTSVX
00415 *
00416       END
 All Files Functions