LAPACK 3.3.1
Linear Algebra PACKage

ssysv.f

Go to the documentation of this file.
00001       SUBROUTINE SSYSV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
00002      $                  LWORK, 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 * @generated s
00009 *
00010 *     .. Scalar Arguments ..
00011       CHARACTER          UPLO
00012       INTEGER            INFO, LDA, LDB, LWORK, N, NRHS
00013 *     ..
00014 *     .. Array Arguments ..
00015       INTEGER            IPIV( * )
00016       REAL               A( LDA, * ), B( LDB, * ), WORK( * )
00017 *     ..
00018 *
00019 *  Purpose
00020 *  =======
00021 *
00022 *  SSYSV computes the solution to a real system of linear equations
00023 *     A * X = B,
00024 *  where A is an N-by-N symmetric matrix and X and B are N-by-NRHS
00025 *  matrices.
00026 *
00027 *  The diagonal pivoting method is used to factor A as
00028 *     A = U * D * U**T,  if UPLO = 'U', or
00029 *     A = L * D * L**T,  if UPLO = 'L',
00030 *  where U (or L) is a product of permutation and unit upper (lower)
00031 *  triangular matrices, and D is symmetric and block diagonal with
00032 *  1-by-1 and 2-by-2 diagonal blocks.  The factored form of A is then
00033 *  used to solve the system of equations A * X = B.
00034 *
00035 *  Arguments
00036 *  =========
00037 *
00038 *  UPLO    (input) CHARACTER*1
00039 *          = 'U':  Upper triangle of A is stored;
00040 *          = 'L':  Lower triangle of A is stored.
00041 *
00042 *  N       (input) INTEGER
00043 *          The number of linear equations, i.e., the order of the
00044 *          matrix A.  N >= 0.
00045 *
00046 *  NRHS    (input) INTEGER
00047 *          The number of right hand sides, i.e., the number of columns
00048 *          of the matrix B.  NRHS >= 0.
00049 *
00050 *  A       (input/output) REAL array, dimension (LDA,N)
00051 *          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
00052 *          N-by-N upper triangular part of A contains the upper
00053 *          triangular part of the matrix A, and the strictly lower
00054 *          triangular part of A is not referenced.  If UPLO = 'L', the
00055 *          leading N-by-N lower triangular part of A contains the lower
00056 *          triangular part of the matrix A, and the strictly upper
00057 *          triangular part of A is not referenced.
00058 *
00059 *          On exit, if INFO = 0, the block diagonal matrix D and the
00060 *          multipliers used to obtain the factor U or L from the
00061 *          factorization A = U*D*U**T or A = L*D*L**T as computed by
00062 *          SSYTRF.
00063 *
00064 *  LDA     (input) INTEGER
00065 *          The leading dimension of the array A.  LDA >= max(1,N).
00066 *
00067 *  IPIV    (output) INTEGER array, dimension (N)
00068 *          Details of the interchanges and the block structure of D, as
00069 *          determined by SSYTRF.  If IPIV(k) > 0, then rows and columns
00070 *          k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1
00071 *          diagonal block.  If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0,
00072 *          then rows and columns k-1 and -IPIV(k) were interchanged and
00073 *          D(k-1:k,k-1:k) is a 2-by-2 diagonal block.  If UPLO = 'L' and
00074 *          IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and
00075 *          -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
00076 *          diagonal block.
00077 *
00078 *  B       (input/output) REAL array, dimension (LDB,NRHS)
00079 *          On entry, the N-by-NRHS right hand side matrix B.
00080 *          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
00081 *
00082 *  LDB     (input) INTEGER
00083 *          The leading dimension of the array B.  LDB >= max(1,N).
00084 *
00085 *  WORK    (workspace/output) REAL array, dimension (MAX(1,LWORK))
00086 *          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00087 *
00088 *  LWORK   (input) INTEGER
00089 *          The length of WORK.  LWORK >= 1, and for best performance
00090 *          LWORK >= max(1,N*NB), where NB is the optimal blocksize for
00091 *          SSYTRF.
00092 *          for LWORK < N, TRS will be done with Level BLAS 2
00093 *          for LWORK >= N, TRS will be done with Level BLAS 3
00094 *
00095 *          If LWORK = -1, then a workspace query is assumed; the routine
00096 *          only calculates the optimal size of the WORK array, returns
00097 *          this value as the first entry of the WORK array, and no error
00098 *          message related to LWORK is issued by XERBLA.
00099 *
00100 *  INFO    (output) INTEGER
00101 *          = 0: successful exit
00102 *          < 0: if INFO = -i, the i-th argument had an illegal value
00103 *          > 0: if INFO = i, D(i,i) is exactly zero.  The factorization
00104 *               has been completed, but the block diagonal matrix D is
00105 *               exactly singular, so the solution could not be computed.
00106 *
00107 *  =====================================================================
00108 *
00109 *     .. Local Scalars ..
00110       LOGICAL            LQUERY
00111       INTEGER            LWKOPT, NB
00112 *     ..
00113 *     .. External Functions ..
00114       LOGICAL            LSAME
00115       INTEGER            ILAENV
00116       EXTERNAL           LSAME, ILAENV
00117 *     ..
00118 *     .. External Subroutines ..
00119       EXTERNAL           XERBLA, SSYTRF, SSYTRS, SSYTRS2
00120 *     ..
00121 *     .. Intrinsic Functions ..
00122       INTRINSIC          MAX
00123 *     ..
00124 *     .. Executable Statements ..
00125 *
00126 *     Test the input parameters.
00127 *
00128       INFO = 0
00129       LQUERY = ( LWORK.EQ.-1 )
00130       IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00131          INFO = -1
00132       ELSE IF( N.LT.0 ) THEN
00133          INFO = -2
00134       ELSE IF( NRHS.LT.0 ) THEN
00135          INFO = -3
00136       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00137          INFO = -5
00138       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00139          INFO = -8
00140       ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THEN
00141          INFO = -10
00142       END IF
00143 *
00144       IF( INFO.EQ.0 ) THEN
00145          IF( N.EQ.0 ) THEN
00146             LWKOPT = 1
00147          ELSE
00148             CALL SSYTRF( UPLO, N, A, LDA, IPIV, WORK, -1, INFO )            
00149             LWKOPT = WORK(1)
00150          END IF
00151          WORK( 1 ) = LWKOPT
00152       END IF
00153 *
00154       IF( INFO.NE.0 ) THEN
00155          CALL XERBLA( 'SSYSV ', -INFO )
00156          RETURN
00157       ELSE IF( LQUERY ) THEN
00158          RETURN
00159       END IF
00160 *
00161 *     Compute the factorization A = U*D*U**T or A = L*D*L**T.
00162 *
00163       CALL SSYTRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
00164       IF( INFO.EQ.0 ) THEN
00165 *
00166 *        Solve the system A*X = B, overwriting B with X.
00167 *
00168          IF ( LWORK.LT.N ) THEN
00169 *
00170 *        Solve with TRS ( Use Level BLAS 2)
00171 *
00172             CALL SSYTRS( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
00173 *
00174          ELSE
00175 *
00176 *        Solve with TRS2 ( Use Level BLAS 3)
00177 *
00178             CALL SSYTRS2( UPLO,N,NRHS,A,LDA,IPIV,B,LDB,WORK,INFO )
00179 *
00180          END IF
00181 *
00182       END IF
00183 *
00184       WORK( 1 ) = LWKOPT
00185 *
00186       RETURN
00187 *
00188 *     End of SSYSV
00189 *
00190       END
 All Files Functions