LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dppsvx.f
Go to the documentation of this file.
00001 *> \brief <b> DPPSVX computes the solution to system of linear equations A * X = B for OTHER matrices</b>
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download DPPSVX + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dppsvx.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dppsvx.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dppsvx.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE DPPSVX( FACT, UPLO, N, NRHS, AP, AFP, EQUED, S, B, LDB,
00022 *                          X, LDX, RCOND, FERR, BERR, WORK, IWORK, INFO )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       CHARACTER          EQUED, FACT, UPLO
00026 *       INTEGER            INFO, LDB, LDX, N, NRHS
00027 *       DOUBLE PRECISION   RCOND
00028 *       ..
00029 *       .. Array Arguments ..
00030 *       INTEGER            IWORK( * )
00031 *       DOUBLE PRECISION   AFP( * ), AP( * ), B( LDB, * ), BERR( * ),
00032 *      $                   FERR( * ), S( * ), WORK( * ), X( LDX, * )
00033 *       ..
00034 *  
00035 *
00036 *> \par Purpose:
00037 *  =============
00038 *>
00039 *> \verbatim
00040 *>
00041 *> DPPSVX uses the Cholesky factorization A = U**T*U or A = L*L**T to
00042 *> compute the solution to a real system of linear equations
00043 *>    A * X = B,
00044 *> where A is an N-by-N symmetric positive definite matrix stored in
00045 *> packed format and X and B are N-by-NRHS matrices.
00046 *>
00047 *> Error bounds on the solution and a condition estimate are also
00048 *> provided.
00049 *> \endverbatim
00050 *
00051 *> \par Description:
00052 *  =================
00053 *>
00054 *> \verbatim
00055 *>
00056 *> The following steps are performed:
00057 *>
00058 *> 1. If FACT = 'E', real scaling factors are computed to equilibrate
00059 *>    the system:
00060 *>       diag(S) * A * diag(S) * inv(diag(S)) * X = diag(S) * B
00061 *>    Whether or not the system will be equilibrated depends on the
00062 *>    scaling of the matrix A, but if equilibration is used, A is
00063 *>    overwritten by diag(S)*A*diag(S) and B by diag(S)*B.
00064 *>
00065 *> 2. If FACT = 'N' or 'E', the Cholesky decomposition is used to
00066 *>    factor the matrix A (after equilibration if FACT = 'E') as
00067 *>       A = U**T* U,  if UPLO = 'U', or
00068 *>       A = L * L**T,  if UPLO = 'L',
00069 *>    where U is an upper triangular matrix and L is a lower triangular
00070 *>    matrix.
00071 *>
00072 *> 3. If the leading i-by-i principal minor is not positive definite,
00073 *>    then the routine returns with INFO = i. Otherwise, the factored
00074 *>    form of A is used to estimate the condition number of the matrix
00075 *>    A.  If the reciprocal of the condition number is less than machine
00076 *>    precision, INFO = N+1 is returned as a warning, but the routine
00077 *>    still goes on to solve for X and compute error bounds as
00078 *>    described below.
00079 *>
00080 *> 4. The system of equations is solved for X using the factored form
00081 *>    of A.
00082 *>
00083 *> 5. Iterative refinement is applied to improve the computed solution
00084 *>    matrix and calculate error bounds and backward error estimates
00085 *>    for it.
00086 *>
00087 *> 6. If equilibration was used, the matrix X is premultiplied by
00088 *>    diag(S) so that it solves the original system before
00089 *>    equilibration.
00090 *> \endverbatim
00091 *
00092 *  Arguments:
00093 *  ==========
00094 *
00095 *> \param[in] FACT
00096 *> \verbatim
00097 *>          FACT is CHARACTER*1
00098 *>          Specifies whether or not the factored form of the matrix A is
00099 *>          supplied on entry, and if not, whether the matrix A should be
00100 *>          equilibrated before it is factored.
00101 *>          = 'F':  On entry, AFP contains the factored form of A.
00102 *>                  If EQUED = 'Y', the matrix A has been equilibrated
00103 *>                  with scaling factors given by S.  AP and AFP will not
00104 *>                  be modified.
00105 *>          = 'N':  The matrix A will be copied to AFP and factored.
00106 *>          = 'E':  The matrix A will be equilibrated if necessary, then
00107 *>                  copied to AFP and factored.
00108 *> \endverbatim
00109 *>
00110 *> \param[in] UPLO
00111 *> \verbatim
00112 *>          UPLO is CHARACTER*1
00113 *>          = 'U':  Upper triangle of A is stored;
00114 *>          = 'L':  Lower triangle of A is stored.
00115 *> \endverbatim
00116 *>
00117 *> \param[in] N
00118 *> \verbatim
00119 *>          N is INTEGER
00120 *>          The number of linear equations, i.e., the order of the
00121 *>          matrix A.  N >= 0.
00122 *> \endverbatim
00123 *>
00124 *> \param[in] NRHS
00125 *> \verbatim
00126 *>          NRHS is INTEGER
00127 *>          The number of right hand sides, i.e., the number of columns
00128 *>          of the matrices B and X.  NRHS >= 0.
00129 *> \endverbatim
00130 *>
00131 *> \param[in,out] AP
00132 *> \verbatim
00133 *>          AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
00134 *>          On entry, the upper or lower triangle of the symmetric matrix
00135 *>          A, packed columnwise in a linear array, except if FACT = 'F'
00136 *>          and EQUED = 'Y', then A must contain the equilibrated matrix
00137 *>          diag(S)*A*diag(S).  The j-th column of A is stored in the
00138 *>          array AP as follows:
00139 *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00140 *>          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
00141 *>          See below for further details.  A is not modified if
00142 *>          FACT = 'F' or 'N', or if FACT = 'E' and EQUED = 'N' on exit.
00143 *>
00144 *>          On exit, if FACT = 'E' and EQUED = 'Y', A is overwritten by
00145 *>          diag(S)*A*diag(S).
00146 *> \endverbatim
00147 *>
00148 *> \param[in,out] AFP
00149 *> \verbatim
00150 *>          AFP is DOUBLE PRECISION array, dimension
00151 *>                            (N*(N+1)/2)
00152 *>          If FACT = 'F', then AFP is an input argument and on entry
00153 *>          contains the triangular factor U or L from the Cholesky
00154 *>          factorization A = U**T*U or A = L*L**T, in the same storage
00155 *>          format as A.  If EQUED .ne. 'N', then AFP is the factored
00156 *>          form of the equilibrated matrix A.
00157 *>
00158 *>          If FACT = 'N', then AFP is an output argument and on exit
00159 *>          returns the triangular factor U or L from the Cholesky
00160 *>          factorization A = U**T * U or A = L * L**T of the original
00161 *>          matrix A.
00162 *>
00163 *>          If FACT = 'E', then AFP is an output argument and on exit
00164 *>          returns the triangular factor U or L from the Cholesky
00165 *>          factorization A = U**T * U or A = L * L**T of the equilibrated
00166 *>          matrix A (see the description of AP for the form of the
00167 *>          equilibrated matrix).
00168 *> \endverbatim
00169 *>
00170 *> \param[in,out] EQUED
00171 *> \verbatim
00172 *>          EQUED is CHARACTER*1
00173 *>          Specifies the form of equilibration that was done.
00174 *>          = 'N':  No equilibration (always true if FACT = 'N').
00175 *>          = 'Y':  Equilibration was done, i.e., A has been replaced by
00176 *>                  diag(S) * A * diag(S).
00177 *>          EQUED is an input argument if FACT = 'F'; otherwise, it is an
00178 *>          output argument.
00179 *> \endverbatim
00180 *>
00181 *> \param[in,out] S
00182 *> \verbatim
00183 *>          S is DOUBLE PRECISION array, dimension (N)
00184 *>          The scale factors for A; not accessed if EQUED = 'N'.  S is
00185 *>          an input argument if FACT = 'F'; otherwise, S is an output
00186 *>          argument.  If FACT = 'F' and EQUED = 'Y', each element of S
00187 *>          must be positive.
00188 *> \endverbatim
00189 *>
00190 *> \param[in,out] B
00191 *> \verbatim
00192 *>          B is DOUBLE PRECISION array, dimension (LDB,NRHS)
00193 *>          On entry, the N-by-NRHS right hand side matrix B.
00194 *>          On exit, if EQUED = 'N', B is not modified; if EQUED = 'Y',
00195 *>          B is overwritten by diag(S) * B.
00196 *> \endverbatim
00197 *>
00198 *> \param[in] LDB
00199 *> \verbatim
00200 *>          LDB is INTEGER
00201 *>          The leading dimension of the array B.  LDB >= max(1,N).
00202 *> \endverbatim
00203 *>
00204 *> \param[out] X
00205 *> \verbatim
00206 *>          X is DOUBLE PRECISION array, dimension (LDX,NRHS)
00207 *>          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X to
00208 *>          the original system of equations.  Note that if EQUED = 'Y',
00209 *>          A and B are modified on exit, and the solution to the
00210 *>          equilibrated system is inv(diag(S))*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 after equilibration (if done).  If RCOND is less than the
00224 *>          machine precision (in particular, if RCOND = 0), the matrix
00225 *>          is singular to working precision.  This condition is
00226 *>          indicated by a return code of 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 DOUBLE PRECISION array, dimension (3*N)
00253 *> \endverbatim
00254 *>
00255 *> \param[out] IWORK
00256 *> \verbatim
00257 *>          IWORK is INTEGER 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:  the leading minor of order i of A is
00267 *>                       not positive definite, so the factorization
00268 *>                       could not be completed, and the solution has not
00269 *>                       been computed. RCOND = 0 is returned.
00270 *>                = N+1: U is nonsingular, but RCOND is less than machine
00271 *>                       precision, meaning that the matrix is singular
00272 *>                       to working precision.  Nevertheless, the
00273 *>                       solution and error bounds are computed because
00274 *>                       there are a number of situations where the
00275 *>                       computed solution can be more accurate than the
00276 *>                       value of RCOND would suggest.
00277 *> \endverbatim
00278 *
00279 *  Authors:
00280 *  ========
00281 *
00282 *> \author Univ. of Tennessee 
00283 *> \author Univ. of California Berkeley 
00284 *> \author Univ. of Colorado Denver 
00285 *> \author NAG Ltd. 
00286 *
00287 *> \date April 2012
00288 *
00289 *> \ingroup doubleOTHERsolve
00290 *
00291 *> \par Further Details:
00292 *  =====================
00293 *>
00294 *> \verbatim
00295 *>
00296 *>  The packed storage scheme is illustrated by the following example
00297 *>  when N = 4, UPLO = 'U':
00298 *>
00299 *>  Two-dimensional storage of the symmetric matrix A:
00300 *>
00301 *>     a11 a12 a13 a14
00302 *>         a22 a23 a24
00303 *>             a33 a34     (aij = conjg(aji))
00304 *>                 a44
00305 *>
00306 *>  Packed storage of the upper triangle of A:
00307 *>
00308 *>  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
00309 *> \endverbatim
00310 *>
00311 *  =====================================================================
00312       SUBROUTINE DPPSVX( FACT, UPLO, N, NRHS, AP, AFP, EQUED, S, B, LDB,
00313      $                   X, LDX, RCOND, FERR, BERR, WORK, IWORK, INFO )
00314 *
00315 *  -- LAPACK driver routine (version 3.4.1) --
00316 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00317 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00318 *     April 2012
00319 *
00320 *     .. Scalar Arguments ..
00321       CHARACTER          EQUED, FACT, UPLO
00322       INTEGER            INFO, LDB, LDX, N, NRHS
00323       DOUBLE PRECISION   RCOND
00324 *     ..
00325 *     .. Array Arguments ..
00326       INTEGER            IWORK( * )
00327       DOUBLE PRECISION   AFP( * ), AP( * ), B( LDB, * ), BERR( * ),
00328      $                   FERR( * ), S( * ), WORK( * ), X( LDX, * )
00329 *     ..
00330 *
00331 *  =====================================================================
00332 *
00333 *     .. Parameters ..
00334       DOUBLE PRECISION   ZERO, ONE
00335       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00336 *     ..
00337 *     .. Local Scalars ..
00338       LOGICAL            EQUIL, NOFACT, RCEQU
00339       INTEGER            I, INFEQU, J
00340       DOUBLE PRECISION   AMAX, ANORM, BIGNUM, SCOND, SMAX, SMIN, SMLNUM
00341 *     ..
00342 *     .. External Functions ..
00343       LOGICAL            LSAME
00344       DOUBLE PRECISION   DLAMCH, DLANSP
00345       EXTERNAL           LSAME, DLAMCH, DLANSP
00346 *     ..
00347 *     .. External Subroutines ..
00348       EXTERNAL           DCOPY, DLACPY, DLAQSP, DPPCON, DPPEQU, DPPRFS,
00349      $                   DPPTRF, DPPTRS, XERBLA
00350 *     ..
00351 *     .. Intrinsic Functions ..
00352       INTRINSIC          MAX, MIN
00353 *     ..
00354 *     .. Executable Statements ..
00355 *
00356       INFO = 0
00357       NOFACT = LSAME( FACT, 'N' )
00358       EQUIL = LSAME( FACT, 'E' )
00359       IF( NOFACT .OR. EQUIL ) THEN
00360          EQUED = 'N'
00361          RCEQU = .FALSE.
00362       ELSE
00363          RCEQU = LSAME( EQUED, 'Y' )
00364          SMLNUM = DLAMCH( 'Safe minimum' )
00365          BIGNUM = ONE / SMLNUM
00366       END IF
00367 *
00368 *     Test the input parameters.
00369 *
00370       IF( .NOT.NOFACT .AND. .NOT.EQUIL .AND. .NOT.LSAME( FACT, 'F' ) )
00371      $     THEN
00372          INFO = -1
00373       ELSE IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) )
00374      $          THEN
00375          INFO = -2
00376       ELSE IF( N.LT.0 ) THEN
00377          INFO = -3
00378       ELSE IF( NRHS.LT.0 ) THEN
00379          INFO = -4
00380       ELSE IF( LSAME( FACT, 'F' ) .AND. .NOT.
00381      $         ( RCEQU .OR. LSAME( EQUED, 'N' ) ) ) THEN
00382          INFO = -7
00383       ELSE
00384          IF( RCEQU ) THEN
00385             SMIN = BIGNUM
00386             SMAX = ZERO
00387             DO 10 J = 1, N
00388                SMIN = MIN( SMIN, S( J ) )
00389                SMAX = MAX( SMAX, S( J ) )
00390    10       CONTINUE
00391             IF( SMIN.LE.ZERO ) THEN
00392                INFO = -8
00393             ELSE IF( N.GT.0 ) THEN
00394                SCOND = MAX( SMIN, SMLNUM ) / MIN( SMAX, BIGNUM )
00395             ELSE
00396                SCOND = ONE
00397             END IF
00398          END IF
00399          IF( INFO.EQ.0 ) THEN
00400             IF( LDB.LT.MAX( 1, N ) ) THEN
00401                INFO = -10
00402             ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
00403                INFO = -12
00404             END IF
00405          END IF
00406       END IF
00407 *
00408       IF( INFO.NE.0 ) THEN
00409          CALL XERBLA( 'DPPSVX', -INFO )
00410          RETURN
00411       END IF
00412 *
00413       IF( EQUIL ) THEN
00414 *
00415 *        Compute row and column scalings to equilibrate the matrix A.
00416 *
00417          CALL DPPEQU( UPLO, N, AP, S, SCOND, AMAX, INFEQU )
00418          IF( INFEQU.EQ.0 ) THEN
00419 *
00420 *           Equilibrate the matrix.
00421 *
00422             CALL DLAQSP( UPLO, N, AP, S, SCOND, AMAX, EQUED )
00423             RCEQU = LSAME( EQUED, 'Y' )
00424          END IF
00425       END IF
00426 *
00427 *     Scale the right-hand side.
00428 *
00429       IF( RCEQU ) THEN
00430          DO 30 J = 1, NRHS
00431             DO 20 I = 1, N
00432                B( I, J ) = S( I )*B( I, J )
00433    20       CONTINUE
00434    30    CONTINUE
00435       END IF
00436 *
00437       IF( NOFACT .OR. EQUIL ) THEN
00438 *
00439 *        Compute the Cholesky factorization A = U**T * U or A = L * L**T.
00440 *
00441          CALL DCOPY( N*( N+1 ) / 2, AP, 1, AFP, 1 )
00442          CALL DPPTRF( UPLO, N, AFP, INFO )
00443 *
00444 *        Return if INFO is non-zero.
00445 *
00446          IF( INFO.GT.0 )THEN
00447             RCOND = ZERO
00448             RETURN
00449          END IF
00450       END IF
00451 *
00452 *     Compute the norm of the matrix A.
00453 *
00454       ANORM = DLANSP( 'I', UPLO, N, AP, WORK )
00455 *
00456 *     Compute the reciprocal of the condition number of A.
00457 *
00458       CALL DPPCON( UPLO, N, AFP, ANORM, RCOND, WORK, IWORK, INFO )
00459 *
00460 *     Compute the solution matrix X.
00461 *
00462       CALL DLACPY( 'Full', N, NRHS, B, LDB, X, LDX )
00463       CALL DPPTRS( UPLO, N, NRHS, AFP, X, LDX, INFO )
00464 *
00465 *     Use iterative refinement to improve the computed solution and
00466 *     compute error bounds and backward error estimates for it.
00467 *
00468       CALL DPPRFS( UPLO, N, NRHS, AP, AFP, B, LDB, X, LDX, FERR, BERR,
00469      $             WORK, IWORK, INFO )
00470 *
00471 *     Transform the solution matrix X to a solution of the original
00472 *     system.
00473 *
00474       IF( RCEQU ) THEN
00475          DO 50 J = 1, NRHS
00476             DO 40 I = 1, N
00477                X( I, J ) = S( I )*X( I, J )
00478    40       CONTINUE
00479    50    CONTINUE
00480          DO 60 J = 1, NRHS
00481             FERR( J ) = FERR( J ) / SCOND
00482    60    CONTINUE
00483       END IF
00484 *
00485 *     Set INFO = N+1 if the matrix is singular to working precision.
00486 *
00487       IF( RCOND.LT.DLAMCH( 'Epsilon' ) )
00488      $   INFO = N + 1
00489 *
00490       RETURN
00491 *
00492 *     End of DPPSVX
00493 *
00494       END
 All Files Functions