kusano 2b45e8
      SUBROUTINE SGETRSF( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
kusano 2b45e8
*
kusano 2b45e8
*  -- LAPACK routine (version 3.0) --
kusano 2b45e8
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
kusano 2b45e8
*     Courant Institute, Argonne National Lab, and Rice University
kusano 2b45e8
*     March 31, 1993 
kusano 2b45e8
*
kusano 2b45e8
*     .. Scalar Arguments ..
kusano 2b45e8
      CHARACTER          TRANS
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
*  SGETRS solves a system of linear equations
kusano 2b45e8
*     A * X = B  or  A' * X = B
kusano 2b45e8
*  with a general N-by-N matrix A using the LU factorization computed
kusano 2b45e8
*  by SGETRF.
kusano 2b45e8
*
kusano 2b45e8
*  Arguments
kusano 2b45e8
*  =========
kusano 2b45e8
*
kusano 2b45e8
*  TRANS   (input) CHARACTER*1
kusano 2b45e8
*          Specifies the form of the system of equations:
kusano 2b45e8
*          = 'N':  A * X = B  (No transpose)
kusano 2b45e8
*          = 'T':  A'* X = B  (Transpose)
kusano 2b45e8
*          = 'C':  A'* X = B  (Conjugate transpose = Transpose)
kusano 2b45e8
*
kusano 2b45e8
*  N       (input) INTEGER
kusano 2b45e8
*          The order of the 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) REAL array, dimension (LDA,N)
kusano 2b45e8
*          The factors L and U from the factorization A = P*L*U
kusano 2b45e8
*          as computed by SGETRF.
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    (input) INTEGER array, dimension (N)
kusano 2b45e8
*          The pivot indices from SGETRF; for 1<=i<=N, row i of the
kusano 2b45e8
*          matrix was interchanged with row IPIV(i).
kusano 2b45e8
*
kusano 2b45e8
*  B       (input/output) REAL array, dimension (LDB,NRHS)
kusano 2b45e8
*          On entry, the right hand side matrix B.
kusano 2b45e8
*          On exit, the 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
*
kusano 2b45e8
*  =====================================================================
kusano 2b45e8
*
kusano 2b45e8
*     .. Parameters ..
kusano 2b45e8
      REAL               ONE
kusano 2b45e8
      PARAMETER          ( ONE = 1.0E+0 )
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Local Scalars ..
kusano 2b45e8
      LOGICAL            NOTRAN
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. External Functions ..
kusano 2b45e8
      LOGICAL            LSAME
kusano 2b45e8
      EXTERNAL           LSAME
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. External Subroutines ..
kusano 2b45e8
      EXTERNAL           SLASWP, STRSM, 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
      NOTRAN = LSAME( TRANS, 'N' )
kusano 2b45e8
      IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
kusano 2b45e8
     $    LSAME( TRANS, 'C' ) ) THEN
kusano 2b45e8
         INFO = -1
kusano 2b45e8
      ELSE IF( N.LT.0 ) THEN
kusano 2b45e8
         INFO = -2
kusano 2b45e8
      ELSE IF( NRHS.LT.0 ) THEN
kusano 2b45e8
         INFO = -3
kusano 2b45e8
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
kusano 2b45e8
         INFO = -5
kusano 2b45e8
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
kusano 2b45e8
         INFO = -8
kusano 2b45e8
      END IF
kusano 2b45e8
      IF( INFO.NE.0 ) THEN
kusano 2b45e8
         CALL XERBLA( 'SGETRS', -INFO )
kusano 2b45e8
         RETURN
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
*     Quick return if possible
kusano 2b45e8
*
kusano 2b45e8
      IF( N.EQ.0 .OR. NRHS.EQ.0 )
kusano 2b45e8
     $   RETURN
kusano 2b45e8
*
kusano 2b45e8
      IF( NOTRAN ) THEN
kusano 2b45e8
*
kusano 2b45e8
*        Solve A * X = B.
kusano 2b45e8
*
kusano 2b45e8
*        Apply row interchanges to the right hand sides.
kusano 2b45e8
*
kusano 2b45e8
         CALL SLASWP( NRHS, B, LDB, 1, N, IPIV, 1 )
kusano 2b45e8
*
kusano 2b45e8
*        Solve L*X = B, overwriting B with X.
kusano 2b45e8
*
kusano 2b45e8
         CALL STRSM( 'Left', 'Lower', 'No transpose', 'Unit', N, NRHS,
kusano 2b45e8
     $               ONE, A, LDA, B, LDB )
kusano 2b45e8
*
kusano 2b45e8
*        Solve U*X = B, overwriting B with X.
kusano 2b45e8
*
kusano 2b45e8
         CALL STRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', N,
kusano 2b45e8
     $               NRHS, ONE, A, LDA, B, LDB )
kusano 2b45e8
      ELSE
kusano 2b45e8
*
kusano 2b45e8
*        Solve A' * X = B.
kusano 2b45e8
*
kusano 2b45e8
*        Solve U'*X = B, overwriting B with X.
kusano 2b45e8
*
kusano 2b45e8
         CALL STRSM( 'Left', 'Upper', 'Transpose', 'Non-unit', N, NRHS,
kusano 2b45e8
     $               ONE, A, LDA, B, LDB )
kusano 2b45e8
*
kusano 2b45e8
*        Solve L'*X = B, overwriting B with X.
kusano 2b45e8
*
kusano 2b45e8
         CALL STRSM( 'Left', 'Lower', 'Transpose', 'Unit', N, NRHS, ONE,
kusano 2b45e8
     $               A, LDA, B, LDB )
kusano 2b45e8
*
kusano 2b45e8
*        Apply row interchanges to the solution vectors.
kusano 2b45e8
*
kusano 2b45e8
         CALL SLASWP( NRHS, B, LDB, 1, N, IPIV, -1 )
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
      RETURN
kusano 2b45e8
*
kusano 2b45e8
*     End of SGETRS
kusano 2b45e8
*
kusano 2b45e8
      END