LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
zgbequ.f
Go to the documentation of this file.
00001 *> \brief \b ZGBEQU
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download ZGBEQU + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgbequ.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgbequ.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgbequ.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE ZGBEQU( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
00022 *                          AMAX, INFO )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       INTEGER            INFO, KL, KU, LDAB, M, N
00026 *       DOUBLE PRECISION   AMAX, COLCND, ROWCND
00027 *       ..
00028 *       .. Array Arguments ..
00029 *       DOUBLE PRECISION   C( * ), R( * )
00030 *       COMPLEX*16         AB( LDAB, * )
00031 *       ..
00032 *  
00033 *
00034 *> \par Purpose:
00035 *  =============
00036 *>
00037 *> \verbatim
00038 *>
00039 *> ZGBEQU computes row and column scalings intended to equilibrate an
00040 *> M-by-N band matrix A and reduce its condition number.  R returns the
00041 *> row scale factors and C the column scale factors, chosen to try to
00042 *> make the largest element in each row and column of the matrix B with
00043 *> elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
00044 *>
00045 *> R(i) and C(j) are restricted to be between SMLNUM = smallest safe
00046 *> number and BIGNUM = largest safe number.  Use of these scaling
00047 *> factors is not guaranteed to reduce the condition number of A but
00048 *> works well in practice.
00049 *> \endverbatim
00050 *
00051 *  Arguments:
00052 *  ==========
00053 *
00054 *> \param[in] M
00055 *> \verbatim
00056 *>          M is INTEGER
00057 *>          The number of rows of the matrix A.  M >= 0.
00058 *> \endverbatim
00059 *>
00060 *> \param[in] N
00061 *> \verbatim
00062 *>          N is INTEGER
00063 *>          The number of columns of the matrix A.  N >= 0.
00064 *> \endverbatim
00065 *>
00066 *> \param[in] KL
00067 *> \verbatim
00068 *>          KL is INTEGER
00069 *>          The number of subdiagonals within the band of A.  KL >= 0.
00070 *> \endverbatim
00071 *>
00072 *> \param[in] KU
00073 *> \verbatim
00074 *>          KU is INTEGER
00075 *>          The number of superdiagonals within the band of A.  KU >= 0.
00076 *> \endverbatim
00077 *>
00078 *> \param[in] AB
00079 *> \verbatim
00080 *>          AB is COMPLEX*16 array, dimension (LDAB,N)
00081 *>          The band matrix A, stored in rows 1 to KL+KU+1.  The j-th
00082 *>          column of A is stored in the j-th column of the array AB as
00083 *>          follows:
00084 *>          AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl).
00085 *> \endverbatim
00086 *>
00087 *> \param[in] LDAB
00088 *> \verbatim
00089 *>          LDAB is INTEGER
00090 *>          The leading dimension of the array AB.  LDAB >= KL+KU+1.
00091 *> \endverbatim
00092 *>
00093 *> \param[out] R
00094 *> \verbatim
00095 *>          R is DOUBLE PRECISION array, dimension (M)
00096 *>          If INFO = 0, or INFO > M, R contains the row scale factors
00097 *>          for A.
00098 *> \endverbatim
00099 *>
00100 *> \param[out] C
00101 *> \verbatim
00102 *>          C is DOUBLE PRECISION array, dimension (N)
00103 *>          If INFO = 0, C contains the column scale factors for A.
00104 *> \endverbatim
00105 *>
00106 *> \param[out] ROWCND
00107 *> \verbatim
00108 *>          ROWCND is DOUBLE PRECISION
00109 *>          If INFO = 0 or INFO > M, ROWCND contains the ratio of the
00110 *>          smallest R(i) to the largest R(i).  If ROWCND >= 0.1 and
00111 *>          AMAX is neither too large nor too small, it is not worth
00112 *>          scaling by R.
00113 *> \endverbatim
00114 *>
00115 *> \param[out] COLCND
00116 *> \verbatim
00117 *>          COLCND is DOUBLE PRECISION
00118 *>          If INFO = 0, COLCND contains the ratio of the smallest
00119 *>          C(i) to the largest C(i).  If COLCND >= 0.1, it is not
00120 *>          worth scaling by C.
00121 *> \endverbatim
00122 *>
00123 *> \param[out] AMAX
00124 *> \verbatim
00125 *>          AMAX is DOUBLE PRECISION
00126 *>          Absolute value of largest matrix element.  If AMAX is very
00127 *>          close to overflow or very close to underflow, the matrix
00128 *>          should be scaled.
00129 *> \endverbatim
00130 *>
00131 *> \param[out] INFO
00132 *> \verbatim
00133 *>          INFO is INTEGER
00134 *>          = 0:  successful exit
00135 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00136 *>          > 0:  if INFO = i, and i is
00137 *>                <= M:  the i-th row of A is exactly zero
00138 *>                >  M:  the (i-M)-th column of A is exactly zero
00139 *> \endverbatim
00140 *
00141 *  Authors:
00142 *  ========
00143 *
00144 *> \author Univ. of Tennessee 
00145 *> \author Univ. of California Berkeley 
00146 *> \author Univ. of Colorado Denver 
00147 *> \author NAG Ltd. 
00148 *
00149 *> \date November 2011
00150 *
00151 *> \ingroup complex16GBcomputational
00152 *
00153 *  =====================================================================
00154       SUBROUTINE ZGBEQU( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
00155      $                   AMAX, INFO )
00156 *
00157 *  -- LAPACK computational routine (version 3.4.0) --
00158 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00159 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00160 *     November 2011
00161 *
00162 *     .. Scalar Arguments ..
00163       INTEGER            INFO, KL, KU, LDAB, M, N
00164       DOUBLE PRECISION   AMAX, COLCND, ROWCND
00165 *     ..
00166 *     .. Array Arguments ..
00167       DOUBLE PRECISION   C( * ), R( * )
00168       COMPLEX*16         AB( LDAB, * )
00169 *     ..
00170 *
00171 *  =====================================================================
00172 *
00173 *     .. Parameters ..
00174       DOUBLE PRECISION   ONE, ZERO
00175       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00176 *     ..
00177 *     .. Local Scalars ..
00178       INTEGER            I, J, KD
00179       DOUBLE PRECISION   BIGNUM, RCMAX, RCMIN, SMLNUM
00180       COMPLEX*16         ZDUM
00181 *     ..
00182 *     .. External Functions ..
00183       DOUBLE PRECISION   DLAMCH
00184       EXTERNAL           DLAMCH
00185 *     ..
00186 *     .. External Subroutines ..
00187       EXTERNAL           XERBLA
00188 *     ..
00189 *     .. Intrinsic Functions ..
00190       INTRINSIC          ABS, DBLE, DIMAG, MAX, MIN
00191 *     ..
00192 *     .. Statement Functions ..
00193       DOUBLE PRECISION   CABS1
00194 *     ..
00195 *     .. Statement Function definitions ..
00196       CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
00197 *     ..
00198 *     .. Executable Statements ..
00199 *
00200 *     Test the input parameters
00201 *
00202       INFO = 0
00203       IF( M.LT.0 ) THEN
00204          INFO = -1
00205       ELSE IF( N.LT.0 ) THEN
00206          INFO = -2
00207       ELSE IF( KL.LT.0 ) THEN
00208          INFO = -3
00209       ELSE IF( KU.LT.0 ) THEN
00210          INFO = -4
00211       ELSE IF( LDAB.LT.KL+KU+1 ) THEN
00212          INFO = -6
00213       END IF
00214       IF( INFO.NE.0 ) THEN
00215          CALL XERBLA( 'ZGBEQU', -INFO )
00216          RETURN
00217       END IF
00218 *
00219 *     Quick return if possible
00220 *
00221       IF( M.EQ.0 .OR. N.EQ.0 ) THEN
00222          ROWCND = ONE
00223          COLCND = ONE
00224          AMAX = ZERO
00225          RETURN
00226       END IF
00227 *
00228 *     Get machine constants.
00229 *
00230       SMLNUM = DLAMCH( 'S' )
00231       BIGNUM = ONE / SMLNUM
00232 *
00233 *     Compute row scale factors.
00234 *
00235       DO 10 I = 1, M
00236          R( I ) = ZERO
00237    10 CONTINUE
00238 *
00239 *     Find the maximum element in each row.
00240 *
00241       KD = KU + 1
00242       DO 30 J = 1, N
00243          DO 20 I = MAX( J-KU, 1 ), MIN( J+KL, M )
00244             R( I ) = MAX( R( I ), CABS1( AB( KD+I-J, J ) ) )
00245    20    CONTINUE
00246    30 CONTINUE
00247 *
00248 *     Find the maximum and minimum scale factors.
00249 *
00250       RCMIN = BIGNUM
00251       RCMAX = ZERO
00252       DO 40 I = 1, M
00253          RCMAX = MAX( RCMAX, R( I ) )
00254          RCMIN = MIN( RCMIN, R( I ) )
00255    40 CONTINUE
00256       AMAX = RCMAX
00257 *
00258       IF( RCMIN.EQ.ZERO ) THEN
00259 *
00260 *        Find the first zero scale factor and return an error code.
00261 *
00262          DO 50 I = 1, M
00263             IF( R( I ).EQ.ZERO ) THEN
00264                INFO = I
00265                RETURN
00266             END IF
00267    50    CONTINUE
00268       ELSE
00269 *
00270 *        Invert the scale factors.
00271 *
00272          DO 60 I = 1, M
00273             R( I ) = ONE / MIN( MAX( R( I ), SMLNUM ), BIGNUM )
00274    60    CONTINUE
00275 *
00276 *        Compute ROWCND = min(R(I)) / max(R(I))
00277 *
00278          ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
00279       END IF
00280 *
00281 *     Compute column scale factors
00282 *
00283       DO 70 J = 1, N
00284          C( J ) = ZERO
00285    70 CONTINUE
00286 *
00287 *     Find the maximum element in each column,
00288 *     assuming the row scaling computed above.
00289 *
00290       KD = KU + 1
00291       DO 90 J = 1, N
00292          DO 80 I = MAX( J-KU, 1 ), MIN( J+KL, M )
00293             C( J ) = MAX( C( J ), CABS1( AB( KD+I-J, J ) )*R( I ) )
00294    80    CONTINUE
00295    90 CONTINUE
00296 *
00297 *     Find the maximum and minimum scale factors.
00298 *
00299       RCMIN = BIGNUM
00300       RCMAX = ZERO
00301       DO 100 J = 1, N
00302          RCMIN = MIN( RCMIN, C( J ) )
00303          RCMAX = MAX( RCMAX, C( J ) )
00304   100 CONTINUE
00305 *
00306       IF( RCMIN.EQ.ZERO ) THEN
00307 *
00308 *        Find the first zero scale factor and return an error code.
00309 *
00310          DO 110 J = 1, N
00311             IF( C( J ).EQ.ZERO ) THEN
00312                INFO = M + J
00313                RETURN
00314             END IF
00315   110    CONTINUE
00316       ELSE
00317 *
00318 *        Invert the scale factors.
00319 *
00320          DO 120 J = 1, N
00321             C( J ) = ONE / MIN( MAX( C( J ), SMLNUM ), BIGNUM )
00322   120    CONTINUE
00323 *
00324 *        Compute COLCND = min(C(J)) / max(C(J))
00325 *
00326          COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
00327       END IF
00328 *
00329       RETURN
00330 *
00331 *     End of ZGBEQU
00332 *
00333       END
 All Files Functions