LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ cgbequ()

subroutine cgbequ ( integer  M,
integer  N,
integer  KL,
integer  KU,
complex, dimension( ldab, * )  AB,
integer  LDAB,
real, dimension( * )  R,
real, dimension( * )  C,
real  ROWCND,
real  COLCND,
real  AMAX,
integer  INFO 
)

CGBEQU

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

Purpose:
 CGBEQU computes row and column scalings intended to equilibrate an
 M-by-N band 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]KL
          KL is INTEGER
          The number of subdiagonals within the band of A.  KL >= 0.
[in]KU
          KU is INTEGER
          The number of superdiagonals within the band of A.  KU >= 0.
[in]AB
          AB is COMPLEX array, dimension (LDAB,N)
          The band matrix A, stored in rows 1 to KL+KU+1.  The j-th
          column of A is stored in the j-th column of the array AB as
          follows:
          AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl).
[in]LDAB
          LDAB is INTEGER
          The leading dimension of the array AB.  LDAB >= KL+KU+1.
[out]R
          R is REAL array, dimension (M)
          If INFO = 0, or INFO > M, R contains the row scale factors
          for A.
[out]C
          C is REAL array, dimension (N)
          If INFO = 0, C contains the column scale factors for A.
[out]ROWCND
          ROWCND is REAL
          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 REAL
          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 REAL
          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.
Date
December 2016

Definition at line 156 of file cgbequ.f.

156 *
157 * -- LAPACK computational routine (version 3.7.0) --
158 * -- LAPACK is a software package provided by Univ. of Tennessee, --
159 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
160 * December 2016
161 *
162 * .. Scalar Arguments ..
163  INTEGER info, kl, ku, ldab, m, n
164  REAL amax, colcnd, rowcnd
165 * ..
166 * .. Array Arguments ..
167  REAL c( * ), r( * )
168  COMPLEX ab( ldab, * )
169 * ..
170 *
171 * =====================================================================
172 *
173 * .. Parameters ..
174  REAL one, zero
175  parameter( one = 1.0e+0, zero = 0.0e+0 )
176 * ..
177 * .. Local Scalars ..
178  INTEGER i, j, kd
179  REAL bignum, rcmax, rcmin, smlnum
180  COMPLEX zdum
181 * ..
182 * .. External Functions ..
183  REAL slamch
184  EXTERNAL slamch
185 * ..
186 * .. External Subroutines ..
187  EXTERNAL xerbla
188 * ..
189 * .. Intrinsic Functions ..
190  INTRINSIC abs, aimag, max, min, real
191 * ..
192 * .. Statement Functions ..
193  REAL cabs1
194 * ..
195 * .. Statement Function definitions ..
196  cabs1( zdum ) = abs( REAL( ZDUM ) ) + abs( aimag( zdum ) )
197 * ..
198 * .. Executable Statements ..
199 *
200 * Test the input parameters
201 *
202  info = 0
203  IF( m.LT.0 ) THEN
204  info = -1
205  ELSE IF( n.LT.0 ) THEN
206  info = -2
207  ELSE IF( kl.LT.0 ) THEN
208  info = -3
209  ELSE IF( ku.LT.0 ) THEN
210  info = -4
211  ELSE IF( ldab.LT.kl+ku+1 ) THEN
212  info = -6
213  END IF
214  IF( info.NE.0 ) THEN
215  CALL xerbla( 'CGBEQU', -info )
216  RETURN
217  END IF
218 *
219 * Quick return if possible
220 *
221  IF( m.EQ.0 .OR. n.EQ.0 ) THEN
222  rowcnd = one
223  colcnd = one
224  amax = zero
225  RETURN
226  END IF
227 *
228 * Get machine constants.
229 *
230  smlnum = slamch( 'S' )
231  bignum = one / smlnum
232 *
233 * Compute row scale factors.
234 *
235  DO 10 i = 1, m
236  r( i ) = zero
237  10 CONTINUE
238 *
239 * Find the maximum element in each row.
240 *
241  kd = ku + 1
242  DO 30 j = 1, n
243  DO 20 i = max( j-ku, 1 ), min( j+kl, m )
244  r( i ) = max( r( i ), cabs1( ab( kd+i-j, j ) ) )
245  20 CONTINUE
246  30 CONTINUE
247 *
248 * Find the maximum and minimum scale factors.
249 *
250  rcmin = bignum
251  rcmax = zero
252  DO 40 i = 1, m
253  rcmax = max( rcmax, r( i ) )
254  rcmin = min( rcmin, r( i ) )
255  40 CONTINUE
256  amax = rcmax
257 *
258  IF( rcmin.EQ.zero ) THEN
259 *
260 * Find the first zero scale factor and return an error code.
261 *
262  DO 50 i = 1, m
263  IF( r( i ).EQ.zero ) THEN
264  info = i
265  RETURN
266  END IF
267  50 CONTINUE
268  ELSE
269 *
270 * Invert the scale factors.
271 *
272  DO 60 i = 1, m
273  r( i ) = one / min( max( r( i ), smlnum ), bignum )
274  60 CONTINUE
275 *
276 * Compute ROWCND = min(R(I)) / max(R(I))
277 *
278  rowcnd = max( rcmin, smlnum ) / min( rcmax, bignum )
279  END IF
280 *
281 * Compute column scale factors
282 *
283  DO 70 j = 1, n
284  c( j ) = zero
285  70 CONTINUE
286 *
287 * Find the maximum element in each column,
288 * assuming the row scaling computed above.
289 *
290  kd = ku + 1
291  DO 90 j = 1, n
292  DO 80 i = max( j-ku, 1 ), min( j+kl, m )
293  c( j ) = max( c( j ), cabs1( ab( kd+i-j, j ) )*r( i ) )
294  80 CONTINUE
295  90 CONTINUE
296 *
297 * Find the maximum and minimum scale factors.
298 *
299  rcmin = bignum
300  rcmax = zero
301  DO 100 j = 1, n
302  rcmin = min( rcmin, c( j ) )
303  rcmax = max( rcmax, c( j ) )
304  100 CONTINUE
305 *
306  IF( rcmin.EQ.zero ) THEN
307 *
308 * Find the first zero scale factor and return an error code.
309 *
310  DO 110 j = 1, n
311  IF( c( j ).EQ.zero ) THEN
312  info = m + j
313  RETURN
314  END IF
315  110 CONTINUE
316  ELSE
317 *
318 * Invert the scale factors.
319 *
320  DO 120 j = 1, n
321  c( j ) = one / min( max( c( j ), smlnum ), bignum )
322  120 CONTINUE
323 *
324 * Compute COLCND = min(C(J)) / max(C(J))
325 *
326  colcnd = max( rcmin, smlnum ) / min( rcmax, bignum )
327  END IF
328 *
329  RETURN
330 *
331 * End of CGBEQU
332 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
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: