File:  [local] / rpl / lapack / lapack / zgeequ.f
Revision 1.17: download - view: text, annotated - select for diffs - revision graph
Mon Aug 7 08:39:16 2023 UTC (8 months, 3 weeks ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_35, rpl-4_1_34, HEAD
Première mise à jour de lapack et blas.

    1: *> \brief \b ZGEEQU
    2: *
    3: *  =========== DOCUMENTATION ===========
    4: *
    5: * Online html documentation available at
    6: *            http://www.netlib.org/lapack/explore-html/
    7: *
    8: *> \htmlonly
    9: *> Download ZGEEQU + dependencies
   10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeequ.f">
   11: *> [TGZ]</a>
   12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeequ.f">
   13: *> [ZIP]</a>
   14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeequ.f">
   15: *> [TXT]</a>
   16: *> \endhtmlonly
   17: *
   18: *  Definition:
   19: *  ===========
   20: *
   21: *       SUBROUTINE ZGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
   22: *                          INFO )
   23: *
   24: *       .. Scalar Arguments ..
   25: *       INTEGER            INFO, LDA, M, N
   26: *       DOUBLE PRECISION   AMAX, COLCND, ROWCND
   27: *       ..
   28: *       .. Array Arguments ..
   29: *       DOUBLE PRECISION   C( * ), R( * )
   30: *       COMPLEX*16         A( LDA, * )
   31: *       ..
   32: *
   33: *
   34: *> \par Purpose:
   35: *  =============
   36: *>
   37: *> \verbatim
   38: *>
   39: *> ZGEEQU computes row and column scalings intended to equilibrate an
   40: *> M-by-N matrix A and reduce its condition number.  R returns the row
   41: *> scale factors and C the column scale factors, chosen to try to make
   42: *> the largest element in each row and column of the matrix B with
   43: *> elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
   44: *>
   45: *> R(i) and C(j) are restricted to be between SMLNUM = smallest safe
   46: *> number and BIGNUM = largest safe number.  Use of these scaling
   47: *> factors is not guaranteed to reduce the condition number of A but
   48: *> works well in practice.
   49: *> \endverbatim
   50: *
   51: *  Arguments:
   52: *  ==========
   53: *
   54: *> \param[in] M
   55: *> \verbatim
   56: *>          M is INTEGER
   57: *>          The number of rows of the matrix A.  M >= 0.
   58: *> \endverbatim
   59: *>
   60: *> \param[in] N
   61: *> \verbatim
   62: *>          N is INTEGER
   63: *>          The number of columns of the matrix A.  N >= 0.
   64: *> \endverbatim
   65: *>
   66: *> \param[in] A
   67: *> \verbatim
   68: *>          A is COMPLEX*16 array, dimension (LDA,N)
   69: *>          The M-by-N matrix whose equilibration factors are
   70: *>          to be computed.
   71: *> \endverbatim
   72: *>
   73: *> \param[in] LDA
   74: *> \verbatim
   75: *>          LDA is INTEGER
   76: *>          The leading dimension of the array A.  LDA >= max(1,M).
   77: *> \endverbatim
   78: *>
   79: *> \param[out] R
   80: *> \verbatim
   81: *>          R is DOUBLE PRECISION array, dimension (M)
   82: *>          If INFO = 0 or INFO > M, R contains the row scale factors
   83: *>          for A.
   84: *> \endverbatim
   85: *>
   86: *> \param[out] C
   87: *> \verbatim
   88: *>          C is DOUBLE PRECISION array, dimension (N)
   89: *>          If INFO = 0,  C contains the column scale factors for A.
   90: *> \endverbatim
   91: *>
   92: *> \param[out] ROWCND
   93: *> \verbatim
   94: *>          ROWCND is DOUBLE PRECISION
   95: *>          If INFO = 0 or INFO > M, ROWCND contains the ratio of the
   96: *>          smallest R(i) to the largest R(i).  If ROWCND >= 0.1 and
   97: *>          AMAX is neither too large nor too small, it is not worth
   98: *>          scaling by R.
   99: *> \endverbatim
  100: *>
  101: *> \param[out] COLCND
  102: *> \verbatim
  103: *>          COLCND is DOUBLE PRECISION
  104: *>          If INFO = 0, COLCND contains the ratio of the smallest
  105: *>          C(i) to the largest C(i).  If COLCND >= 0.1, it is not
  106: *>          worth scaling by C.
  107: *> \endverbatim
  108: *>
  109: *> \param[out] AMAX
  110: *> \verbatim
  111: *>          AMAX is DOUBLE PRECISION
  112: *>          Absolute value of largest matrix element.  If AMAX is very
  113: *>          close to overflow or very close to underflow, the matrix
  114: *>          should be scaled.
  115: *> \endverbatim
  116: *>
  117: *> \param[out] INFO
  118: *> \verbatim
  119: *>          INFO is INTEGER
  120: *>          = 0:  successful exit
  121: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
  122: *>          > 0:  if INFO = i,  and i is
  123: *>                <= M:  the i-th row of A is exactly zero
  124: *>                >  M:  the (i-M)-th column of A is exactly zero
  125: *> \endverbatim
  126: *
  127: *  Authors:
  128: *  ========
  129: *
  130: *> \author Univ. of Tennessee
  131: *> \author Univ. of California Berkeley
  132: *> \author Univ. of Colorado Denver
  133: *> \author NAG Ltd.
  134: *
  135: *> \ingroup complex16GEcomputational
  136: *
  137: *  =====================================================================
  138:       SUBROUTINE ZGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
  139:      $                   INFO )
  140: *
  141: *  -- LAPACK computational routine --
  142: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
  143: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  144: *
  145: *     .. Scalar Arguments ..
  146:       INTEGER            INFO, LDA, M, N
  147:       DOUBLE PRECISION   AMAX, COLCND, ROWCND
  148: *     ..
  149: *     .. Array Arguments ..
  150:       DOUBLE PRECISION   C( * ), R( * )
  151:       COMPLEX*16         A( LDA, * )
  152: *     ..
  153: *
  154: *  =====================================================================
  155: *
  156: *     .. Parameters ..
  157:       DOUBLE PRECISION   ONE, ZERO
  158:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  159: *     ..
  160: *     .. Local Scalars ..
  161:       INTEGER            I, J
  162:       DOUBLE PRECISION   BIGNUM, RCMAX, RCMIN, SMLNUM
  163:       COMPLEX*16         ZDUM
  164: *     ..
  165: *     .. External Functions ..
  166:       DOUBLE PRECISION   DLAMCH
  167:       EXTERNAL           DLAMCH
  168: *     ..
  169: *     .. External Subroutines ..
  170:       EXTERNAL           XERBLA
  171: *     ..
  172: *     .. Intrinsic Functions ..
  173:       INTRINSIC          ABS, DBLE, DIMAG, MAX, MIN
  174: *     ..
  175: *     .. Statement Functions ..
  176:       DOUBLE PRECISION   CABS1
  177: *     ..
  178: *     .. Statement Function definitions ..
  179:       CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
  180: *     ..
  181: *     .. Executable Statements ..
  182: *
  183: *     Test the input parameters.
  184: *
  185:       INFO = 0
  186:       IF( M.LT.0 ) THEN
  187:          INFO = -1
  188:       ELSE IF( N.LT.0 ) THEN
  189:          INFO = -2
  190:       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
  191:          INFO = -4
  192:       END IF
  193:       IF( INFO.NE.0 ) THEN
  194:          CALL XERBLA( 'ZGEEQU', -INFO )
  195:          RETURN
  196:       END IF
  197: *
  198: *     Quick return if possible
  199: *
  200:       IF( M.EQ.0 .OR. N.EQ.0 ) THEN
  201:          ROWCND = ONE
  202:          COLCND = ONE
  203:          AMAX = ZERO
  204:          RETURN
  205:       END IF
  206: *
  207: *     Get machine constants.
  208: *
  209:       SMLNUM = DLAMCH( 'S' )
  210:       BIGNUM = ONE / SMLNUM
  211: *
  212: *     Compute row scale factors.
  213: *
  214:       DO 10 I = 1, M
  215:          R( I ) = ZERO
  216:    10 CONTINUE
  217: *
  218: *     Find the maximum element in each row.
  219: *
  220:       DO 30 J = 1, N
  221:          DO 20 I = 1, M
  222:             R( I ) = MAX( R( I ), CABS1( A( I, J ) ) )
  223:    20    CONTINUE
  224:    30 CONTINUE
  225: *
  226: *     Find the maximum and minimum scale factors.
  227: *
  228:       RCMIN = BIGNUM
  229:       RCMAX = ZERO
  230:       DO 40 I = 1, M
  231:          RCMAX = MAX( RCMAX, R( I ) )
  232:          RCMIN = MIN( RCMIN, R( I ) )
  233:    40 CONTINUE
  234:       AMAX = RCMAX
  235: *
  236:       IF( RCMIN.EQ.ZERO ) THEN
  237: *
  238: *        Find the first zero scale factor and return an error code.
  239: *
  240:          DO 50 I = 1, M
  241:             IF( R( I ).EQ.ZERO ) THEN
  242:                INFO = I
  243:                RETURN
  244:             END IF
  245:    50    CONTINUE
  246:       ELSE
  247: *
  248: *        Invert the scale factors.
  249: *
  250:          DO 60 I = 1, M
  251:             R( I ) = ONE / MIN( MAX( R( I ), SMLNUM ), BIGNUM )
  252:    60    CONTINUE
  253: *
  254: *        Compute ROWCND = min(R(I)) / max(R(I))
  255: *
  256:          ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
  257:       END IF
  258: *
  259: *     Compute column scale factors
  260: *
  261:       DO 70 J = 1, N
  262:          C( J ) = ZERO
  263:    70 CONTINUE
  264: *
  265: *     Find the maximum element in each column,
  266: *     assuming the row scaling computed above.
  267: *
  268:       DO 90 J = 1, N
  269:          DO 80 I = 1, M
  270:             C( J ) = MAX( C( J ), CABS1( A( I, J ) )*R( I ) )
  271:    80    CONTINUE
  272:    90 CONTINUE
  273: *
  274: *     Find the maximum and minimum scale factors.
  275: *
  276:       RCMIN = BIGNUM
  277:       RCMAX = ZERO
  278:       DO 100 J = 1, N
  279:          RCMIN = MIN( RCMIN, C( J ) )
  280:          RCMAX = MAX( RCMAX, C( J ) )
  281:   100 CONTINUE
  282: *
  283:       IF( RCMIN.EQ.ZERO ) THEN
  284: *
  285: *        Find the first zero scale factor and return an error code.
  286: *
  287:          DO 110 J = 1, N
  288:             IF( C( J ).EQ.ZERO ) THEN
  289:                INFO = M + J
  290:                RETURN
  291:             END IF
  292:   110    CONTINUE
  293:       ELSE
  294: *
  295: *        Invert the scale factors.
  296: *
  297:          DO 120 J = 1, N
  298:             C( J ) = ONE / MIN( MAX( C( J ), SMLNUM ), BIGNUM )
  299:   120    CONTINUE
  300: *
  301: *        Compute COLCND = min(C(J)) / max(C(J))
  302: *
  303:          COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
  304:       END IF
  305: *
  306:       RETURN
  307: *
  308: *     End of ZGEEQU
  309: *
  310:       END

CVSweb interface <joel.bertrand@systella.fr>