3 /* Table of constant values */
5 static integer c__1 = 1;
6 static doublereal c_b12 = 1.;
7 static integer c_n1 = -1;
9 /* Subroutine */ int dgetrs_(char *trans, integer *n, integer *nrhs,
10 doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *
13 /* System generated locals */
14 integer a_dim1, a_offset, b_dim1, b_offset, i__1;
17 extern logical lsame_(char *, char *);
18 extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *,
19 integer *, integer *, doublereal *, doublereal *, integer *,
20 doublereal *, integer *), xerbla_(
21 char *, integer *), dlaswp_(integer *, doublereal *,
22 integer *, integer *, integer *, integer *, integer *);
26 /* -- LAPACK routine (version 3.1) -- */
27 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
30 /* .. Scalar Arguments .. */
32 /* .. Array Arguments .. */
38 /* DGETRS solves a system of linear equations */
39 /* A * X = B or A' * X = B */
40 /* with a general N-by-N matrix A using the LU factorization computed */
46 /* TRANS (input) CHARACTER*1 */
47 /* Specifies the form of the system of equations: */
48 /* = 'N': A * X = B (No transpose) */
49 /* = 'T': A'* X = B (Transpose) */
50 /* = 'C': A'* X = B (Conjugate transpose = Transpose) */
52 /* N (input) INTEGER */
53 /* The order of the matrix A. N >= 0. */
55 /* NRHS (input) INTEGER */
56 /* The number of right hand sides, i.e., the number of columns */
57 /* of the matrix B. NRHS >= 0. */
59 /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
60 /* The factors L and U from the factorization A = P*L*U */
61 /* as computed by DGETRF. */
63 /* LDA (input) INTEGER */
64 /* The leading dimension of the array A. LDA >= max(1,N). */
66 /* IPIV (input) INTEGER array, dimension (N) */
67 /* The pivot indices from DGETRF; for 1<=i<=N, row i of the */
68 /* matrix was interchanged with row IPIV(i). */
70 /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
71 /* On entry, the right hand side matrix B. */
72 /* On exit, the solution matrix X. */
74 /* LDB (input) INTEGER */
75 /* The leading dimension of the array B. LDB >= max(1,N). */
77 /* INFO (output) INTEGER */
78 /* = 0: successful exit */
79 /* < 0: if INFO = -i, the i-th argument had an illegal value */
81 /* ===================================================================== */
83 /* .. Parameters .. */
85 /* .. Local Scalars .. */
87 /* .. External Functions .. */
89 /* .. External Subroutines .. */
91 /* .. Intrinsic Functions .. */
93 /* .. Executable Statements .. */
95 /* Test the input parameters. */
97 /* Parameter adjustments */
99 a_offset = 1 + a_dim1;
103 b_offset = 1 + b_dim1;
108 notran = lsame_(trans, "N");
109 if (! notran && ! lsame_(trans, "T") && ! lsame_(
114 } else if (*nrhs < 0) {
116 } else if (*lda < max(1,*n)) {
118 } else if (*ldb < max(1,*n)) {
123 xerbla_("DGETRS", &i__1);
127 /* Quick return if possible */
129 if (*n == 0 || *nrhs == 0) {
135 /* Solve A * X = B. */
137 /* Apply row interchanges to the right hand sides. */
139 dlaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1);
141 /* Solve L*X = B, overwriting B with X. */
143 dtrsm_("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b12, &a[
144 a_offset], lda, &b[b_offset], ldb);
146 /* Solve U*X = B, overwriting B with X. */
148 dtrsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b12, &
149 a[a_offset], lda, &b[b_offset], ldb);
152 /* Solve A' * X = B. */
154 /* Solve U'*X = B, overwriting B with X. */
156 dtrsm_("Left", "Upper", "Transpose", "Non-unit", n, nrhs, &c_b12, &a[
157 a_offset], lda, &b[b_offset], ldb);
159 /* Solve L'*X = B, overwriting B with X. */
161 dtrsm_("Left", "Lower", "Transpose", "Unit", n, nrhs, &c_b12, &a[
162 a_offset], lda, &b[b_offset], ldb);
164 /* Apply row interchanges to the solution vectors. */
166 dlaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1);