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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:07