3 /* Table of constant values */
5 static integer c__1 = 1;
6 static real c_b12 = 1.f;
7 static integer c_n1 = -1;
9 /* Subroutine */ int sgetrs_(char *trans, integer *n, integer *nrhs, real *a,
10 integer *lda, integer *ipiv, real *b, integer *ldb, integer *info)
12 /* System generated locals */
13 integer a_dim1, a_offset, b_dim1, b_offset, i__1;
16 extern logical lsame_(char *, char *);
17 extern /* Subroutine */ int strsm_(char *, char *, char *, char *,
18 integer *, integer *, real *, real *, integer *, real *, integer *
19 ), xerbla_(char *, integer *);
21 extern /* Subroutine */ int slaswp_(integer *, real *, integer *, integer
22 *, integer *, integer *, integer *);
25 /* -- LAPACK routine (version 3.1) -- */
26 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
29 /* .. Scalar Arguments .. */
31 /* .. Array Arguments .. */
37 /* SGETRS solves a system of linear equations */
38 /* A * X = B or A' * X = B */
39 /* with a general N-by-N matrix A using the LU factorization computed */
45 /* TRANS (input) CHARACTER*1 */
46 /* Specifies the form of the system of equations: */
47 /* = 'N': A * X = B (No transpose) */
48 /* = 'T': A'* X = B (Transpose) */
49 /* = 'C': A'* X = B (Conjugate transpose = Transpose) */
51 /* N (input) INTEGER */
52 /* The order of the matrix A. N >= 0. */
54 /* NRHS (input) INTEGER */
55 /* The number of right hand sides, i.e., the number of columns */
56 /* of the matrix B. NRHS >= 0. */
58 /* A (input) REAL array, dimension (LDA,N) */
59 /* The factors L and U from the factorization A = P*L*U */
60 /* as computed by SGETRF. */
62 /* LDA (input) INTEGER */
63 /* The leading dimension of the array A. LDA >= max(1,N). */
65 /* IPIV (input) INTEGER array, dimension (N) */
66 /* The pivot indices from SGETRF; for 1<=i<=N, row i of the */
67 /* matrix was interchanged with row IPIV(i). */
69 /* B (input/output) REAL array, dimension (LDB,NRHS) */
70 /* On entry, the right hand side matrix B. */
71 /* On exit, the solution matrix X. */
73 /* LDB (input) INTEGER */
74 /* The leading dimension of the array B. LDB >= max(1,N). */
76 /* INFO (output) INTEGER */
77 /* = 0: successful exit */
78 /* < 0: if INFO = -i, the i-th argument had an illegal value */
80 /* ===================================================================== */
82 /* .. Parameters .. */
84 /* .. Local Scalars .. */
86 /* .. External Functions .. */
88 /* .. External Subroutines .. */
90 /* .. Intrinsic Functions .. */
92 /* .. Executable Statements .. */
94 /* Test the input parameters. */
96 /* Parameter adjustments */
98 a_offset = 1 + a_dim1;
102 b_offset = 1 + b_dim1;
107 notran = lsame_(trans, "N");
108 if (! notran && ! lsame_(trans, "T") && ! lsame_(
113 } else if (*nrhs < 0) {
115 } else if (*lda < max(1,*n)) {
117 } else if (*ldb < max(1,*n)) {
122 xerbla_("SGETRS", &i__1);
126 /* Quick return if possible */
128 if (*n == 0 || *nrhs == 0) {
134 /* Solve A * X = B. */
136 /* Apply row interchanges to the right hand sides. */
138 slaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1);
140 /* Solve L*X = B, overwriting B with X. */
142 strsm_("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b12, &a[
143 a_offset], lda, &b[b_offset], ldb);
145 /* Solve U*X = B, overwriting B with X. */
147 strsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b12, &
148 a[a_offset], lda, &b[b_offset], ldb);
151 /* Solve A' * X = B. */
153 /* Solve U'*X = B, overwriting B with X. */
155 strsm_("Left", "Upper", "Transpose", "Non-unit", n, nrhs, &c_b12, &a[
156 a_offset], lda, &b[b_offset], ldb);
158 /* Solve L'*X = B, overwriting B with X. */
160 strsm_("Left", "Lower", "Transpose", "Unit", n, nrhs, &c_b12, &a[
161 a_offset], lda, &b[b_offset], ldb);
163 /* Apply row interchanges to the solution vectors. */
165 slaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1);