LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine sgetc2 ( integer  N,
real, dimension( lda, * )  A,
integer  LDA,
integer, dimension( * )  IPIV,
integer, dimension( * )  JPIV,
integer  INFO 
)

SGETC2 computes the LU factorization with complete pivoting of the general n-by-n matrix.

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

Purpose:
 SGETC2 computes an LU factorization with complete pivoting of the
 n-by-n matrix A. The factorization has the form A = P * L * U * Q,
 where P and Q are permutation matrices, L is lower triangular with
 unit diagonal elements and U is upper triangular.

 This is the Level 2 BLAS algorithm.
Parameters
[in]N
          N is INTEGER
          The order of the matrix A. N >= 0.
[in,out]A
          A is REAL array, dimension (LDA, N)
          On entry, the n-by-n matrix A to be factored.
          On exit, the factors L and U from the factorization
          A = P*L*U*Q; the unit diagonal elements of L are not stored.
          If U(k, k) appears to be less than SMIN, U(k, k) is given the
          value of SMIN, i.e., giving a nonsingular perturbed system.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[out]IPIV
          IPIV is INTEGER array, dimension(N).
          The pivot indices; for 1 <= i <= N, row i of the
          matrix has been interchanged with row IPIV(i).
[out]JPIV
          JPIV is INTEGER array, dimension(N).
          The pivot indices; for 1 <= j <= N, column j of the
          matrix has been interchanged with column JPIV(j).
[out]INFO
          INFO is INTEGER
           = 0: successful exit
           > 0: if INFO = k, U(k, k) is likely to produce owerflow if
                we try to solve for x in Ax = b. So U is perturbed to
                avoid the overflow.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
June 2016
Contributors:
Bo Kagstrom and Peter Poromaa, Department of Computing Science, Umea University, S-901 87 Umea, Sweden.

Definition at line 113 of file sgetc2.f.

113 *
114 * -- LAPACK auxiliary routine (version 3.6.1) --
115 * -- LAPACK is a software package provided by Univ. of Tennessee, --
116 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
117 * June 2016
118 *
119 * .. Scalar Arguments ..
120  INTEGER info, lda, n
121 * ..
122 * .. Array Arguments ..
123  INTEGER ipiv( * ), jpiv( * )
124  REAL a( lda, * )
125 * ..
126 *
127 * =====================================================================
128 *
129 * .. Parameters ..
130  REAL zero, one
131  parameter ( zero = 0.0e+0, one = 1.0e+0 )
132 * ..
133 * .. Local Scalars ..
134  INTEGER i, ip, ipv, j, jp, jpv
135  REAL bignum, eps, smin, smlnum, xmax
136 * ..
137 * .. External Subroutines ..
138  EXTERNAL sger, slabad, sswap
139 * ..
140 * .. External Functions ..
141  REAL slamch
142  EXTERNAL slamch
143 * ..
144 * .. Intrinsic Functions ..
145  INTRINSIC abs, max
146 * ..
147 * .. Executable Statements ..
148 *
149  info = 0
150 *
151 * Quick return if possible
152 *
153  IF( n.EQ.0 )
154  $ RETURN
155 *
156 * Set constants to control overflow
157 *
158  eps = slamch( 'P' )
159  smlnum = slamch( 'S' ) / eps
160  bignum = one / smlnum
161  CALL slabad( smlnum, bignum )
162 *
163 * Handle the case N=1 by itself
164 *
165  IF( n.EQ.1 ) THEN
166  ipiv( 1 ) = 1
167  jpiv( 1 ) = 1
168  IF( abs( a( 1, 1 ) ).LT.smlnum ) THEN
169  info = 1
170  a( 1, 1 ) = smlnum
171  END IF
172  RETURN
173  END IF
174 *
175 * Factorize A using complete pivoting.
176 * Set pivots less than SMIN to SMIN.
177 *
178  DO 40 i = 1, n - 1
179 *
180 * Find max element in matrix A
181 *
182  xmax = zero
183  DO 20 ip = i, n
184  DO 10 jp = i, n
185  IF( abs( a( ip, jp ) ).GE.xmax ) THEN
186  xmax = abs( a( ip, jp ) )
187  ipv = ip
188  jpv = jp
189  END IF
190  10 CONTINUE
191  20 CONTINUE
192  IF( i.EQ.1 )
193  $ smin = max( eps*xmax, smlnum )
194 *
195 * Swap rows
196 *
197  IF( ipv.NE.i )
198  $ CALL sswap( n, a( ipv, 1 ), lda, a( i, 1 ), lda )
199  ipiv( i ) = ipv
200 *
201 * Swap columns
202 *
203  IF( jpv.NE.i )
204  $ CALL sswap( n, a( 1, jpv ), 1, a( 1, i ), 1 )
205  jpiv( i ) = jpv
206 *
207 * Check for singularity
208 *
209  IF( abs( a( i, i ) ).LT.smin ) THEN
210  info = i
211  a( i, i ) = smin
212  END IF
213  DO 30 j = i + 1, n
214  a( j, i ) = a( j, i ) / a( i, i )
215  30 CONTINUE
216  CALL sger( n-i, n-i, -one, a( i+1, i ), 1, a( i, i+1 ), lda,
217  $ a( i+1, i+1 ), lda )
218  40 CONTINUE
219 *
220  IF( abs( a( n, n ) ).LT.smin ) THEN
221  info = n
222  a( n, n ) = smin
223  END IF
224 *
225 * Set last pivots to N
226 *
227  ipiv( n ) = n
228  jpiv( n ) = n
229 *
230  RETURN
231 *
232 * End of SGETC2
233 *
subroutine sger(M, N, ALPHA, X, INCX, Y, INCY, A, LDA)
SGER
Definition: sger.f:132
subroutine slabad(SMALL, LARGE)
SLABAD
Definition: slabad.f:76
subroutine sswap(N, SX, INCX, SY, INCY)
SSWAP
Definition: sswap.f:53
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69

Here is the call graph for this function:

Here is the caller graph for this function: