MB04MD

Balancing a general real matrix

[Specification] [Arguments] [Method] [References] [Comments] [Example]

Purpose

  To reduce the 1-norm of a general real matrix A by balancing.
  This involves diagonal similarity transformations applied
  iteratively to A to make the rows and columns as close in norm as
  possible.

  This routine can be used instead LAPACK Library routine DGEBAL,
  when no reduction of the 1-norm of the matrix is possible with
  DGEBAL, as for upper triangular matrices. LAPACK Library routine
  DGEBAK, with parameters ILO = 1, IHI = N, and JOB = 'S', should
  be used to apply the backward transformation.

Specification
      SUBROUTINE MB04MD( N, MAXRED, A, LDA, SCALE, INFO )
C     .. Scalar Arguments ..
      INTEGER            INFO, LDA, N
      DOUBLE PRECISION   MAXRED
C     .. Array Arguments ..
      DOUBLE PRECISION   A( LDA, * ), SCALE( * )

Arguments

Input/Output Parameters

  N       (input) INTEGER
          The order of the matrix A.  N >= 0.

  MAXRED  (input/output) DOUBLE PRECISION
          On entry, the maximum allowed reduction in the 1-norm of
          A (in an iteration) if zero rows or columns are
          encountered.
          If MAXRED > 0.0, MAXRED must be larger than one (to enable
          the norm reduction).
          If MAXRED <= 0.0, then the value 10.0 for MAXRED is
          used.
          On exit, if the 1-norm of the given matrix A is non-zero,
          the ratio between the 1-norm of the given matrix and the
          1-norm of the balanced matrix. Usually, this ratio will be
          larger than one, but it can sometimes be one, or even less
          than one (for instance, for some companion matrices).

  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
          On entry, the leading N-by-N part of this array must
          contain the input matrix A.
          On exit, the leading N-by-N part of this array contains
          the balanced matrix.

  LDA     INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).

  SCALE   (output) DOUBLE PRECISION array, dimension (N)
          The scaling factors applied to A.  If D(j) is the scaling
          factor applied to row and column j, then SCALE(j) = D(j),
          for j = 1,...,N.

Error Indicator
  INFO    INTEGER
          = 0:  successful exit.
          < 0:  if INFO = -i, the i-th argument had an illegal
                value.

Method
  Balancing consists of applying a diagonal similarity
  transformation inv(D) * A * D to make the 1-norms of each row
  of A and its corresponding column nearly equal.

  Information about the diagonal matrix D is returned in the vector
  SCALE.

References
  [1] Anderson, E., Bai, Z., Bischof, C., Demmel, J., Dongarra, J.,
      Du Croz, J., Greenbaum, A., Hammarling, S., McKenney, A.,
      Ostrouchov, S., and Sorensen, D.
      LAPACK Users' Guide: Second Edition.
      SIAM, Philadelphia, 1995.

Numerical Aspects
  None.

Further Comments
  None
Example

Program Text

*     MB04MD EXAMPLE PROGRAM TEXT.
*     Copyright (c) 2002-2017 NICONET e.V.
*
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        ( NIN = 5, NOUT = 6 )
      INTEGER          NMAX
      PARAMETER        ( NMAX = 20 )
      INTEGER          LDA
      PARAMETER        ( LDA = NMAX )
*     .. Local Scalars ..
      INTEGER          I, INFO, J, N
      DOUBLE PRECISION MAXRED
*     .. Local Arrays ..
      DOUBLE PRECISION A(LDA,NMAX), SCALE(NMAX)
*     .. External Subroutines ..
      EXTERNAL         MB04MD
*     .. Executable Statements ..
*
      WRITE ( NOUT, FMT = 99999 )
*     Skip the heading in the data file and read the data.
      READ ( NIN, FMT = '()' )
      READ ( NIN, FMT = * ) N, MAXRED
      IF ( N.LE.0 .OR. N.GT.NMAX ) THEN
         WRITE ( NOUT, FMT = 99993 ) N
      ELSE
         READ ( NIN, FMT = * ) ( ( A(I,J), J = 1,N ), I = 1,N )
*        Balance matrix A.
         CALL MB04MD( N, MAXRED, A, LDA, SCALE, INFO )
*
         IF ( INFO.NE.0 ) THEN
            WRITE ( NOUT, FMT = 99998 ) INFO
         ELSE
            WRITE ( NOUT, FMT = 99997 )
            DO 20 I = 1, N
               WRITE ( NOUT, FMT = 99996 ) ( A(I,J), J = 1,N )
   20       CONTINUE
            WRITE ( NOUT, FMT = 99994 ) ( SCALE(I), I = 1,N )
         END IF
      END IF
      STOP
*
99999 FORMAT (' MB04MD EXAMPLE PROGRAM RESULTS',/1X)
99998 FORMAT (' INFO on exit from MB04MD = ',I2)
99997 FORMAT (' The balanced matrix is ')
99996 FORMAT (20(1X,F10.4))
99994 FORMAT (/' SCALE is ',/20(1X,F10.4))
99993 FORMAT (/' N is out of range.',/' N = ',I5)
      END
Program Data
 MB04MD EXAMPLE PROGRAM DATA
   4    0.0
   1.0   0.0   0.0   0.0
 300.0 400.0 500.0 600.0
   1.0   2.0   0.0   0.0
   1.0   1.0   1.0   1.0
Program Results
 MB04MD EXAMPLE PROGRAM RESULTS

 The balanced matrix is 
     1.0000     0.0000     0.0000     0.0000
    30.0000   400.0000    50.0000    60.0000
     1.0000    20.0000     0.0000     0.0000
     1.0000    10.0000     1.0000     1.0000

 SCALE is 
     1.0000    10.0000     1.0000     1.0000

Return to index