LAPACK 3.3.1
Linear Algebra PACKage

dspsv.f

Go to the documentation of this file.
00001       SUBROUTINE DSPSV( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO )
00002 *
00003 *  -- LAPACK driver routine (version 3.3.1) --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *  -- April 2011                                                      --
00007 *
00008 *     .. Scalar Arguments ..
00009       CHARACTER          UPLO
00010       INTEGER            INFO, LDB, N, NRHS
00011 *     ..
00012 *     .. Array Arguments ..
00013       INTEGER            IPIV( * )
00014       DOUBLE PRECISION   AP( * ), B( LDB, * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  DSPSV computes the solution to a real system of linear equations
00021 *     A * X = B,
00022 *  where A is an N-by-N symmetric matrix stored in packed format and X
00023 *  and B are N-by-NRHS matrices.
00024 *
00025 *  The diagonal pivoting method is used to factor A as
00026 *     A = U * D * U**T,  if UPLO = 'U', or
00027 *     A = L * D * L**T,  if UPLO = 'L',
00028 *  where U (or L) is a product of permutation and unit upper (lower)
00029 *  triangular matrices, D is symmetric and block diagonal with 1-by-1
00030 *  and 2-by-2 diagonal blocks.  The factored form of A is then used to
00031 *  solve the system of equations A * X = B.
00032 *
00033 *  Arguments
00034 *  =========
00035 *
00036 *  UPLO    (input) CHARACTER*1
00037 *          = 'U':  Upper triangle of A is stored;
00038 *          = 'L':  Lower triangle of A is stored.
00039 *
00040 *  N       (input) INTEGER
00041 *          The number of linear equations, i.e., the order of the
00042 *          matrix A.  N >= 0.
00043 *
00044 *  NRHS    (input) INTEGER
00045 *          The number of right hand sides, i.e., the number of columns
00046 *          of the matrix B.  NRHS >= 0.
00047 *
00048 *  AP      (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
00049 *          On entry, the upper or lower triangle of the symmetric matrix
00050 *          A, packed columnwise in a linear array.  The j-th column of A
00051 *          is stored in the array AP as follows:
00052 *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00053 *          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
00054 *          See below for further details.
00055 *
00056 *          On exit, the block diagonal matrix D and the multipliers used
00057 *          to obtain the factor U or L from the factorization
00058 *          A = U*D*U**T or A = L*D*L**T as computed by DSPTRF, stored as
00059 *          a packed triangular matrix in the same storage format as A.
00060 *
00061 *  IPIV    (output) INTEGER array, dimension (N)
00062 *          Details of the interchanges and the block structure of D, as
00063 *          determined by DSPTRF.  If IPIV(k) > 0, then rows and columns
00064 *          k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1
00065 *          diagonal block.  If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0,
00066 *          then rows and columns k-1 and -IPIV(k) were interchanged and
00067 *          D(k-1:k,k-1:k) is a 2-by-2 diagonal block.  If UPLO = 'L' and
00068 *          IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and
00069 *          -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
00070 *          diagonal block.
00071 *
00072 *  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
00073 *          On entry, the N-by-NRHS right hand side matrix B.
00074 *          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
00075 *
00076 *  LDB     (input) INTEGER
00077 *          The leading dimension of the array B.  LDB >= max(1,N).
00078 *
00079 *  INFO    (output) INTEGER
00080 *          = 0:  successful exit
00081 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00082 *          > 0:  if INFO = i, D(i,i) is exactly zero.  The factorization
00083 *                has been completed, but the block diagonal matrix D is
00084 *                exactly singular, so the solution could not be
00085 *                computed.
00086 *
00087 *  Further Details
00088 *  ===============
00089 *
00090 *  The packed storage scheme is illustrated by the following example
00091 *  when N = 4, UPLO = 'U':
00092 *
00093 *  Two-dimensional storage of the symmetric matrix A:
00094 *
00095 *     a11 a12 a13 a14
00096 *         a22 a23 a24
00097 *             a33 a34     (aij = aji)
00098 *                 a44
00099 *
00100 *  Packed storage of the upper triangle of A:
00101 *
00102 *  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
00103 *
00104 *  =====================================================================
00105 *
00106 *     .. External Functions ..
00107       LOGICAL            LSAME
00108       EXTERNAL           LSAME
00109 *     ..
00110 *     .. External Subroutines ..
00111       EXTERNAL           DSPTRF, DSPTRS, XERBLA
00112 *     ..
00113 *     .. Intrinsic Functions ..
00114       INTRINSIC          MAX
00115 *     ..
00116 *     .. Executable Statements ..
00117 *
00118 *     Test the input parameters.
00119 *
00120       INFO = 0
00121       IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00122          INFO = -1
00123       ELSE IF( N.LT.0 ) THEN
00124          INFO = -2
00125       ELSE IF( NRHS.LT.0 ) THEN
00126          INFO = -3
00127       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00128          INFO = -7
00129       END IF
00130       IF( INFO.NE.0 ) THEN
00131          CALL XERBLA( 'DSPSV ', -INFO )
00132          RETURN
00133       END IF
00134 *
00135 *     Compute the factorization A = U*D*U**T or A = L*D*L**T.
00136 *
00137       CALL DSPTRF( UPLO, N, AP, IPIV, INFO )
00138       IF( INFO.EQ.0 ) THEN
00139 *
00140 *        Solve the system A*X = B, overwriting B with X.
00141 *
00142          CALL DSPTRS( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO )
00143 *
00144       END IF
00145       RETURN
00146 *
00147 *     End of DSPSV
00148 *
00149       END
 All Files Functions