00001 /* dsysv.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 dsysv_(char *uplo, integer *n, integer *nrhs, doublereal 00022 *a, integer *lda, integer *ipiv, doublereal *b, integer *ldb, 00023 doublereal *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 dsytrf_(char *, integer *, doublereal *, 00035 integer *, integer *, doublereal *, integer *, integer *); 00036 integer lwkopt; 00037 logical lquery; 00038 extern /* Subroutine */ int dsytrs_(char *, integer *, integer *, 00039 doublereal *, integer *, integer *, doublereal *, integer *, 00040 integer *); 00041 00042 00043 /* -- LAPACK driver routine (version 3.2) -- */ 00044 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00045 /* November 2006 */ 00046 00047 /* .. Scalar Arguments .. */ 00048 /* .. */ 00049 /* .. Array Arguments .. */ 00050 /* .. */ 00051 00052 /* Purpose */ 00053 /* ======= */ 00054 00055 /* DSYSV computes the solution to a real system of linear equations */ 00056 /* A * X = B, */ 00057 /* where A is an N-by-N symmetric matrix and X and B are N-by-NRHS */ 00058 /* matrices. */ 00059 00060 /* The diagonal pivoting method is used to factor A as */ 00061 /* A = U * D * U**T, if UPLO = 'U', or */ 00062 /* A = L * D * L**T, if UPLO = 'L', */ 00063 /* where U (or L) is a product of permutation and unit upper (lower) */ 00064 /* triangular matrices, and D is symmetric and block diagonal with */ 00065 /* 1-by-1 and 2-by-2 diagonal blocks. The factored form of A is then */ 00066 /* used to solve the system of equations A * X = B. */ 00067 00068 /* Arguments */ 00069 /* ========= */ 00070 00071 /* UPLO (input) CHARACTER*1 */ 00072 /* = 'U': Upper triangle of A is stored; */ 00073 /* = 'L': Lower triangle of A is stored. */ 00074 00075 /* N (input) INTEGER */ 00076 /* The number of linear equations, i.e., the order of the */ 00077 /* matrix A. N >= 0. */ 00078 00079 /* NRHS (input) INTEGER */ 00080 /* The number of right hand sides, i.e., the number of columns */ 00081 /* of the matrix B. NRHS >= 0. */ 00082 00083 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ 00084 /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */ 00085 /* N-by-N upper triangular part of A contains the upper */ 00086 /* triangular part of the matrix A, and the strictly lower */ 00087 /* triangular part of A is not referenced. If UPLO = 'L', the */ 00088 /* leading N-by-N lower triangular part of A contains the lower */ 00089 /* triangular part of the matrix A, and the strictly upper */ 00090 /* triangular part of A is not referenced. */ 00091 00092 /* On exit, if INFO = 0, the block diagonal matrix D and the */ 00093 /* multipliers used to obtain the factor U or L from the */ 00094 /* factorization A = U*D*U**T or A = L*D*L**T as computed by */ 00095 /* DSYTRF. */ 00096 00097 /* LDA (input) INTEGER */ 00098 /* The leading dimension of the array A. LDA >= max(1,N). */ 00099 00100 /* IPIV (output) INTEGER array, dimension (N) */ 00101 /* Details of the interchanges and the block structure of D, as */ 00102 /* determined by DSYTRF. If IPIV(k) > 0, then rows and columns */ 00103 /* k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1 */ 00104 /* diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, */ 00105 /* then rows and columns k-1 and -IPIV(k) were interchanged and */ 00106 /* D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and */ 00107 /* IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and */ 00108 /* -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2 */ 00109 /* diagonal block. */ 00110 00111 /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ 00112 /* On entry, the N-by-NRHS right hand side matrix B. */ 00113 /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ 00114 00115 /* LDB (input) INTEGER */ 00116 /* The leading dimension of the array B. LDB >= max(1,N). */ 00117 00118 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ 00119 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ 00120 00121 /* LWORK (input) INTEGER */ 00122 /* The length of WORK. LWORK >= 1, and for best performance */ 00123 /* LWORK >= max(1,N*NB), where NB is the optimal blocksize for */ 00124 /* DSYTRF. */ 00125 00126 /* If LWORK = -1, then a workspace query is assumed; the routine */ 00127 /* only calculates the optimal size of the WORK array, returns */ 00128 /* this value as the first entry of the WORK array, and no error */ 00129 /* message related to LWORK is issued by XERBLA. */ 00130 00131 /* INFO (output) INTEGER */ 00132 /* = 0: successful exit */ 00133 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00134 /* > 0: if INFO = i, D(i,i) is exactly zero. The factorization */ 00135 /* has been completed, but the block diagonal matrix D is */ 00136 /* exactly singular, so the solution could not be computed. */ 00137 00138 /* ===================================================================== */ 00139 00140 /* .. Local Scalars .. */ 00141 /* .. */ 00142 /* .. External Functions .. */ 00143 /* .. */ 00144 /* .. External Subroutines .. */ 00145 /* .. */ 00146 /* .. Intrinsic Functions .. */ 00147 /* .. */ 00148 /* .. Executable Statements .. */ 00149 00150 /* Test the input parameters. */ 00151 00152 /* Parameter adjustments */ 00153 a_dim1 = *lda; 00154 a_offset = 1 + a_dim1; 00155 a -= a_offset; 00156 --ipiv; 00157 b_dim1 = *ldb; 00158 b_offset = 1 + b_dim1; 00159 b -= b_offset; 00160 --work; 00161 00162 /* Function Body */ 00163 *info = 0; 00164 lquery = *lwork == -1; 00165 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) { 00166 *info = -1; 00167 } else if (*n < 0) { 00168 *info = -2; 00169 } else if (*nrhs < 0) { 00170 *info = -3; 00171 } else if (*lda < max(1,*n)) { 00172 *info = -5; 00173 } else if (*ldb < max(1,*n)) { 00174 *info = -8; 00175 } else if (*lwork < 1 && ! lquery) { 00176 *info = -10; 00177 } 00178 00179 if (*info == 0) { 00180 if (*n == 0) { 00181 lwkopt = 1; 00182 } else { 00183 nb = ilaenv_(&c__1, "DSYTRF", uplo, n, &c_n1, &c_n1, &c_n1); 00184 lwkopt = *n * nb; 00185 } 00186 work[1] = (doublereal) lwkopt; 00187 } 00188 00189 if (*info != 0) { 00190 i__1 = -(*info); 00191 xerbla_("DSYSV ", &i__1); 00192 return 0; 00193 } else if (lquery) { 00194 return 0; 00195 } 00196 00197 /* Compute the factorization A = U*D*U' or A = L*D*L'. */ 00198 00199 dsytrf_(uplo, n, &a[a_offset], lda, &ipiv[1], &work[1], lwork, info); 00200 if (*info == 0) { 00201 00202 /* Solve the system A*X = B, overwriting B with X. */ 00203 00204 dsytrs_(uplo, n, nrhs, &a[a_offset], lda, &ipiv[1], &b[b_offset], ldb, 00205 info); 00206 00207 } 00208 00209 work[1] = (doublereal) lwkopt; 00210 00211 return 0; 00212 00213 /* End of DSYSV */ 00214 00215 } /* dsysv_ */