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