00001 /* dgesv.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 /* Subroutine */ int dgesv_(integer *n, integer *nrhs, doublereal *a, integer 00017 *lda, integer *ipiv, doublereal *b, integer *ldb, integer *info) 00018 { 00019 /* System generated locals */ 00020 integer a_dim1, a_offset, b_dim1, b_offset, i__1; 00021 00022 /* Local variables */ 00023 extern /* Subroutine */ int dgetrf_(integer *, integer *, doublereal *, 00024 integer *, integer *, integer *), xerbla_(char *, integer *), dgetrs_(char *, integer *, integer *, doublereal *, 00025 integer *, integer *, doublereal *, integer *, integer *); 00026 00027 00028 /* -- LAPACK driver routine (version 3.2) -- */ 00029 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00030 /* November 2006 */ 00031 00032 /* .. Scalar Arguments .. */ 00033 /* .. */ 00034 /* .. Array Arguments .. */ 00035 /* .. */ 00036 00037 /* Purpose */ 00038 /* ======= */ 00039 00040 /* DGESV computes the solution to a real system of linear equations */ 00041 /* A * X = B, */ 00042 /* where A is an N-by-N matrix and X and B are N-by-NRHS matrices. */ 00043 00044 /* The LU decomposition with partial pivoting and row interchanges is */ 00045 /* used to factor A as */ 00046 /* A = P * L * U, */ 00047 /* where P is a permutation matrix, L is unit lower triangular, and U is */ 00048 /* upper triangular. The factored form of A is then used to solve the */ 00049 /* system of equations A * X = B. */ 00050 00051 /* Arguments */ 00052 /* ========= */ 00053 00054 /* N (input) INTEGER */ 00055 /* The number of linear equations, i.e., the order of the */ 00056 /* matrix A. N >= 0. */ 00057 00058 /* NRHS (input) INTEGER */ 00059 /* The number of right hand sides, i.e., the number of columns */ 00060 /* of the matrix B. NRHS >= 0. */ 00061 00062 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ 00063 /* On entry, the N-by-N coefficient matrix A. */ 00064 /* On exit, the factors L and U from the factorization */ 00065 /* A = P*L*U; the unit diagonal elements of L are not stored. */ 00066 00067 /* LDA (input) INTEGER */ 00068 /* The leading dimension of the array A. LDA >= max(1,N). */ 00069 00070 /* IPIV (output) INTEGER array, dimension (N) */ 00071 /* The pivot indices that define the permutation matrix P; */ 00072 /* row i of the matrix was interchanged with row IPIV(i). */ 00073 00074 /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ 00075 /* On entry, the N-by-NRHS matrix of right hand side matrix B. */ 00076 /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ 00077 00078 /* LDB (input) INTEGER */ 00079 /* The leading dimension of the array B. LDB >= max(1,N). */ 00080 00081 /* INFO (output) INTEGER */ 00082 /* = 0: successful exit */ 00083 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00084 /* > 0: if INFO = i, U(i,i) is exactly zero. The factorization */ 00085 /* has been completed, but the factor U is exactly */ 00086 /* singular, so the solution could not be computed. */ 00087 00088 /* ===================================================================== */ 00089 00090 /* .. External Subroutines .. */ 00091 /* .. */ 00092 /* .. Intrinsic Functions .. */ 00093 /* .. */ 00094 /* .. Executable Statements .. */ 00095 00096 /* Test the input parameters. */ 00097 00098 /* Parameter adjustments */ 00099 a_dim1 = *lda; 00100 a_offset = 1 + a_dim1; 00101 a -= a_offset; 00102 --ipiv; 00103 b_dim1 = *ldb; 00104 b_offset = 1 + b_dim1; 00105 b -= b_offset; 00106 00107 /* Function Body */ 00108 *info = 0; 00109 if (*n < 0) { 00110 *info = -1; 00111 } else if (*nrhs < 0) { 00112 *info = -2; 00113 } else if (*lda < max(1,*n)) { 00114 *info = -4; 00115 } else if (*ldb < max(1,*n)) { 00116 *info = -7; 00117 } 00118 if (*info != 0) { 00119 i__1 = -(*info); 00120 xerbla_("DGESV ", &i__1); 00121 return 0; 00122 } 00123 00124 /* Compute the LU factorization of A. */ 00125 00126 dgetrf_(n, n, &a[a_offset], lda, &ipiv[1], info); 00127 if (*info == 0) { 00128 00129 /* Solve the system A*X = B, overwriting B with X. */ 00130 00131 dgetrs_("No transpose", n, nrhs, &a[a_offset], lda, &ipiv[1], &b[ 00132 b_offset], ldb, info); 00133 } 00134 return 0; 00135 00136 /* End of DGESV */ 00137 00138 } /* dgesv_ */