00001 /* zhesv.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 static integer c_n1 = -1; 00020 00021 /* Subroutine */ int zhesv_(char *uplo, integer *n, integer *nrhs, 00022 doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, 00023 integer *ldb, doublecomplex *work, integer *lwork, integer *info) 00024 { 00025 /* System generated locals */ 00026 integer a_dim1, a_offset, b_dim1, b_offset, i__1; 00027 00028 /* Local variables */ 00029 integer nb; 00030 extern logical lsame_(char *, char *); 00031 extern /* Subroutine */ int xerbla_(char *, integer *); 00032 extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 00033 integer *, integer *); 00034 extern /* Subroutine */ int zhetrf_(char *, integer *, doublecomplex *, 00035 integer *, integer *, doublecomplex *, integer *, integer *), zhetrs_(char *, integer *, integer *, doublecomplex *, 00036 integer *, integer *, doublecomplex *, integer *, integer *); 00037 integer lwkopt; 00038 logical lquery; 00039 00040 00041 /* -- LAPACK driver routine (version 3.2) -- */ 00042 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00043 /* November 2006 */ 00044 00045 /* .. Scalar Arguments .. */ 00046 /* .. */ 00047 /* .. Array Arguments .. */ 00048 /* .. */ 00049 00050 /* Purpose */ 00051 /* ======= */ 00052 00053 /* ZHESV computes the solution to a complex system of linear equations */ 00054 /* A * X = B, */ 00055 /* where A is an N-by-N Hermitian matrix and X and B are N-by-NRHS */ 00056 /* matrices. */ 00057 00058 /* The diagonal pivoting method is used to factor A as */ 00059 /* A = U * D * U**H, if UPLO = 'U', or */ 00060 /* A = L * D * L**H, if UPLO = 'L', */ 00061 /* where U (or L) is a product of permutation and unit upper (lower) */ 00062 /* triangular matrices, and D is Hermitian and block diagonal with */ 00063 /* 1-by-1 and 2-by-2 diagonal blocks. The factored form of A is then */ 00064 /* used to solve the system of equations A * X = B. */ 00065 00066 /* Arguments */ 00067 /* ========= */ 00068 00069 /* UPLO (input) CHARACTER*1 */ 00070 /* = 'U': Upper triangle of A is stored; */ 00071 /* = 'L': Lower triangle of A is stored. */ 00072 00073 /* N (input) INTEGER */ 00074 /* The number of linear equations, i.e., the order of the */ 00075 /* matrix A. N >= 0. */ 00076 00077 /* NRHS (input) INTEGER */ 00078 /* The number of right hand sides, i.e., the number of columns */ 00079 /* of the matrix B. NRHS >= 0. */ 00080 00081 /* A (input/output) COMPLEX*16 array, dimension (LDA,N) */ 00082 /* On entry, the Hermitian matrix A. If UPLO = 'U', the leading */ 00083 /* N-by-N upper triangular part of A contains the upper */ 00084 /* triangular part of the matrix A, and the strictly lower */ 00085 /* triangular part of A is not referenced. If UPLO = 'L', the */ 00086 /* leading N-by-N lower triangular part of A contains the lower */ 00087 /* triangular part of the matrix A, and the strictly upper */ 00088 /* triangular part of A is not referenced. */ 00089 00090 /* On exit, if INFO = 0, the block diagonal matrix D and the */ 00091 /* multipliers used to obtain the factor U or L from the */ 00092 /* factorization A = U*D*U**H or A = L*D*L**H as computed by */ 00093 /* ZHETRF. */ 00094 00095 /* LDA (input) INTEGER */ 00096 /* The leading dimension of the array A. LDA >= max(1,N). */ 00097 00098 /* IPIV (output) INTEGER array, dimension (N) */ 00099 /* Details of the interchanges and the block structure of D, as */ 00100 /* determined by ZHETRF. If IPIV(k) > 0, then rows and columns */ 00101 /* k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1 */ 00102 /* diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, */ 00103 /* then rows and columns k-1 and -IPIV(k) were interchanged and */ 00104 /* D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and */ 00105 /* IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and */ 00106 /* -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2 */ 00107 /* diagonal block. */ 00108 00109 /* B (input/output) COMPLEX*16 array, dimension (LDB,NRHS) */ 00110 /* On entry, the N-by-NRHS right hand side matrix B. */ 00111 /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ 00112 00113 /* LDB (input) INTEGER */ 00114 /* The leading dimension of the array B. LDB >= max(1,N). */ 00115 00116 /* WORK (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) */ 00117 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ 00118 00119 /* LWORK (input) INTEGER */ 00120 /* The length of WORK. LWORK >= 1, and for best performance */ 00121 /* LWORK >= max(1,N*NB), where NB is the optimal blocksize for */ 00122 /* ZHETRF. */ 00123 00124 /* If LWORK = -1, then a workspace query is assumed; the routine */ 00125 /* only calculates the optimal size of the WORK array, returns */ 00126 /* this value as the first entry of the WORK array, and no error */ 00127 /* message related to LWORK is issued by XERBLA. */ 00128 00129 /* INFO (output) INTEGER */ 00130 /* = 0: successful exit */ 00131 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00132 /* > 0: if INFO = i, D(i,i) is exactly zero. The factorization */ 00133 /* has been completed, but the block diagonal matrix D is */ 00134 /* exactly singular, so the solution could not be computed. */ 00135 00136 /* ===================================================================== */ 00137 00138 /* .. Local Scalars .. */ 00139 /* .. */ 00140 /* .. External Functions .. */ 00141 /* .. */ 00142 /* .. External Subroutines .. */ 00143 /* .. */ 00144 /* .. Intrinsic Functions .. */ 00145 /* .. */ 00146 /* .. Executable Statements .. */ 00147 00148 /* Test the input parameters. */ 00149 00150 /* Parameter adjustments */ 00151 a_dim1 = *lda; 00152 a_offset = 1 + a_dim1; 00153 a -= a_offset; 00154 --ipiv; 00155 b_dim1 = *ldb; 00156 b_offset = 1 + b_dim1; 00157 b -= b_offset; 00158 --work; 00159 00160 /* Function Body */ 00161 *info = 0; 00162 lquery = *lwork == -1; 00163 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) { 00164 *info = -1; 00165 } else if (*n < 0) { 00166 *info = -2; 00167 } else if (*nrhs < 0) { 00168 *info = -3; 00169 } else if (*lda < max(1,*n)) { 00170 *info = -5; 00171 } else if (*ldb < max(1,*n)) { 00172 *info = -8; 00173 } else if (*lwork < 1 && ! lquery) { 00174 *info = -10; 00175 } 00176 00177 if (*info == 0) { 00178 if (*n == 0) { 00179 lwkopt = 1; 00180 } else { 00181 nb = ilaenv_(&c__1, "ZHETRF", uplo, n, &c_n1, &c_n1, &c_n1); 00182 lwkopt = *n * nb; 00183 } 00184 work[1].r = (doublereal) lwkopt, work[1].i = 0.; 00185 } 00186 00187 if (*info != 0) { 00188 i__1 = -(*info); 00189 xerbla_("ZHESV ", &i__1); 00190 return 0; 00191 } else if (lquery) { 00192 return 0; 00193 } 00194 00195 /* Compute the factorization A = U*D*U' or A = L*D*L'. */ 00196 00197 zhetrf_(uplo, n, &a[a_offset], lda, &ipiv[1], &work[1], lwork, info); 00198 if (*info == 0) { 00199 00200 /* Solve the system A*X = B, overwriting B with X. */ 00201 00202 zhetrs_(uplo, n, nrhs, &a[a_offset], lda, &ipiv[1], &b[b_offset], ldb, 00203 info); 00204 00205 } 00206 00207 work[1].r = (doublereal) lwkopt, work[1].i = 0.; 00208 00209 return 0; 00210 00211 /* End of ZHESV */ 00212 00213 } /* zhesv_ */