Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / sgetrs.c
1 #include "clapack.h"
2
3 /* Table of constant values */
4
5 static integer c__1 = 1;
6 static real c_b12 = 1.f;
7 static integer c_n1 = -1;
8
9 /* Subroutine */ int sgetrs_(char *trans, integer *n, integer *nrhs, real *a, 
10         integer *lda, integer *ipiv, real *b, integer *ldb, integer *info)
11 {
12     /* System generated locals */
13     integer a_dim1, a_offset, b_dim1, b_offset, i__1;
14
15     /* Local variables */
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 *);
20     logical notran;
21     extern /* Subroutine */ int slaswp_(integer *, real *, integer *, integer 
22             *, integer *, integer *, integer *);
23
24
25 /*  -- LAPACK routine (version 3.1) -- */
26 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
27 /*     November 2006 */
28
29 /*     .. Scalar Arguments .. */
30 /*     .. */
31 /*     .. Array Arguments .. */
32 /*     .. */
33
34 /*  Purpose */
35 /*  ======= */
36
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 */
40 /*  by SGETRF. */
41
42 /*  Arguments */
43 /*  ========= */
44
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) */
50
51 /*  N       (input) INTEGER */
52 /*          The order of the matrix A.  N >= 0. */
53
54 /*  NRHS    (input) INTEGER */
55 /*          The number of right hand sides, i.e., the number of columns */
56 /*          of the matrix B.  NRHS >= 0. */
57
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. */
61
62 /*  LDA     (input) INTEGER */
63 /*          The leading dimension of the array A.  LDA >= max(1,N). */
64
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). */
68
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. */
72
73 /*  LDB     (input) INTEGER */
74 /*          The leading dimension of the array B.  LDB >= max(1,N). */
75
76 /*  INFO    (output) INTEGER */
77 /*          = 0:  successful exit */
78 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
79
80 /*  ===================================================================== */
81
82 /*     .. Parameters .. */
83 /*     .. */
84 /*     .. Local Scalars .. */
85 /*     .. */
86 /*     .. External Functions .. */
87 /*     .. */
88 /*     .. External Subroutines .. */
89 /*     .. */
90 /*     .. Intrinsic Functions .. */
91 /*     .. */
92 /*     .. Executable Statements .. */
93
94 /*     Test the input parameters. */
95
96     /* Parameter adjustments */
97     a_dim1 = *lda;
98     a_offset = 1 + a_dim1;
99     a -= a_offset;
100     --ipiv;
101     b_dim1 = *ldb;
102     b_offset = 1 + b_dim1;
103     b -= b_offset;
104
105     /* Function Body */
106     *info = 0;
107     notran = lsame_(trans, "N");
108     if (! notran && ! lsame_(trans, "T") && ! lsame_(
109             trans, "C")) {
110         *info = -1;
111     } else if (*n < 0) {
112         *info = -2;
113     } else if (*nrhs < 0) {
114         *info = -3;
115     } else if (*lda < max(1,*n)) {
116         *info = -5;
117     } else if (*ldb < max(1,*n)) {
118         *info = -8;
119     }
120     if (*info != 0) {
121         i__1 = -(*info);
122         xerbla_("SGETRS", &i__1);
123         return 0;
124     }
125
126 /*     Quick return if possible */
127
128     if (*n == 0 || *nrhs == 0) {
129         return 0;
130     }
131
132     if (notran) {
133
134 /*        Solve A * X = B. */
135
136 /*        Apply row interchanges to the right hand sides. */
137
138         slaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1);
139
140 /*        Solve L*X = B, overwriting B with X. */
141
142         strsm_("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b12, &a[
143                 a_offset], lda, &b[b_offset], ldb);
144
145 /*        Solve U*X = B, overwriting B with X. */
146
147         strsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b12, &
148                 a[a_offset], lda, &b[b_offset], ldb);
149     } else {
150
151 /*        Solve A' * X = B. */
152
153 /*        Solve U'*X = B, overwriting B with X. */
154
155         strsm_("Left", "Upper", "Transpose", "Non-unit", n, nrhs, &c_b12, &a[
156                 a_offset], lda, &b[b_offset], ldb);
157
158 /*        Solve L'*X = B, overwriting B with X. */
159
160         strsm_("Left", "Lower", "Transpose", "Unit", n, nrhs, &c_b12, &a[
161                 a_offset], lda, &b[b_offset], ldb);
162
163 /*        Apply row interchanges to the solution vectors. */
164
165         slaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1);
166     }
167
168     return 0;
169
170 /*     End of SGETRS */
171
172 } /* sgetrs_ */