LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sspsvx.f
Go to the documentation of this file.
00001 *> \brief <b> SSPSVX 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 SSPSVX + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sspsvx.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sspsvx.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sspsvx.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SSPSVX( FACT, UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X,
00022 *                          LDX, RCOND, FERR, BERR, WORK, IWORK, INFO )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       CHARACTER          FACT, UPLO
00026 *       INTEGER            INFO, LDB, LDX, N, NRHS
00027 *       REAL               RCOND
00028 *       ..
00029 *       .. Array Arguments ..
00030 *       INTEGER            IPIV( * ), IWORK( * )
00031 *       REAL               AFP( * ), AP( * ), B( LDB, * ), BERR( * ),
00032 *      $                   FERR( * ), WORK( * ), X( LDX, * )
00033 *       ..
00034 *  
00035 *
00036 *> \par Purpose:
00037 *  =============
00038 *>
00039 *> \verbatim
00040 *>
00041 *> SSPSVX uses the diagonal pivoting factorization A = U*D*U**T or
00042 *> A = L*D*L**T to compute the solution to a real system of linear
00043 *> equations A * X = B, where A is an N-by-N symmetric matrix stored
00044 *> in packed format and X and B are N-by-NRHS matrices.
00045 *>
00046 *> Error bounds on the solution and a condition estimate are also
00047 *> provided.
00048 *> \endverbatim
00049 *
00050 *> \par Description:
00051 *  =================
00052 *>
00053 *> \verbatim
00054 *>
00055 *> The following steps are performed:
00056 *>
00057 *> 1. If FACT = 'N', the diagonal pivoting method is used to factor A as
00058 *>       A = U * D * U**T,  if UPLO = 'U', or
00059 *>       A = L * D * L**T,  if UPLO = 'L',
00060 *>    where U (or L) is a product of permutation and unit upper (lower)
00061 *>    triangular matrices and D is symmetric and block diagonal with
00062 *>    1-by-1 and 2-by-2 diagonal blocks.
00063 *>
00064 *> 2. If some D(i,i)=0, so that D is exactly singular, then the routine
00065 *>    returns with INFO = i. Otherwise, the factored form of A is used
00066 *>    to estimate the condition number of the matrix A.  If the
00067 *>    reciprocal of the condition number is less than machine precision,
00068 *>    INFO = N+1 is returned as a warning, but the routine still goes on
00069 *>    to solve for X and compute error bounds as described below.
00070 *>
00071 *> 3. The system of equations is solved for X using the factored form
00072 *>    of A.
00073 *>
00074 *> 4. Iterative refinement is applied to improve the computed solution
00075 *>    matrix and calculate error bounds and backward error estimates
00076 *>    for it.
00077 *> \endverbatim
00078 *
00079 *  Arguments:
00080 *  ==========
00081 *
00082 *> \param[in] FACT
00083 *> \verbatim
00084 *>          FACT is CHARACTER*1
00085 *>          Specifies whether or not the factored form of A has been
00086 *>          supplied on entry.
00087 *>          = 'F':  On entry, AFP and IPIV contain the factored form of
00088 *>                  A.  AP, AFP and IPIV will not be modified.
00089 *>          = 'N':  The matrix A will be copied to AFP and factored.
00090 *> \endverbatim
00091 *>
00092 *> \param[in] UPLO
00093 *> \verbatim
00094 *>          UPLO is CHARACTER*1
00095 *>          = 'U':  Upper triangle of A is stored;
00096 *>          = 'L':  Lower triangle of A is stored.
00097 *> \endverbatim
00098 *>
00099 *> \param[in] N
00100 *> \verbatim
00101 *>          N is INTEGER
00102 *>          The number of linear equations, i.e., the order of the
00103 *>          matrix A.  N >= 0.
00104 *> \endverbatim
00105 *>
00106 *> \param[in] NRHS
00107 *> \verbatim
00108 *>          NRHS is INTEGER
00109 *>          The number of right hand sides, i.e., the number of columns
00110 *>          of the matrices B and X.  NRHS >= 0.
00111 *> \endverbatim
00112 *>
00113 *> \param[in] AP
00114 *> \verbatim
00115 *>          AP is REAL array, dimension (N*(N+1)/2)
00116 *>          The upper or lower triangle of the symmetric matrix A, packed
00117 *>          columnwise in a linear array.  The j-th column of A is stored
00118 *>          in the array AP as follows:
00119 *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00120 *>          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
00121 *>          See below for further details.
00122 *> \endverbatim
00123 *>
00124 *> \param[in,out] AFP
00125 *> \verbatim
00126 *>          AFP is REAL array, dimension
00127 *>                            (N*(N+1)/2)
00128 *>          If FACT = 'F', then AFP is an input argument and on entry
00129 *>          contains the block diagonal matrix D and the multipliers used
00130 *>          to obtain the factor U or L from the factorization
00131 *>          A = U*D*U**T or A = L*D*L**T as computed by SSPTRF, stored as
00132 *>          a packed triangular matrix in the same storage format as A.
00133 *>
00134 *>          If FACT = 'N', then AFP is an output argument and on exit
00135 *>          contains the block diagonal matrix D and the multipliers used
00136 *>          to obtain the factor U or L from the factorization
00137 *>          A = U*D*U**T or A = L*D*L**T as computed by SSPTRF, stored as
00138 *>          a packed triangular matrix in the same storage format as A.
00139 *> \endverbatim
00140 *>
00141 *> \param[in,out] IPIV
00142 *> \verbatim
00143 *>          IPIV is INTEGER array, dimension (N)
00144 *>          If FACT = 'F', then IPIV is an input argument and on entry
00145 *>          contains details of the interchanges and the block structure
00146 *>          of D, as determined by SSPTRF.
00147 *>          If IPIV(k) > 0, then rows and columns k and IPIV(k) were
00148 *>          interchanged and D(k,k) is a 1-by-1 diagonal block.
00149 *>          If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and
00150 *>          columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
00151 *>          is a 2-by-2 diagonal block.  If UPLO = 'L' and IPIV(k) =
00152 *>          IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were
00153 *>          interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
00154 *>
00155 *>          If FACT = 'N', then IPIV is an output argument and on exit
00156 *>          contains details of the interchanges and the block structure
00157 *>          of D, as determined by SSPTRF.
00158 *> \endverbatim
00159 *>
00160 *> \param[in] B
00161 *> \verbatim
00162 *>          B is REAL array, dimension (LDB,NRHS)
00163 *>          The N-by-NRHS right hand side matrix B.
00164 *> \endverbatim
00165 *>
00166 *> \param[in] LDB
00167 *> \verbatim
00168 *>          LDB is INTEGER
00169 *>          The leading dimension of the array B.  LDB >= max(1,N).
00170 *> \endverbatim
00171 *>
00172 *> \param[out] X
00173 *> \verbatim
00174 *>          X is REAL array, dimension (LDX,NRHS)
00175 *>          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
00176 *> \endverbatim
00177 *>
00178 *> \param[in] LDX
00179 *> \verbatim
00180 *>          LDX is INTEGER
00181 *>          The leading dimension of the array X.  LDX >= max(1,N).
00182 *> \endverbatim
00183 *>
00184 *> \param[out] RCOND
00185 *> \verbatim
00186 *>          RCOND is REAL
00187 *>          The estimate of the reciprocal condition number of the matrix
00188 *>          A.  If RCOND is less than the machine precision (in
00189 *>          particular, if RCOND = 0), the matrix is singular to working
00190 *>          precision.  This condition is indicated by a return code of
00191 *>          INFO > 0.
00192 *> \endverbatim
00193 *>
00194 *> \param[out] FERR
00195 *> \verbatim
00196 *>          FERR is REAL array, dimension (NRHS)
00197 *>          The estimated forward error bound for each solution vector
00198 *>          X(j) (the j-th column of the solution matrix X).
00199 *>          If XTRUE is the true solution corresponding to X(j), FERR(j)
00200 *>          is an estimated upper bound for the magnitude of the largest
00201 *>          element in (X(j) - XTRUE) divided by the magnitude of the
00202 *>          largest element in X(j).  The estimate is as reliable as
00203 *>          the estimate for RCOND, and is almost always a slight
00204 *>          overestimate of the true error.
00205 *> \endverbatim
00206 *>
00207 *> \param[out] BERR
00208 *> \verbatim
00209 *>          BERR is REAL array, dimension (NRHS)
00210 *>          The componentwise relative backward error of each solution
00211 *>          vector X(j) (i.e., the smallest relative change in
00212 *>          any element of A or B that makes X(j) an exact solution).
00213 *> \endverbatim
00214 *>
00215 *> \param[out] WORK
00216 *> \verbatim
00217 *>          WORK is REAL array, dimension (3*N)
00218 *> \endverbatim
00219 *>
00220 *> \param[out] IWORK
00221 *> \verbatim
00222 *>          IWORK is INTEGER array, dimension (N)
00223 *> \endverbatim
00224 *>
00225 *> \param[out] INFO
00226 *> \verbatim
00227 *>          INFO is INTEGER
00228 *>          = 0: successful exit
00229 *>          < 0: if INFO = -i, the i-th argument had an illegal value
00230 *>          > 0:  if INFO = i, and i is
00231 *>                <= N:  D(i,i) is exactly zero.  The factorization
00232 *>                       has been completed but the factor D is exactly
00233 *>                       singular, so the solution and error bounds could
00234 *>                       not be computed. RCOND = 0 is returned.
00235 *>                = N+1: D is nonsingular, but RCOND is less than machine
00236 *>                       precision, meaning that the matrix is singular
00237 *>                       to working precision.  Nevertheless, the
00238 *>                       solution and error bounds are computed because
00239 *>                       there are a number of situations where the
00240 *>                       computed solution can be more accurate than the
00241 *>                       value of RCOND would suggest.
00242 *> \endverbatim
00243 *
00244 *  Authors:
00245 *  ========
00246 *
00247 *> \author Univ. of Tennessee 
00248 *> \author Univ. of California Berkeley 
00249 *> \author Univ. of Colorado Denver 
00250 *> \author NAG Ltd. 
00251 *
00252 *> \date April 2012
00253 *
00254 *> \ingroup realOTHERsolve
00255 *
00256 *> \par Further Details:
00257 *  =====================
00258 *>
00259 *> \verbatim
00260 *>
00261 *>  The packed storage scheme is illustrated by the following example
00262 *>  when N = 4, UPLO = 'U':
00263 *>
00264 *>  Two-dimensional storage of the symmetric matrix A:
00265 *>
00266 *>     a11 a12 a13 a14
00267 *>         a22 a23 a24
00268 *>             a33 a34     (aij = aji)
00269 *>                 a44
00270 *>
00271 *>  Packed storage of the upper triangle of A:
00272 *>
00273 *>  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
00274 *> \endverbatim
00275 *>
00276 *  =====================================================================
00277       SUBROUTINE SSPSVX( FACT, UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X,
00278      $                   LDX, RCOND, FERR, BERR, WORK, IWORK, INFO )
00279 *
00280 *  -- LAPACK driver routine (version 3.4.1) --
00281 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00282 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00283 *     April 2012
00284 *
00285 *     .. Scalar Arguments ..
00286       CHARACTER          FACT, UPLO
00287       INTEGER            INFO, LDB, LDX, N, NRHS
00288       REAL               RCOND
00289 *     ..
00290 *     .. Array Arguments ..
00291       INTEGER            IPIV( * ), IWORK( * )
00292       REAL               AFP( * ), AP( * ), B( LDB, * ), BERR( * ),
00293      $                   FERR( * ), WORK( * ), X( LDX, * )
00294 *     ..
00295 *
00296 *  =====================================================================
00297 *
00298 *     .. Parameters ..
00299       REAL               ZERO
00300       PARAMETER          ( ZERO = 0.0E+0 )
00301 *     ..
00302 *     .. Local Scalars ..
00303       LOGICAL            NOFACT
00304       REAL               ANORM
00305 *     ..
00306 *     .. External Functions ..
00307       LOGICAL            LSAME
00308       REAL               SLAMCH, SLANSP
00309       EXTERNAL           LSAME, SLAMCH, SLANSP
00310 *     ..
00311 *     .. External Subroutines ..
00312       EXTERNAL           SCOPY, SLACPY, SSPCON, SSPRFS, SSPTRF, SSPTRS,
00313      $                   XERBLA
00314 *     ..
00315 *     .. Intrinsic Functions ..
00316       INTRINSIC          MAX
00317 *     ..
00318 *     .. Executable Statements ..
00319 *
00320 *     Test the input parameters.
00321 *
00322       INFO = 0
00323       NOFACT = LSAME( FACT, 'N' )
00324       IF( .NOT.NOFACT .AND. .NOT.LSAME( FACT, 'F' ) ) THEN
00325          INFO = -1
00326       ELSE IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) )
00327      $          THEN
00328          INFO = -2
00329       ELSE IF( N.LT.0 ) THEN
00330          INFO = -3
00331       ELSE IF( NRHS.LT.0 ) THEN
00332          INFO = -4
00333       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00334          INFO = -9
00335       ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
00336          INFO = -11
00337       END IF
00338       IF( INFO.NE.0 ) THEN
00339          CALL XERBLA( 'SSPSVX', -INFO )
00340          RETURN
00341       END IF
00342 *
00343       IF( NOFACT ) THEN
00344 *
00345 *        Compute the factorization A = U*D*U**T or A = L*D*L**T.
00346 *
00347          CALL SCOPY( N*( N+1 ) / 2, AP, 1, AFP, 1 )
00348          CALL SSPTRF( UPLO, N, AFP, IPIV, INFO )
00349 *
00350 *        Return if INFO is non-zero.
00351 *
00352          IF( INFO.GT.0 )THEN
00353             RCOND = ZERO
00354             RETURN
00355          END IF
00356       END IF
00357 *
00358 *     Compute the norm of the matrix A.
00359 *
00360       ANORM = SLANSP( 'I', UPLO, N, AP, WORK )
00361 *
00362 *     Compute the reciprocal of the condition number of A.
00363 *
00364       CALL SSPCON( UPLO, N, AFP, IPIV, ANORM, RCOND, WORK, IWORK, INFO )
00365 *
00366 *     Compute the solution vectors X.
00367 *
00368       CALL SLACPY( 'Full', N, NRHS, B, LDB, X, LDX )
00369       CALL SSPTRS( UPLO, N, NRHS, AFP, IPIV, X, LDX, INFO )
00370 *
00371 *     Use iterative refinement to improve the computed solutions and
00372 *     compute error bounds and backward error estimates for them.
00373 *
00374       CALL SSPRFS( UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, LDX, FERR,
00375      $             BERR, WORK, IWORK, INFO )
00376 *
00377 *     Set INFO = N+1 if the matrix is singular to working precision.
00378 *
00379       IF( RCOND.LT.SLAMCH( 'Epsilon' ) )
00380      $   INFO = N + 1
00381 *
00382       RETURN
00383 *
00384 *     End of SSPSVX
00385 *
00386       END
 All Files Functions