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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:45