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

◆ dgeequ()

subroutine dgeequ ( integer m,
integer n,
double precision, dimension( lda, * ) a,
integer lda,
double precision, dimension( * ) r,
double precision, dimension( * ) c,
double precision rowcnd,
double precision colcnd,
double precision amax,
integer info )

DGEEQU

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

Purpose:
!>
!> DGEEQU computes row and column scalings intended to equilibrate an
!> M-by-N matrix A and reduce its condition number.  R returns the row
!> scale factors and C the column scale factors, chosen to try to make
!> the largest element in each row and column of the matrix B with
!> elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
!>
!> R(i) and C(j) are restricted to be between SMLNUM = smallest safe
!> number and BIGNUM = largest safe number.  Use of these scaling
!> factors is not guaranteed to reduce the condition number of A but
!> works well in practice.
!> 
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]A
!>          A is DOUBLE PRECISION array, dimension (LDA,N)
!>          The M-by-N matrix whose equilibration factors are
!>          to be computed.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,M).
!> 
[out]R
!>          R is DOUBLE PRECISION array, dimension (M)
!>          If INFO = 0 or INFO > M, R contains the row scale factors
!>          for A.
!> 
[out]C
!>          C is DOUBLE PRECISION array, dimension (N)
!>          If INFO = 0,  C contains the column scale factors for A.
!> 
[out]ROWCND
!>          ROWCND is DOUBLE PRECISION
!>          If INFO = 0 or INFO > M, ROWCND contains the ratio of the
!>          smallest R(i) to the largest R(i).  If ROWCND >= 0.1 and
!>          AMAX is neither too large nor too small, it is not worth
!>          scaling by R.
!> 
[out]COLCND
!>          COLCND is DOUBLE PRECISION
!>          If INFO = 0, COLCND contains the ratio of the smallest
!>          C(i) to the largest C(i).  If COLCND >= 0.1, it is not
!>          worth scaling by C.
!> 
[out]AMAX
!>          AMAX is DOUBLE PRECISION
!>          Absolute value of largest matrix element.  If AMAX is very
!>          close to overflow or very close to underflow, the matrix
!>          should be scaled.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!>          > 0:  if INFO = i,  and i is
!>                <= M:  the i-th row of A is exactly zero
!>                >  M:  the (i-M)-th column of A is exactly zero
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 135 of file dgeequ.f.

137*
138* -- LAPACK computational routine --
139* -- LAPACK is a software package provided by Univ. of Tennessee, --
140* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
141*
142* .. Scalar Arguments ..
143 INTEGER INFO, LDA, M, N
144 DOUBLE PRECISION AMAX, COLCND, ROWCND
145* ..
146* .. Array Arguments ..
147 DOUBLE PRECISION A( LDA, * ), C( * ), R( * )
148* ..
149*
150* =====================================================================
151*
152* .. Parameters ..
153 DOUBLE PRECISION ONE, ZERO
154 parameter( one = 1.0d+0, zero = 0.0d+0 )
155* ..
156* .. Local Scalars ..
157 INTEGER I, J
158 DOUBLE PRECISION BIGNUM, RCMAX, RCMIN, SMLNUM
159* ..
160* .. External Functions ..
161 DOUBLE PRECISION DLAMCH
162 EXTERNAL dlamch
163* ..
164* .. External Subroutines ..
165 EXTERNAL xerbla
166* ..
167* .. Intrinsic Functions ..
168 INTRINSIC abs, max, min
169* ..
170* .. Executable Statements ..
171*
172* Test the input parameters.
173*
174 info = 0
175 IF( m.LT.0 ) THEN
176 info = -1
177 ELSE IF( n.LT.0 ) THEN
178 info = -2
179 ELSE IF( lda.LT.max( 1, m ) ) THEN
180 info = -4
181 END IF
182 IF( info.NE.0 ) THEN
183 CALL xerbla( 'DGEEQU', -info )
184 RETURN
185 END IF
186*
187* Quick return if possible
188*
189 IF( m.EQ.0 .OR. n.EQ.0 ) THEN
190 rowcnd = one
191 colcnd = one
192 amax = zero
193 RETURN
194 END IF
195*
196* Get machine constants.
197*
198 smlnum = dlamch( 'S' )
199 bignum = one / smlnum
200*
201* Compute row scale factors.
202*
203 DO 10 i = 1, m
204 r( i ) = zero
205 10 CONTINUE
206*
207* Find the maximum element in each row.
208*
209 DO 30 j = 1, n
210 DO 20 i = 1, m
211 r( i ) = max( r( i ), abs( a( i, j ) ) )
212 20 CONTINUE
213 30 CONTINUE
214*
215* Find the maximum and minimum scale factors.
216*
217 rcmin = bignum
218 rcmax = zero
219 DO 40 i = 1, m
220 rcmax = max( rcmax, r( i ) )
221 rcmin = min( rcmin, r( i ) )
222 40 CONTINUE
223 amax = rcmax
224*
225 IF( rcmin.EQ.zero ) THEN
226*
227* Find the first zero scale factor and return an error code.
228*
229 DO 50 i = 1, m
230 IF( r( i ).EQ.zero ) THEN
231 info = i
232 RETURN
233 END IF
234 50 CONTINUE
235 ELSE
236*
237* Invert the scale factors.
238*
239 DO 60 i = 1, m
240 r( i ) = one / min( max( r( i ), smlnum ), bignum )
241 60 CONTINUE
242*
243* Compute ROWCND = min(R(I)) / max(R(I))
244*
245 rowcnd = max( rcmin, smlnum ) / min( rcmax, bignum )
246 END IF
247*
248* Compute column scale factors
249*
250 DO 70 j = 1, n
251 c( j ) = zero
252 70 CONTINUE
253*
254* Find the maximum element in each column,
255* assuming the row scaling computed above.
256*
257 DO 90 j = 1, n
258 DO 80 i = 1, m
259 c( j ) = max( c( j ), abs( a( i, j ) )*r( i ) )
260 80 CONTINUE
261 90 CONTINUE
262*
263* Find the maximum and minimum scale factors.
264*
265 rcmin = bignum
266 rcmax = zero
267 DO 100 j = 1, n
268 rcmin = min( rcmin, c( j ) )
269 rcmax = max( rcmax, c( j ) )
270 100 CONTINUE
271*
272 IF( rcmin.EQ.zero ) THEN
273*
274* Find the first zero scale factor and return an error code.
275*
276 DO 110 j = 1, n
277 IF( c( j ).EQ.zero ) THEN
278 info = m + j
279 RETURN
280 END IF
281 110 CONTINUE
282 ELSE
283*
284* Invert the scale factors.
285*
286 DO 120 j = 1, n
287 c( j ) = one / min( max( c( j ), smlnum ), bignum )
288 120 CONTINUE
289*
290* Compute COLCND = min(C(J)) / max(C(J))
291*
292 colcnd = max( rcmin, smlnum ) / min( rcmax, bignum )
293 END IF
294*
295 RETURN
296*
297* End of DGEEQU
298*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
Here is the call graph for this function:
Here is the caller graph for this function: