LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sgetrs.f
Go to the documentation of this file.
00001 *> \brief \b SGETRS
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download SGETRS + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgetrs.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgetrs.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgetrs.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       CHARACTER          TRANS
00025 *       INTEGER            INFO, LDA, LDB, N, NRHS
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       INTEGER            IPIV( * )
00029 *       REAL               A( LDA, * ), B( LDB, * )
00030 *       ..
00031 *  
00032 *
00033 *> \par Purpose:
00034 *  =============
00035 *>
00036 *> \verbatim
00037 *>
00038 *> SGETRS solves a system of linear equations
00039 *>    A * X = B  or  A**T * X = B
00040 *> with a general N-by-N matrix A using the LU factorization computed
00041 *> by SGETRF.
00042 *> \endverbatim
00043 *
00044 *  Arguments:
00045 *  ==========
00046 *
00047 *> \param[in] TRANS
00048 *> \verbatim
00049 *>          TRANS is CHARACTER*1
00050 *>          Specifies the form of the system of equations:
00051 *>          = 'N':  A * X = B  (No transpose)
00052 *>          = 'T':  A**T* X = B  (Transpose)
00053 *>          = 'C':  A**T* X = B  (Conjugate transpose = Transpose)
00054 *> \endverbatim
00055 *>
00056 *> \param[in] N
00057 *> \verbatim
00058 *>          N is INTEGER
00059 *>          The order of the matrix A.  N >= 0.
00060 *> \endverbatim
00061 *>
00062 *> \param[in] NRHS
00063 *> \verbatim
00064 *>          NRHS is INTEGER
00065 *>          The number of right hand sides, i.e., the number of columns
00066 *>          of the matrix B.  NRHS >= 0.
00067 *> \endverbatim
00068 *>
00069 *> \param[in] A
00070 *> \verbatim
00071 *>          A is REAL array, dimension (LDA,N)
00072 *>          The factors L and U from the factorization A = P*L*U
00073 *>          as computed by SGETRF.
00074 *> \endverbatim
00075 *>
00076 *> \param[in] LDA
00077 *> \verbatim
00078 *>          LDA is INTEGER
00079 *>          The leading dimension of the array A.  LDA >= max(1,N).
00080 *> \endverbatim
00081 *>
00082 *> \param[in] IPIV
00083 *> \verbatim
00084 *>          IPIV is INTEGER array, dimension (N)
00085 *>          The pivot indices from SGETRF; for 1<=i<=N, row i of the
00086 *>          matrix was interchanged with row IPIV(i).
00087 *> \endverbatim
00088 *>
00089 *> \param[in,out] B
00090 *> \verbatim
00091 *>          B is REAL array, dimension (LDB,NRHS)
00092 *>          On entry, the right hand side matrix B.
00093 *>          On exit, the solution matrix X.
00094 *> \endverbatim
00095 *>
00096 *> \param[in] LDB
00097 *> \verbatim
00098 *>          LDB is INTEGER
00099 *>          The leading dimension of the array B.  LDB >= max(1,N).
00100 *> \endverbatim
00101 *>
00102 *> \param[out] INFO
00103 *> \verbatim
00104 *>          INFO is INTEGER
00105 *>          = 0:  successful exit
00106 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00107 *> \endverbatim
00108 *
00109 *  Authors:
00110 *  ========
00111 *
00112 *> \author Univ. of Tennessee 
00113 *> \author Univ. of California Berkeley 
00114 *> \author Univ. of Colorado Denver 
00115 *> \author NAG Ltd. 
00116 *
00117 *> \date November 2011
00118 *
00119 *> \ingroup realGEcomputational
00120 *
00121 *  =====================================================================
00122       SUBROUTINE SGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
00123 *
00124 *  -- LAPACK computational routine (version 3.4.0) --
00125 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00126 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00127 *     November 2011
00128 *
00129 *     .. Scalar Arguments ..
00130       CHARACTER          TRANS
00131       INTEGER            INFO, LDA, LDB, N, NRHS
00132 *     ..
00133 *     .. Array Arguments ..
00134       INTEGER            IPIV( * )
00135       REAL               A( LDA, * ), B( LDB, * )
00136 *     ..
00137 *
00138 *  =====================================================================
00139 *
00140 *     .. Parameters ..
00141       REAL               ONE
00142       PARAMETER          ( ONE = 1.0E+0 )
00143 *     ..
00144 *     .. Local Scalars ..
00145       LOGICAL            NOTRAN
00146 *     ..
00147 *     .. External Functions ..
00148       LOGICAL            LSAME
00149       EXTERNAL           LSAME
00150 *     ..
00151 *     .. External Subroutines ..
00152       EXTERNAL           SLASWP, STRSM, XERBLA
00153 *     ..
00154 *     .. Intrinsic Functions ..
00155       INTRINSIC          MAX
00156 *     ..
00157 *     .. Executable Statements ..
00158 *
00159 *     Test the input parameters.
00160 *
00161       INFO = 0
00162       NOTRAN = LSAME( TRANS, 'N' )
00163       IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
00164      $    LSAME( TRANS, 'C' ) ) THEN
00165          INFO = -1
00166       ELSE IF( N.LT.0 ) THEN
00167          INFO = -2
00168       ELSE IF( NRHS.LT.0 ) THEN
00169          INFO = -3
00170       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00171          INFO = -5
00172       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00173          INFO = -8
00174       END IF
00175       IF( INFO.NE.0 ) THEN
00176          CALL XERBLA( 'SGETRS', -INFO )
00177          RETURN
00178       END IF
00179 *
00180 *     Quick return if possible
00181 *
00182       IF( N.EQ.0 .OR. NRHS.EQ.0 )
00183      $   RETURN
00184 *
00185       IF( NOTRAN ) THEN
00186 *
00187 *        Solve A * X = B.
00188 *
00189 *        Apply row interchanges to the right hand sides.
00190 *
00191          CALL SLASWP( NRHS, B, LDB, 1, N, IPIV, 1 )
00192 *
00193 *        Solve L*X = B, overwriting B with X.
00194 *
00195          CALL STRSM( 'Left', 'Lower', 'No transpose', 'Unit', N, NRHS,
00196      $               ONE, A, LDA, B, LDB )
00197 *
00198 *        Solve U*X = B, overwriting B with X.
00199 *
00200          CALL STRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', N,
00201      $               NRHS, ONE, A, LDA, B, LDB )
00202       ELSE
00203 *
00204 *        Solve A**T * X = B.
00205 *
00206 *        Solve U**T *X = B, overwriting B with X.
00207 *
00208          CALL STRSM( 'Left', 'Upper', 'Transpose', 'Non-unit', N, NRHS,
00209      $               ONE, A, LDA, B, LDB )
00210 *
00211 *        Solve L**T *X = B, overwriting B with X.
00212 *
00213          CALL STRSM( 'Left', 'Lower', 'Transpose', 'Unit', N, NRHS, ONE,
00214      $               A, LDA, B, LDB )
00215 *
00216 *        Apply row interchanges to the solution vectors.
00217 *
00218          CALL SLASWP( NRHS, B, LDB, 1, N, IPIV, -1 )
00219       END IF
00220 *
00221       RETURN
00222 *
00223 *     End of SGETRS
00224 *
00225       END
 All Files Functions