kusano 2b45e8
      SUBROUTINE SGESVF( N, NRHS, A, LDA, IPIV, B, LDB, INFO )
kusano 2b45e8
*
kusano 2b45e8
*  -- LAPACK driver routine (version 3.1) --
kusano 2b45e8
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
kusano 2b45e8
*     November 2006
kusano 2b45e8
*
kusano 2b45e8
*     .. Scalar Arguments ..
kusano 2b45e8
      INTEGER            INFO, LDA, LDB, N, NRHS
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Array Arguments ..
kusano 2b45e8
      INTEGER            IPIV( * )
kusano 2b45e8
      REAL               A( LDA, * ), B( LDB, * )
kusano 2b45e8
*     ..
kusano 2b45e8
*
kusano 2b45e8
*  Purpose
kusano 2b45e8
*  =======
kusano 2b45e8
*
kusano 2b45e8
*  SGESV computes the solution to a real system of linear equations
kusano 2b45e8
*     A * X = B,
kusano 2b45e8
*  where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
kusano 2b45e8
*
kusano 2b45e8
*  The LU decomposition with partial pivoting and row interchanges is
kusano 2b45e8
*  used to factor A as
kusano 2b45e8
*     A = P * L * U,
kusano 2b45e8
*  where P is a permutation matrix, L is unit lower triangular, and U is
kusano 2b45e8
*  upper triangular.  The factored form of A is then used to solve the
kusano 2b45e8
*  system of equations A * X = B.
kusano 2b45e8
*
kusano 2b45e8
*  Arguments
kusano 2b45e8
*  =========
kusano 2b45e8
*
kusano 2b45e8
*  N       (input) INTEGER
kusano 2b45e8
*          The number of linear equations, i.e., the order of the
kusano 2b45e8
*          matrix A.  N >= 0.
kusano 2b45e8
*
kusano 2b45e8
*  NRHS    (input) INTEGER
kusano 2b45e8
*          The number of right hand sides, i.e., the number of columns
kusano 2b45e8
*          of the matrix B.  NRHS >= 0.
kusano 2b45e8
*
kusano 2b45e8
*  A       (input/output) REAL array, dimension (LDA,N)
kusano 2b45e8
*          On entry, the N-by-N coefficient matrix A.
kusano 2b45e8
*          On exit, the factors L and U from the factorization
kusano 2b45e8
*          A = P*L*U; the unit diagonal elements of L are not stored.
kusano 2b45e8
*
kusano 2b45e8
*  LDA     (input) INTEGER
kusano 2b45e8
*          The leading dimension of the array A.  LDA >= max(1,N).
kusano 2b45e8
*
kusano 2b45e8
*  IPIV    (output) INTEGER array, dimension (N)
kusano 2b45e8
*          The pivot indices that define the permutation matrix P;
kusano 2b45e8
*          row i of the matrix was interchanged with row IPIV(i).
kusano 2b45e8
*
kusano 2b45e8
*  B       (input/output) REAL array, dimension (LDB,NRHS)
kusano 2b45e8
*          On entry, the N-by-NRHS matrix of right hand side matrix B.
kusano 2b45e8
*          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
kusano 2b45e8
*
kusano 2b45e8
*  LDB     (input) INTEGER
kusano 2b45e8
*          The leading dimension of the array B.  LDB >= max(1,N).
kusano 2b45e8
*
kusano 2b45e8
*  INFO    (output) INTEGER
kusano 2b45e8
*          = 0:  successful exit
kusano 2b45e8
*          < 0:  if INFO = -i, the i-th argument had an illegal value
kusano 2b45e8
*          > 0:  if INFO = i, U(i,i) is exactly zero.  The factorization
kusano 2b45e8
*                has been completed, but the factor U is exactly
kusano 2b45e8
*                singular, so the solution could not be computed.
kusano 2b45e8
*
kusano 2b45e8
*  =====================================================================
kusano 2b45e8
*
kusano 2b45e8
*     .. External Subroutines ..
kusano 2b45e8
      EXTERNAL           SGETRF, SGETRS, XERBLA
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Intrinsic Functions ..
kusano 2b45e8
      INTRINSIC          MAX
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Executable Statements ..
kusano 2b45e8
*
kusano 2b45e8
*     Test the input parameters.
kusano 2b45e8
*
kusano 2b45e8
      INFO = 0
kusano 2b45e8
      IF( N.LT.0 ) THEN
kusano 2b45e8
         INFO = -1
kusano 2b45e8
      ELSE IF( NRHS.LT.0 ) THEN
kusano 2b45e8
         INFO = -2
kusano 2b45e8
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
kusano 2b45e8
         INFO = -4
kusano 2b45e8
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
kusano 2b45e8
         INFO = -7
kusano 2b45e8
      END IF
kusano 2b45e8
      IF( INFO.NE.0 ) THEN
kusano 2b45e8
         CALL XERBLA( 'SGESV ', -INFO )
kusano 2b45e8
         RETURN
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
*     Compute the LU factorization of A.
kusano 2b45e8
*
kusano 2b45e8
      CALL SGETRF( N, N, A, LDA, IPIV, INFO )
kusano 2b45e8
      IF( INFO.EQ.0 ) THEN
kusano 2b45e8
*
kusano 2b45e8
*        Solve the system A*X = B, overwriting B with X.
kusano 2b45e8
*
kusano 2b45e8
         CALL SGETRS( 'No transpose', N, NRHS, A, LDA, IPIV, B, LDB,
kusano 2b45e8
     $                INFO )
kusano 2b45e8
      END IF
kusano 2b45e8
      RETURN
kusano 2b45e8
*
kusano 2b45e8
*     End of SGESV
kusano 2b45e8
*
kusano 2b45e8
      END