LAPACK 3.3.1
Linear Algebra PACKage

sspsvx.f

Go to the documentation of this file.
00001       SUBROUTINE SSPSVX( FACT, UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X,
00002      $                   LDX, RCOND, FERR, BERR, WORK, IWORK, INFO )
00003 *
00004 *  -- LAPACK driver routine (version 3.3.1) --
00005 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00006 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00007 *  -- April 2011                                                      --
00008 *
00009 *     .. Scalar Arguments ..
00010       CHARACTER          FACT, UPLO
00011       INTEGER            INFO, LDB, LDX, N, NRHS
00012       REAL               RCOND
00013 *     ..
00014 *     .. Array Arguments ..
00015       INTEGER            IPIV( * ), IWORK( * )
00016       REAL               AFP( * ), AP( * ), B( LDB, * ), BERR( * ),
00017      $                   FERR( * ), WORK( * ), X( LDX, * )
00018 *     ..
00019 *
00020 *  Purpose
00021 *  =======
00022 *
00023 *  SSPSVX uses the diagonal pivoting factorization A = U*D*U**T or
00024 *  A = L*D*L**T to compute the solution to a real system of linear
00025 *  equations A * X = B, where A is an N-by-N symmetric matrix stored
00026 *  in packed format and X and B are N-by-NRHS matrices.
00027 *
00028 *  Error bounds on the solution and a condition estimate are also
00029 *  provided.
00030 *
00031 *  Description
00032 *  ===========
00033 *
00034 *  The following steps are performed:
00035 *
00036 *  1. If FACT = 'N', the diagonal pivoting method is used to factor A as
00037 *        A = U * D * U**T,  if UPLO = 'U', or
00038 *        A = L * D * L**T,  if UPLO = 'L',
00039 *     where U (or L) is a product of permutation and unit upper (lower)
00040 *     triangular matrices and D is symmetric and block diagonal with
00041 *     1-by-1 and 2-by-2 diagonal blocks.
00042 *
00043 *  2. If some D(i,i)=0, so that D is exactly singular, then the routine
00044 *     returns with INFO = i. Otherwise, the factored form of A is used
00045 *     to estimate the condition number of the matrix A.  If the
00046 *     reciprocal of the condition number is less than machine precision,
00047 *     INFO = N+1 is returned as a warning, but the routine still goes on
00048 *     to solve for X and compute error bounds as described below.
00049 *
00050 *  3. The system of equations is solved for X using the factored form
00051 *     of A.
00052 *
00053 *  4. Iterative refinement is applied to improve the computed solution
00054 *     matrix and calculate error bounds and backward error estimates
00055 *     for it.
00056 *
00057 *  Arguments
00058 *  =========
00059 *
00060 *  FACT    (input) CHARACTER*1
00061 *          Specifies whether or not the factored form of A has been
00062 *          supplied on entry.
00063 *          = 'F':  On entry, AFP and IPIV contain the factored form of
00064 *                  A.  AP, AFP and IPIV will not be modified.
00065 *          = 'N':  The matrix A will be copied to AFP and factored.
00066 *
00067 *  UPLO    (input) CHARACTER*1
00068 *          = 'U':  Upper triangle of A is stored;
00069 *          = 'L':  Lower triangle of A is stored.
00070 *
00071 *  N       (input) INTEGER
00072 *          The number of linear equations, i.e., the order of the
00073 *          matrix A.  N >= 0.
00074 *
00075 *  NRHS    (input) INTEGER
00076 *          The number of right hand sides, i.e., the number of columns
00077 *          of the matrices B and X.  NRHS >= 0.
00078 *
00079 *  AP      (input) REAL array, dimension (N*(N+1)/2)
00080 *          The upper or lower triangle of the symmetric matrix A, packed
00081 *          columnwise in a linear array.  The j-th column of A is stored
00082 *          in the array AP as follows:
00083 *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00084 *          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
00085 *          See below for further details.
00086 *
00087 *  AFP     (input or output) REAL array, dimension
00088 *                            (N*(N+1)/2)
00089 *          If FACT = 'F', then AFP is an input argument and on entry
00090 *          contains the block diagonal matrix D and the multipliers used
00091 *          to obtain the factor U or L from the factorization
00092 *          A = U*D*U**T or A = L*D*L**T as computed by SSPTRF, stored as
00093 *          a packed triangular matrix in the same storage format as A.
00094 *
00095 *          If FACT = 'N', then AFP is an output argument and on exit
00096 *          contains the block diagonal matrix D and the multipliers used
00097 *          to obtain the factor U or L from the factorization
00098 *          A = U*D*U**T or A = L*D*L**T as computed by SSPTRF, stored as
00099 *          a packed triangular matrix in the same storage format as A.
00100 *
00101 *  IPIV    (input or output) INTEGER array, dimension (N)
00102 *          If FACT = 'F', then IPIV is an input argument and on entry
00103 *          contains details of the interchanges and the block structure
00104 *          of D, as determined by SSPTRF.
00105 *          If IPIV(k) > 0, then rows and columns k and IPIV(k) were
00106 *          interchanged and D(k,k) is a 1-by-1 diagonal block.
00107 *          If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and
00108 *          columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
00109 *          is a 2-by-2 diagonal block.  If UPLO = 'L' and IPIV(k) =
00110 *          IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were
00111 *          interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
00112 *
00113 *          If FACT = 'N', then IPIV is an output argument and on exit
00114 *          contains details of the interchanges and the block structure
00115 *          of D, as determined by SSPTRF.
00116 *
00117 *  B       (input) REAL array, dimension (LDB,NRHS)
00118 *          The N-by-NRHS right hand side matrix B.
00119 *
00120 *  LDB     (input) INTEGER
00121 *          The leading dimension of the array B.  LDB >= max(1,N).
00122 *
00123 *  X       (output) REAL array, dimension (LDX,NRHS)
00124 *          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
00125 *
00126 *  LDX     (input) INTEGER
00127 *          The leading dimension of the array X.  LDX >= max(1,N).
00128 *
00129 *  RCOND   (output) REAL
00130 *          The estimate of the reciprocal condition number of the matrix
00131 *          A.  If RCOND is less than the machine precision (in
00132 *          particular, if RCOND = 0), the matrix is singular to working
00133 *          precision.  This condition is indicated by a return code of
00134 *          INFO > 0.
00135 *
00136 *  FERR    (output) REAL array, dimension (NRHS)
00137 *          The estimated forward error bound for each solution vector
00138 *          X(j) (the j-th column of the solution matrix X).
00139 *          If XTRUE is the true solution corresponding to X(j), FERR(j)
00140 *          is an estimated upper bound for the magnitude of the largest
00141 *          element in (X(j) - XTRUE) divided by the magnitude of the
00142 *          largest element in X(j).  The estimate is as reliable as
00143 *          the estimate for RCOND, and is almost always a slight
00144 *          overestimate of the true error.
00145 *
00146 *  BERR    (output) REAL array, dimension (NRHS)
00147 *          The componentwise relative backward error of each solution
00148 *          vector X(j) (i.e., the smallest relative change in
00149 *          any element of A or B that makes X(j) an exact solution).
00150 *
00151 *  WORK    (workspace) REAL array, dimension (3*N)
00152 *
00153 *  IWORK   (workspace) INTEGER array, dimension (N)
00154 *
00155 *  INFO    (output) INTEGER
00156 *          = 0: successful exit
00157 *          < 0: if INFO = -i, the i-th argument had an illegal value
00158 *          > 0:  if INFO = i, and i is
00159 *                <= N:  D(i,i) is exactly zero.  The factorization
00160 *                       has been completed but the factor D is exactly
00161 *                       singular, so the solution and error bounds could
00162 *                       not be computed. RCOND = 0 is returned.
00163 *                = N+1: D is nonsingular, but RCOND is less than machine
00164 *                       precision, meaning that the matrix is singular
00165 *                       to working precision.  Nevertheless, the
00166 *                       solution and error bounds are computed because
00167 *                       there are a number of situations where the
00168 *                       computed solution can be more accurate than the
00169 *                       value of RCOND would suggest.
00170 *
00171 *  Further Details
00172 *  ===============
00173 *
00174 *  The packed storage scheme is illustrated by the following example
00175 *  when N = 4, UPLO = 'U':
00176 *
00177 *  Two-dimensional storage of the symmetric matrix A:
00178 *
00179 *     a11 a12 a13 a14
00180 *         a22 a23 a24
00181 *             a33 a34     (aij = aji)
00182 *                 a44
00183 *
00184 *  Packed storage of the upper triangle of A:
00185 *
00186 *  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
00187 *
00188 *  =====================================================================
00189 *
00190 *     .. Parameters ..
00191       REAL               ZERO
00192       PARAMETER          ( ZERO = 0.0E+0 )
00193 *     ..
00194 *     .. Local Scalars ..
00195       LOGICAL            NOFACT
00196       REAL               ANORM
00197 *     ..
00198 *     .. External Functions ..
00199       LOGICAL            LSAME
00200       REAL               SLAMCH, SLANSP
00201       EXTERNAL           LSAME, SLAMCH, SLANSP
00202 *     ..
00203 *     .. External Subroutines ..
00204       EXTERNAL           SCOPY, SLACPY, SSPCON, SSPRFS, SSPTRF, SSPTRS,
00205      $                   XERBLA
00206 *     ..
00207 *     .. Intrinsic Functions ..
00208       INTRINSIC          MAX
00209 *     ..
00210 *     .. Executable Statements ..
00211 *
00212 *     Test the input parameters.
00213 *
00214       INFO = 0
00215       NOFACT = LSAME( FACT, 'N' )
00216       IF( .NOT.NOFACT .AND. .NOT.LSAME( FACT, 'F' ) ) THEN
00217          INFO = -1
00218       ELSE IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) )
00219      $          THEN
00220          INFO = -2
00221       ELSE IF( N.LT.0 ) THEN
00222          INFO = -3
00223       ELSE IF( NRHS.LT.0 ) THEN
00224          INFO = -4
00225       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00226          INFO = -9
00227       ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
00228          INFO = -11
00229       END IF
00230       IF( INFO.NE.0 ) THEN
00231          CALL XERBLA( 'SSPSVX', -INFO )
00232          RETURN
00233       END IF
00234 *
00235       IF( NOFACT ) THEN
00236 *
00237 *        Compute the factorization A = U*D*U**T or A = L*D*L**T.
00238 *
00239          CALL SCOPY( N*( N+1 ) / 2, AP, 1, AFP, 1 )
00240          CALL SSPTRF( UPLO, N, AFP, IPIV, INFO )
00241 *
00242 *        Return if INFO is non-zero.
00243 *
00244          IF( INFO.GT.0 )THEN
00245             RCOND = ZERO
00246             RETURN
00247          END IF
00248       END IF
00249 *
00250 *     Compute the norm of the matrix A.
00251 *
00252       ANORM = SLANSP( 'I', UPLO, N, AP, WORK )
00253 *
00254 *     Compute the reciprocal of the condition number of A.
00255 *
00256       CALL SSPCON( UPLO, N, AFP, IPIV, ANORM, RCOND, WORK, IWORK, INFO )
00257 *
00258 *     Compute the solution vectors X.
00259 *
00260       CALL SLACPY( 'Full', N, NRHS, B, LDB, X, LDX )
00261       CALL SSPTRS( UPLO, N, NRHS, AFP, IPIV, X, LDX, INFO )
00262 *
00263 *     Use iterative refinement to improve the computed solutions and
00264 *     compute error bounds and backward error estimates for them.
00265 *
00266       CALL SSPRFS( UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, LDX, FERR,
00267      $             BERR, WORK, IWORK, INFO )
00268 *
00269 *     Set INFO = N+1 if the matrix is singular to working precision.
00270 *
00271       IF( RCOND.LT.SLAMCH( 'Epsilon' ) )
00272      $   INFO = N + 1
00273 *
00274       RETURN
00275 *
00276 *     End of SSPSVX
00277 *
00278       END
 All Files Functions