LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ sgetrf()

subroutine sgetrf ( integer m,
integer n,
real, dimension( lda, * ) a,
integer lda,
integer, dimension( * ) ipiv,
integer info )

SGETRF

Download SGETRF + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SGETRF computes an LU factorization of a general M-by-N matrix A
!> using partial pivoting with row interchanges.
!>
!> The factorization has the form
!>    A = P * L * U
!> where P is a permutation matrix, L is lower triangular with unit
!> diagonal elements (lower trapezoidal if m > n), and U is upper
!> triangular (upper trapezoidal if m < n).
!>
!> This is the right-looking Level 3 BLAS version of the algorithm.
!> 
Parameters
[in]M
!>          M is INTEGER
!>          The number of rows of the matrix A.  M >= 0.
!> 
[in]N
!>          N is INTEGER
!>          The number of columns of the matrix A.  N >= 0.
!> 
[in,out]A
!>          A is REAL array, dimension (LDA,N)
!>          On entry, the M-by-N matrix to be factored.
!>          On exit, the factors L and U from the factorization
!>          A = P*L*U; the unit diagonal elements of L are not stored.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,M).
!> 
[out]IPIV
!>          IPIV is INTEGER array, dimension (min(M,N))
!>          The pivot indices; for 1 <= i <= min(M,N), row i of the
!>          matrix was interchanged with row IPIV(i).
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!>          > 0:  if INFO = i, U(i,i) is exactly zero. The factorization
!>                has been completed, but the factor U is exactly
!>                singular, and division by zero will occur if it is used
!>                to solve a system of equations.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 105 of file sgetrf.f.

106*
107* -- LAPACK computational routine --
108* -- LAPACK is a software package provided by Univ. of Tennessee, --
109* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
110*
111* .. Scalar Arguments ..
112 INTEGER INFO, LDA, M, N
113* ..
114* .. Array Arguments ..
115 INTEGER IPIV( * )
116 REAL A( LDA, * )
117* ..
118*
119* =====================================================================
120*
121* .. Parameters ..
122 REAL ONE
123 parameter( one = 1.0e+0 )
124* ..
125* .. Local Scalars ..
126 INTEGER I, IINFO, J, JB, NB
127* ..
128* .. External Subroutines ..
129 EXTERNAL sgemm, sgetrf2, slaswp, strsm,
130 $ xerbla
131* ..
132* .. External Functions ..
133 INTEGER ILAENV
134 EXTERNAL ilaenv
135* ..
136* .. Intrinsic Functions ..
137 INTRINSIC max, min
138* ..
139* .. Executable Statements ..
140*
141* Test the input parameters.
142*
143 info = 0
144 IF( m.LT.0 ) THEN
145 info = -1
146 ELSE IF( n.LT.0 ) THEN
147 info = -2
148 ELSE IF( lda.LT.max( 1, m ) ) THEN
149 info = -4
150 END IF
151 IF( info.NE.0 ) THEN
152 CALL xerbla( 'SGETRF', -info )
153 RETURN
154 END IF
155*
156* Quick return if possible
157*
158 IF( m.EQ.0 .OR. n.EQ.0 )
159 $ RETURN
160*
161* Determine the block size for this environment.
162*
163 nb = ilaenv( 1, 'SGETRF', ' ', m, n, -1, -1 )
164 IF( nb.LE.1 .OR. nb.GE.min( m, n ) ) THEN
165*
166* Use unblocked code.
167*
168 CALL sgetrf2( m, n, a, lda, ipiv, info )
169 ELSE
170*
171* Use blocked code.
172*
173 DO 20 j = 1, min( m, n ), nb
174 jb = min( min( m, n )-j+1, nb )
175*
176* Factor diagonal and subdiagonal blocks and test for exact
177* singularity.
178*
179 CALL sgetrf2( m-j+1, jb, a( j, j ), lda, ipiv( j ),
180 $ iinfo )
181*
182* Adjust INFO and the pivot indices.
183*
184 IF( info.EQ.0 .AND. iinfo.GT.0 )
185 $ info = iinfo + j - 1
186 DO 10 i = j, min( m, j+jb-1 )
187 ipiv( i ) = j - 1 + ipiv( i )
188 10 CONTINUE
189*
190* Apply interchanges to columns 1:J-1.
191*
192 CALL slaswp( j-1, a, lda, j, j+jb-1, ipiv, 1 )
193*
194 IF( j+jb.LE.n ) THEN
195*
196* Apply interchanges to columns J+JB:N.
197*
198 CALL slaswp( n-j-jb+1, a( 1, j+jb ), lda, j, j+jb-1,
199 $ ipiv, 1 )
200*
201* Compute block row of U.
202*
203 CALL strsm( 'Left', 'Lower', 'No transpose', 'Unit',
204 $ jb,
205 $ n-j-jb+1, one, a( j, j ), lda, a( j, j+jb ),
206 $ lda )
207 IF( j+jb.LE.m ) THEN
208*
209* Update trailing submatrix.
210*
211 CALL sgemm( 'No transpose', 'No transpose',
212 $ m-j-jb+1,
213 $ n-j-jb+1, jb, -one, a( j+jb, j ), lda,
214 $ a( j, j+jb ), lda, one, a( j+jb, j+jb ),
215 $ lda )
216 END IF
217 END IF
218 20 CONTINUE
219 END IF
220 RETURN
221*
222* End of SGETRF
223*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
Definition sgemm.f:188
recursive subroutine sgetrf2(m, n, a, lda, ipiv, info)
SGETRF2
Definition sgetrf2.f:113
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
subroutine slaswp(n, a, lda, k1, k2, ipiv, incx)
SLASWP performs a series of row interchanges on a general rectangular matrix.
Definition slaswp.f:113
subroutine strsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
STRSM
Definition strsm.f:181
Here is the call graph for this function:
Here is the caller graph for this function: