Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / sgesv.c
1 #include "clapack.h"
2
3 /* Subroutine */ int sgesv_(integer *n, integer *nrhs, real *a, integer *lda, 
4         integer *ipiv, real *b, integer *ldb, integer *info)
5 {
6     /* System generated locals */
7     integer a_dim1, a_offset, b_dim1, b_offset, i__1;
8
9     /* Local variables */
10     extern /* Subroutine */ int xerbla_(char *, integer *), sgetrf_(
11             integer *, integer *, real *, integer *, integer *, integer *), 
12             sgetrs_(char *, integer *, integer *, real *, integer *, integer *
13 , real *, integer *, integer *);
14
15
16 /*  -- LAPACK driver routine (version 3.1) -- */
17 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
18 /*     November 2006 */
19
20 /*     .. Scalar Arguments .. */
21 /*     .. */
22 /*     .. Array Arguments .. */
23 /*     .. */
24
25 /*  Purpose */
26 /*  ======= */
27
28 /*  SGESV computes the solution to a real system of linear equations */
29 /*     A * X = B, */
30 /*  where A is an N-by-N matrix and X and B are N-by-NRHS matrices. */
31
32 /*  The LU decomposition with partial pivoting and row interchanges is */
33 /*  used to factor A as */
34 /*     A = P * L * U, */
35 /*  where P is a permutation matrix, L is unit lower triangular, and U is */
36 /*  upper triangular.  The factored form of A is then used to solve the */
37 /*  system of equations A * X = B. */
38
39 /*  Arguments */
40 /*  ========= */
41
42 /*  N       (input) INTEGER */
43 /*          The number of linear equations, i.e., the order of the */
44 /*          matrix A.  N >= 0. */
45
46 /*  NRHS    (input) INTEGER */
47 /*          The number of right hand sides, i.e., the number of columns */
48 /*          of the matrix B.  NRHS >= 0. */
49
50 /*  A       (input/output) REAL array, dimension (LDA,N) */
51 /*          On entry, the N-by-N coefficient matrix A. */
52 /*          On exit, the factors L and U from the factorization */
53 /*          A = P*L*U; the unit diagonal elements of L are not stored. */
54
55 /*  LDA     (input) INTEGER */
56 /*          The leading dimension of the array A.  LDA >= max(1,N). */
57
58 /*  IPIV    (output) INTEGER array, dimension (N) */
59 /*          The pivot indices that define the permutation matrix P; */
60 /*          row i of the matrix was interchanged with row IPIV(i). */
61
62 /*  B       (input/output) REAL array, dimension (LDB,NRHS) */
63 /*          On entry, the N-by-NRHS matrix of right hand side matrix B. */
64 /*          On exit, if INFO = 0, the N-by-NRHS solution matrix X. */
65
66 /*  LDB     (input) INTEGER */
67 /*          The leading dimension of the array B.  LDB >= max(1,N). */
68
69 /*  INFO    (output) INTEGER */
70 /*          = 0:  successful exit */
71 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
72 /*          > 0:  if INFO = i, U(i,i) is exactly zero.  The factorization */
73 /*                has been completed, but the factor U is exactly */
74 /*                singular, so the solution could not be computed. */
75
76 /*  ===================================================================== */
77
78 /*     .. External Subroutines .. */
79 /*     .. */
80 /*     .. Intrinsic Functions .. */
81 /*     .. */
82 /*     .. Executable Statements .. */
83
84 /*     Test the input parameters. */
85
86     /* Parameter adjustments */
87     a_dim1 = *lda;
88     a_offset = 1 + a_dim1;
89     a -= a_offset;
90     --ipiv;
91     b_dim1 = *ldb;
92     b_offset = 1 + b_dim1;
93     b -= b_offset;
94
95     /* Function Body */
96     *info = 0;
97     if (*n < 0) {
98         *info = -1;
99     } else if (*nrhs < 0) {
100         *info = -2;
101     } else if (*lda < max(1,*n)) {
102         *info = -4;
103     } else if (*ldb < max(1,*n)) {
104         *info = -7;
105     }
106     if (*info != 0) {
107         i__1 = -(*info);
108         xerbla_("SGESV ", &i__1);
109         return 0;
110     }
111
112 /*     Compute the LU factorization of A. */
113
114     sgetrf_(n, n, &a[a_offset], lda, &ipiv[1], info);
115     if (*info == 0) {
116
117 /*        Solve the system A*X = B, overwriting B with X. */
118
119         sgetrs_("No transpose", n, nrhs, &a[a_offset], lda, &ipiv[1], &b[
120                 b_offset], ldb, info);
121     }
122     return 0;
123
124 /*     End of SGESV */
125
126 } /* sgesv_ */