3 /* Subroutine */ int sgesv_(integer *n, integer *nrhs, real *a, integer *lda,
4 integer *ipiv, real *b, integer *ldb, integer *info)
6 /* System generated locals */
7 integer a_dim1, a_offset, b_dim1, b_offset, i__1;
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 *);
16 /* -- LAPACK driver routine (version 3.1) -- */
17 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
20 /* .. Scalar Arguments .. */
22 /* .. Array Arguments .. */
28 /* SGESV computes the solution to a real system of linear equations */
30 /* where A is an N-by-N matrix and X and B are N-by-NRHS matrices. */
32 /* The LU decomposition with partial pivoting and row interchanges is */
33 /* used to factor A as */
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. */
42 /* N (input) INTEGER */
43 /* The number of linear equations, i.e., the order of the */
44 /* matrix A. N >= 0. */
46 /* NRHS (input) INTEGER */
47 /* The number of right hand sides, i.e., the number of columns */
48 /* of the matrix B. NRHS >= 0. */
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. */
55 /* LDA (input) INTEGER */
56 /* The leading dimension of the array A. LDA >= max(1,N). */
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). */
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. */
66 /* LDB (input) INTEGER */
67 /* The leading dimension of the array B. LDB >= max(1,N). */
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. */
76 /* ===================================================================== */
78 /* .. External Subroutines .. */
80 /* .. Intrinsic Functions .. */
82 /* .. Executable Statements .. */
84 /* Test the input parameters. */
86 /* Parameter adjustments */
88 a_offset = 1 + a_dim1;
92 b_offset = 1 + b_dim1;
99 } else if (*nrhs < 0) {
101 } else if (*lda < max(1,*n)) {
103 } else if (*ldb < max(1,*n)) {
108 xerbla_("SGESV ", &i__1);
112 /* Compute the LU factorization of A. */
114 sgetrf_(n, n, &a[a_offset], lda, &ipiv[1], info);
117 /* Solve the system A*X = B, overwriting B with X. */
119 sgetrs_("No transpose", n, nrhs, &a[a_offset], lda, &ipiv[1], &b[
120 b_offset], ldb, info);