sgetrs.c
Go to the documentation of this file.
00001 /* sgetrs.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 real c_b12 = 1.f;
00020 static integer c_n1 = -1;
00021 
00022 /* Subroutine */ int sgetrs_(char *trans, integer *n, integer *nrhs, real *a, 
00023         integer *lda, integer *ipiv, real *b, integer *ldb, integer *info)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, b_dim1, b_offset, i__1;
00027 
00028     /* Local variables */
00029     extern logical lsame_(char *, char *);
00030     extern /* Subroutine */ int strsm_(char *, char *, char *, char *, 
00031             integer *, integer *, real *, real *, integer *, real *, integer *
00032 ), xerbla_(char *, integer *);
00033     logical notran;
00034     extern /* Subroutine */ int slaswp_(integer *, real *, integer *, integer 
00035             *, integer *, integer *, integer *);
00036 
00037 
00038 /*  -- LAPACK routine (version 3.2) -- */
00039 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00040 /*     November 2006 */
00041 
00042 /*     .. Scalar Arguments .. */
00043 /*     .. */
00044 /*     .. Array Arguments .. */
00045 /*     .. */
00046 
00047 /*  Purpose */
00048 /*  ======= */
00049 
00050 /*  SGETRS solves a system of linear equations */
00051 /*     A * X = B  or  A' * X = B */
00052 /*  with a general N-by-N matrix A using the LU factorization computed */
00053 /*  by SGETRF. */
00054 
00055 /*  Arguments */
00056 /*  ========= */
00057 
00058 /*  TRANS   (input) CHARACTER*1 */
00059 /*          Specifies the form of the system of equations: */
00060 /*          = 'N':  A * X = B  (No transpose) */
00061 /*          = 'T':  A'* X = B  (Transpose) */
00062 /*          = 'C':  A'* X = B  (Conjugate transpose = Transpose) */
00063 
00064 /*  N       (input) INTEGER */
00065 /*          The order of the matrix A.  N >= 0. */
00066 
00067 /*  NRHS    (input) INTEGER */
00068 /*          The number of right hand sides, i.e., the number of columns */
00069 /*          of the matrix B.  NRHS >= 0. */
00070 
00071 /*  A       (input) REAL array, dimension (LDA,N) */
00072 /*          The factors L and U from the factorization A = P*L*U */
00073 /*          as computed by SGETRF. */
00074 
00075 /*  LDA     (input) INTEGER */
00076 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00077 
00078 /*  IPIV    (input) INTEGER array, dimension (N) */
00079 /*          The pivot indices from SGETRF; for 1<=i<=N, row i of the */
00080 /*          matrix was interchanged with row IPIV(i). */
00081 
00082 /*  B       (input/output) REAL array, dimension (LDB,NRHS) */
00083 /*          On entry, the right hand side matrix B. */
00084 /*          On exit, the solution matrix X. */
00085 
00086 /*  LDB     (input) INTEGER */
00087 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00088 
00089 /*  INFO    (output) INTEGER */
00090 /*          = 0:  successful exit */
00091 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00092 
00093 /*  ===================================================================== */
00094 
00095 /*     .. Parameters .. */
00096 /*     .. */
00097 /*     .. Local Scalars .. */
00098 /*     .. */
00099 /*     .. External Functions .. */
00100 /*     .. */
00101 /*     .. External Subroutines .. */
00102 /*     .. */
00103 /*     .. Intrinsic Functions .. */
00104 /*     .. */
00105 /*     .. Executable Statements .. */
00106 
00107 /*     Test the input parameters. */
00108 
00109     /* Parameter adjustments */
00110     a_dim1 = *lda;
00111     a_offset = 1 + a_dim1;
00112     a -= a_offset;
00113     --ipiv;
00114     b_dim1 = *ldb;
00115     b_offset = 1 + b_dim1;
00116     b -= b_offset;
00117 
00118     /* Function Body */
00119     *info = 0;
00120     notran = lsame_(trans, "N");
00121     if (! notran && ! lsame_(trans, "T") && ! lsame_(
00122             trans, "C")) {
00123         *info = -1;
00124     } else if (*n < 0) {
00125         *info = -2;
00126     } else if (*nrhs < 0) {
00127         *info = -3;
00128     } else if (*lda < max(1,*n)) {
00129         *info = -5;
00130     } else if (*ldb < max(1,*n)) {
00131         *info = -8;
00132     }
00133     if (*info != 0) {
00134         i__1 = -(*info);
00135         xerbla_("SGETRS", &i__1);
00136         return 0;
00137     }
00138 
00139 /*     Quick return if possible */
00140 
00141     if (*n == 0 || *nrhs == 0) {
00142         return 0;
00143     }
00144 
00145     if (notran) {
00146 
00147 /*        Solve A * X = B. */
00148 
00149 /*        Apply row interchanges to the right hand sides. */
00150 
00151         slaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1);
00152 
00153 /*        Solve L*X = B, overwriting B with X. */
00154 
00155         strsm_("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b12, &a[
00156                 a_offset], lda, &b[b_offset], ldb);
00157 
00158 /*        Solve U*X = B, overwriting B with X. */
00159 
00160         strsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b12, &
00161                 a[a_offset], lda, &b[b_offset], ldb);
00162     } else {
00163 
00164 /*        Solve A' * X = B. */
00165 
00166 /*        Solve U'*X = B, overwriting B with X. */
00167 
00168         strsm_("Left", "Upper", "Transpose", "Non-unit", n, nrhs, &c_b12, &a[
00169                 a_offset], lda, &b[b_offset], ldb);
00170 
00171 /*        Solve L'*X = B, overwriting B with X. */
00172 
00173         strsm_("Left", "Lower", "Transpose", "Unit", n, nrhs, &c_b12, &a[
00174                 a_offset], lda, &b[b_offset], ldb);
00175 
00176 /*        Apply row interchanges to the solution vectors. */
00177 
00178         slaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1);
00179     }
00180 
00181     return 0;
00182 
00183 /*     End of SGETRS */
00184 
00185 } /* sgetrs_ */


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