LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
chesv.f
Go to the documentation of this file.
00001 *> \brief <b> CHESV computes the solution to system of linear equations A * X = B for HE 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 CHESV + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chesv.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chesv.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chesv.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CHESV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
00022 *                         LWORK, INFO )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       CHARACTER          UPLO
00026 *       INTEGER            INFO, LDA, LDB, LWORK, N, NRHS
00027 *       ..
00028 *       .. Array Arguments ..
00029 *       INTEGER            IPIV( * )
00030 *       COMPLEX            A( LDA, * ), B( LDB, * ), WORK( * )
00031 *       ..
00032 *  
00033 *
00034 *> \par Purpose:
00035 *  =============
00036 *>
00037 *> \verbatim
00038 *>
00039 *> CHESV computes the solution to a complex system of linear equations
00040 *>    A * X = B,
00041 *> where A is an N-by-N Hermitian matrix and X and B are N-by-NRHS
00042 *> matrices.
00043 *>
00044 *> The diagonal pivoting method is used to factor A as
00045 *>    A = U * D * U**H,  if UPLO = 'U', or
00046 *>    A = L * D * L**H,  if UPLO = 'L',
00047 *> where U (or L) is a product of permutation and unit upper (lower)
00048 *> triangular matrices, and D is Hermitian and block diagonal with
00049 *> 1-by-1 and 2-by-2 diagonal blocks.  The factored form of A is then
00050 *> used to solve the system of equations A * X = B.
00051 *> \endverbatim
00052 *
00053 *  Arguments:
00054 *  ==========
00055 *
00056 *> \param[in] UPLO
00057 *> \verbatim
00058 *>          UPLO is CHARACTER*1
00059 *>          = 'U':  Upper triangle of A is stored;
00060 *>          = 'L':  Lower triangle of A is stored.
00061 *> \endverbatim
00062 *>
00063 *> \param[in] N
00064 *> \verbatim
00065 *>          N is INTEGER
00066 *>          The number of linear equations, i.e., the order of the
00067 *>          matrix A.  N >= 0.
00068 *> \endverbatim
00069 *>
00070 *> \param[in] NRHS
00071 *> \verbatim
00072 *>          NRHS is INTEGER
00073 *>          The number of right hand sides, i.e., the number of columns
00074 *>          of the matrix B.  NRHS >= 0.
00075 *> \endverbatim
00076 *>
00077 *> \param[in,out] A
00078 *> \verbatim
00079 *>          A is COMPLEX array, dimension (LDA,N)
00080 *>          On entry, the Hermitian matrix A.  If UPLO = 'U', the leading
00081 *>          N-by-N upper triangular part of A contains the upper
00082 *>          triangular part of the matrix A, and the strictly lower
00083 *>          triangular part of A is not referenced.  If UPLO = 'L', the
00084 *>          leading N-by-N lower triangular part of A contains the lower
00085 *>          triangular part of the matrix A, and the strictly upper
00086 *>          triangular part of A is not referenced.
00087 *>
00088 *>          On exit, if INFO = 0, the block diagonal matrix D and the
00089 *>          multipliers used to obtain the factor U or L from the
00090 *>          factorization A = U*D*U**H or A = L*D*L**H as computed by
00091 *>          CHETRF.
00092 *> \endverbatim
00093 *>
00094 *> \param[in] LDA
00095 *> \verbatim
00096 *>          LDA is INTEGER
00097 *>          The leading dimension of the array A.  LDA >= max(1,N).
00098 *> \endverbatim
00099 *>
00100 *> \param[out] IPIV
00101 *> \verbatim
00102 *>          IPIV is INTEGER array, dimension (N)
00103 *>          Details of the interchanges and the block structure of D, as
00104 *>          determined by CHETRF.  If IPIV(k) > 0, then rows and columns
00105 *>          k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1
00106 *>          diagonal block.  If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0,
00107 *>          then rows and columns k-1 and -IPIV(k) were interchanged and
00108 *>          D(k-1:k,k-1:k) is a 2-by-2 diagonal block.  If UPLO = 'L' and
00109 *>          IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and
00110 *>          -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
00111 *>          diagonal block.
00112 *> \endverbatim
00113 *>
00114 *> \param[in,out] B
00115 *> \verbatim
00116 *>          B is COMPLEX array, dimension (LDB,NRHS)
00117 *>          On entry, the N-by-NRHS right hand side matrix B.
00118 *>          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
00119 *> \endverbatim
00120 *>
00121 *> \param[in] LDB
00122 *> \verbatim
00123 *>          LDB is INTEGER
00124 *>          The leading dimension of the array B.  LDB >= max(1,N).
00125 *> \endverbatim
00126 *>
00127 *> \param[out] WORK
00128 *> \verbatim
00129 *>          WORK is COMPLEX array, dimension (MAX(1,LWORK))
00130 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00131 *> \endverbatim
00132 *>
00133 *> \param[in] LWORK
00134 *> \verbatim
00135 *>          LWORK is INTEGER
00136 *>          The length of WORK.  LWORK >= 1, and for best performance
00137 *>          LWORK >= max(1,N*NB), where NB is the optimal blocksize for
00138 *>          CHETRF.
00139 *>          for LWORK < N, TRS will be done with Level BLAS 2
00140 *>          for LWORK >= N, TRS will be done with Level BLAS 3
00141 *>
00142 *>          If LWORK = -1, then a workspace query is assumed; the routine
00143 *>          only calculates the optimal size of the WORK array, returns
00144 *>          this value as the first entry of the WORK array, and no error
00145 *>          message related to LWORK is issued by XERBLA.
00146 *> \endverbatim
00147 *>
00148 *> \param[out] INFO
00149 *> \verbatim
00150 *>          INFO is INTEGER
00151 *>          = 0: successful exit
00152 *>          < 0: if INFO = -i, the i-th argument had an illegal value
00153 *>          > 0: if INFO = i, D(i,i) is exactly zero.  The factorization
00154 *>               has been completed, but the block diagonal matrix D is
00155 *>               exactly singular, so the solution could not be computed.
00156 *> \endverbatim
00157 *
00158 *  Authors:
00159 *  ========
00160 *
00161 *> \author Univ. of Tennessee 
00162 *> \author Univ. of California Berkeley 
00163 *> \author Univ. of Colorado Denver 
00164 *> \author NAG Ltd. 
00165 *
00166 *> \date November 2011
00167 *
00168 *> \ingroup complexHEsolve
00169 *
00170 *  =====================================================================
00171       SUBROUTINE CHESV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
00172      $                  LWORK, INFO )
00173 *
00174 *  -- LAPACK driver routine (version 3.4.0) --
00175 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00176 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00177 *     November 2011
00178 *
00179 *     .. Scalar Arguments ..
00180       CHARACTER          UPLO
00181       INTEGER            INFO, LDA, LDB, LWORK, N, NRHS
00182 *     ..
00183 *     .. Array Arguments ..
00184       INTEGER            IPIV( * )
00185       COMPLEX            A( LDA, * ), B( LDB, * ), WORK( * )
00186 *     ..
00187 *
00188 *  =====================================================================
00189 *
00190 *     .. Local Scalars ..
00191       LOGICAL            LQUERY
00192       INTEGER            LWKOPT, NB
00193 *     ..
00194 *     .. External Functions ..
00195       LOGICAL            LSAME
00196       INTEGER            ILAENV
00197       EXTERNAL           LSAME, ILAENV
00198 *     ..
00199 *     .. External Subroutines ..
00200       EXTERNAL           XERBLA, CHETRF, CHETRS, CHETRS2
00201 *     ..
00202 *     .. Intrinsic Functions ..
00203       INTRINSIC          MAX
00204 *     ..
00205 *     .. Executable Statements ..
00206 *
00207 *     Test the input parameters.
00208 *
00209       INFO = 0
00210       LQUERY = ( LWORK.EQ.-1 )
00211       IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00212          INFO = -1
00213       ELSE IF( N.LT.0 ) THEN
00214          INFO = -2
00215       ELSE IF( NRHS.LT.0 ) THEN
00216          INFO = -3
00217       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00218          INFO = -5
00219       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00220          INFO = -8
00221       ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THEN
00222          INFO = -10
00223       END IF
00224 *
00225       IF( INFO.EQ.0 ) THEN
00226          IF( N.EQ.0 ) THEN
00227             LWKOPT = 1
00228          ELSE
00229             NB = ILAENV( 1, 'CHETRF', UPLO, N, -1, -1, -1 )
00230             LWKOPT = N*NB
00231          END IF
00232          WORK( 1 ) = LWKOPT
00233       END IF
00234 *
00235       IF( INFO.NE.0 ) THEN
00236          CALL XERBLA( 'CHESV ', -INFO )
00237          RETURN
00238       ELSE IF( LQUERY ) THEN
00239          RETURN
00240       END IF
00241 *
00242 *     Compute the factorization A = U*D*U**H or A = L*D*L**H.
00243 *
00244       CALL CHETRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
00245       IF( INFO.EQ.0 ) THEN
00246 *
00247 *        Solve the system A*X = B, overwriting B with X.
00248 *
00249          IF ( LWORK.LT.N ) THEN
00250 *
00251 *        Solve with TRS ( Use Level BLAS 2)
00252 *
00253             CALL CHETRS( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
00254 *
00255          ELSE
00256 *
00257 *        Solve with TRS2 ( Use Level BLAS 3)
00258 *
00259             CALL CHETRS2( UPLO,N,NRHS,A,LDA,IPIV,B,LDB,WORK,INFO )
00260 *
00261          END IF
00262 *
00263       END IF
00264 *
00265       WORK( 1 ) = LWKOPT
00266 *
00267       RETURN
00268 *
00269 *     End of CHESV
00270 *
00271       END
 All Files Functions