?gesv

Computes the solution to the system of linear equations with a square matrix A and multiple right-hand sides.

Syntax

FORTRAN 77:

call sgesv( n, nrhs, a, lda, ipiv, b, ldb, info )

call dgesv( n, nrhs, a, lda, ipiv, b, ldb, info )

call cgesv( n, nrhs, a, lda, ipiv, b, ldb, info )

call zgesv( n, nrhs, a, lda, ipiv, b, ldb, info )

call dsgesv( n, nrhs, a, lda, ipiv, b, ldb, x, ldx, work, swork, iter, info )

call zcgesv( n, nrhs, a, lda, ipiv, b, ldb, x, ldx, work, swork, rwork, iter, info )

FORTRAN 95:

call gesv( a, b [,ipiv] [,info] )

C:

lapack_int LAPACKE_<?>gesv( int matrix_order, lapack_int n, lapack_int nrhs, <datatype>* a, lapack_int lda, lapack_int* ipiv, <datatype>* b, lapack_int ldb );

lapack_int LAPACKE_dsgesv( int matrix_order, lapack_int n, lapack_int nrhs, double* a, lapack_int lda, lapack_int* ipiv, double* b, lapack_int ldb, double* x, lapack_int ldx, lapack_int* iter );

lapack_int LAPACKE_zcgesv( int matrix_order, lapack_int n, lapack_int nrhs, lapack_complex_double* a, lapack_int lda, lapack_int* ipiv, lapack_complex_double* b, lapack_int ldb, lapack_complex_double* x, lapack_int ldx, lapack_int* iter );

Include Files

Description

The routine solves for X the system of linear equations A*X = B, where A is an n-by-n matrix, the columns of matrix B are individual right-hand sides, and the columns of X are the corresponding solutions.

The LU decomposition with partial pivoting and row interchanges is used to factor A as A = P*L*U, where P is a permutation matrix, L is unit lower triangular, and U is upper triangular. The factored form of A is then used to solve the system of equations A*X = B.

The dsgesv and zcgesv are mixed precision iterative refinement subroutines for exploiting fast single precision hardware. They first attempt to factorize the matrix in single precision (dsgesv) or single complex precision (zcgesv) and use this factorization within an iterative refinement procedure to produce a solution with double precision (dsgesv) / double complex precision (zcgesv) normwise backward error quality (see below). If the approach fails, the method switches to a double precision or double complex precision factorization respectively and computes the solution.

The iterative refinement is not going to be a winning strategy if the ratio single precision performance over double precision performance is too small. A reasonable strategy should take the number of right-hand sides and the size of the matrix into account. This might be done with a call to ilaenv in the future. At present, iterative refinement is implemented.

The iterative refinement process is stopped if

iter > itermax

or for all the right-hand sides:

rnmr < sqrt(n)*xnrm*anrm*eps*bwdmax

where

The values itermax and bwdmax are fixed to 30 and 1.0d+00 respectively.

Input Parameters

The data types are given for the Fortran interface. A <datatype> placeholder, if present, is used for the C interface data types in the C interface section above. See C Interface Conventions for the C interface principal conventions and type definitions.

n

INTEGER. The number of linear equations, that is, the order of the matrix A; n 0.

nrhs

INTEGER. The number of right-hand sides, that is, the number of columns of the matrix B; nrhs 0.

a, b

REAL for sgesv

DOUBLE PRECISION for dgesv and dsgesv

COMPLEX for cgesv

DOUBLE COMPLEX for zgesv and zcgesv.

Arrays: a(lda,*), b(ldb,*).

The array a contains the n-by-n coefficient matrix A.

The array b contains the n-by-nrhs matrix of right hand side matrix B.

The second dimension of a must be at least max(1, n), the second dimension of b at least max(1,nrhs).

lda

INTEGER. The leading dimension of the array a; lda max(1, n).

ldb

INTEGER. The leading dimension of the array b; ldb max(1, n).

ldx

INTEGER. The leading dimension of the array x; ldx max(1, n).

work

DOUBLE PRECISION for dsgesv

DOUBLE COMPLEX for zcgesv.

Workspace array, DIMENSION at least max(1,n*nrhs). This array is used to hold the residual vectors.

swork

REAL for dsgesv

COMPLEX for zcgesv.

Workspace array, DIMENSION at least max(1,n*(n+nrhs)). This array is used to use the single precision matrix and the right-hand sides or solutions in single precision.

rwork

DOUBLE PRECISION. Workspace array, DIMENSION at least max(1,n).

Output Parameters

a

Overwritten by the factors L and U from the factorization of A = P*L*U; the unit diagonal elements of L are not stored.

If iterative refinement has been successfully used (info= 0 and iter 0), then A is unchanged.

If double precision factorization has been used (info= 0 and iter < 0), then the array A contains the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.

b

Overwritten by the solution matrix X for dgesv, sgesv,zgesv,zgesv. Unchanged for dsgesv and zcgesv.

ipiv

INTEGER.

Array, DIMENSION at least max(1, n). The pivot indices that define the permutation matrix P; row i of the matrix was interchanged with row ipiv(i). Corresponds to the single precision factorization (if info= 0 and iter 0) or the double precision factorization (if info= 0 and iter < 0).

x

DOUBLE PRECISION for dsgesv

DOUBLE COMPLEX for zcgesv.

Array, DIMENSION (ldx, nrhs). If info = 0, contains the n-by-nrhs solution matrix X.

iter

INTEGER.

If iter < 0: iterative refinement has failed, double precision factorization has been performed

  • If iter = -1: the routine fell back to full precision for implementation- or machine-specific reason

  • If iter = -2: narrowing the precision induced an overflow, the routine fell back to full precision

  • If iter = -3: failure of sgetrf for dsgesv, or cgetrf for zcgesv

  • If iter = -31: stop the iterative refinement after the 30th iteration.

If iter > 0: iterative refinement has been successfully used. Returns the number of iterations.

info

INTEGER. If info=0, the execution is successful.

If info = -i, the i-th parameter had an illegal value.

If info = i, U(i, i) (computed in double precision for mixed precision subroutines) is exactly zero. The factorization has been completed, but the factor U is exactly singular, so the solution could not be computed.

Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or reconstructible arguments, see Fortran 95 Interface Conventions.

Specific details for the routine gesv interface are as follows:

a

Holds the matrix A of size (n,n).

b

Holds the matrix B of size (n,nrhs).

ipiv

Holds the vector of length n.

Note iconNote

Fortran 95 Interface is so far not available for the mixed precision subroutines dsgesv/zcgesv.

See Also


Submit feedback on this help topic