Previous Next Contents Generated Index Doc Set Home



Equilibration Scale Factors for a General Matrix

The subroutines described in this section compute row and column scalings intended to equilibrate a general matrix A and reduce its condition number. The scale factors are chosen to try to make largest element of the equilibrated matrix have magnitude equal to 1. Note that these subroutines only compute the scale factors for A. Additional code must be written to actually equilibrate A. Each element of the equilibrated matrix B has the value B(i,j) = ROWSC(i) × B(i,j) × COLSC(j).

Calling Sequence

CALL DGEEQU 
(M, N, DA, LDA, DROWSC, DCOLSC, DROWCN, DCOLCN, DAMAX, 
INFO)
CALL SGEEQU 
(M, N, SA, LDA, SROWSC, SCOLSC, SROWCN, SCOLCN, SAMAX, 
INFO)
CALL ZGEEQU 
(M, N, ZA, LDA, DROWSC, DCOLSC, DROWCN, DCOLCN, DAMAX, 
INFO)
CALL CGEEQU 
(M, N, CA, LDA, SROWSC, SCOLSC, SROWCN, SCOLCN, SAMAX, 
INFO)






void dgeequ 
(int m, int n, double *da, int lda, double *drowsc, 
double *dcolsc, double *drowcn, double *dcolcn, double 
*damax, int *info)
void sgeequ 
(int m, int n, float *sa, int lda, float *srowsc, float 
*scolsc, float *srowcn, float *scolcn, float *samax, 
int *info)
void zgeequ 
(int m, int n, doublecomplex *za, int lda, double 
*drowcn, double *dcolcn,double *drowcn, double 
*dcolcn, double *damax, int *info)
void cgeequ 
(int m, int n, complex *ca, int lda, float *srowsc, 
float *scolsc, float *srowcn, float *scolcn, float 
*samax, int *info)

Arguments

M

Number of rows in the matrix A. M 0.

N

Number of columns in the matrix A. N 0.

xA

Matrix A.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA max(1, M).

xROWSC

On exit, if INFO = 0 or INFO > M, ROWSC contains the row scale factors for the matrix A.

xCOLSC

On exit, if INFO = 0, COLSC contains the column scale factors for the matrix A.

xROWCN

On exit, if INFO = 0 or INFO > M, ROWCN contains the ratio of the smallest ROWSC(i) to the largest ROWSC(i). If ROWCN 0.1 and AMAX is not close to overflow or underflow, then it is not worth scaling by ROWSC.

xCOLCN

On exit, if INFO = 0, COLCN contains the ratio of the smallest COLSC(i) to the largest COLSC(i).

If COLCN 0.1 and AMAX is not close to overflow or underflow, then it is not worth scaling by COLSC.

xAMAX

On exit, the absolute value of the largest element of A. If AMAX is very close to overflow or underflow, A should be scaled regardless of the value of ROWCN or COLCN.

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

The ith argument, where i = |INFO|, had an illegal value.

1 INFO M

Row INFO of the array A is exactly zero.

INFO > M

Column (INFO - M) of the array A is exactly zero.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDA, N
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
C
      DOUBLE PRECISION  A(LDA,N), AMAX, COLSCA(N), COLCND
      DOUBLE PRECISION  ROWCND, ROWSCA(N)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DGEEQU
      INTRINSIC         ABS
C
C     Initialize the array A to store the 3x3 matrix A shown
C     below.
C
C         2   4   8
C     A = 2   8  16
C         2  16  32
C
      DATA A / 2.0D0, 2.0D0, 2.0D0, 4.0D0, 8.0D0, 1.6D1,
     $         8.0D0, 1.6D1, 3.2D1 /
C
C     Print the initial value of A.
C
      PRINT 1000
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, LDA)
C
C     Compute and print the scale factors that will 
C     equilibrate A.
C
      CALL DGEEQU (N, N, A, LDA, ROWSCA, COLSCA, ROWCND, COLCND,
     $             AMAX, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1020, ABS(INFO)
        STOP 1
      ELSE IF (INFO .GT. N) THEN
        PRINT 1030, INFO - N
        STOP 2
      ELSE IF (INFO .GT. 0) THEN
        PRINT 1040, INFO
        STOP 3
      END IF
      PRINT 1050
      PRINT 1010, ROWSCA
      PRINT 1060
      PRINT 1010, COLSCA
C
C     Use the scale factors to equilibrate A and print the 
C     equilibrated A.
C
      DO 110, ICOL = 1, N
        DO 100, IROW = 1, N
          A(IROW,ICOL) = A(IROW,ICOL) * ROWSCA(IROW) * 
     $                   COLSCA(ICOL)
  100   CONTINUE
  110 CONTINUE
      PRINT 1070
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, LDA)
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (3(3X, F8.5))
 1020 FORMAT (1X, 'Illegal argument to DGEEQU, argument #', I1)
 1030 FORMAT (1X, 'Column ', I1, ' of A is exactly zero.')
 1040 FORMAT (1X, 'Row ', I1, ' of A is exactly zero.')
 1050 FORMAT (/1X, 'Row scale factors:')
 1060 FORMAT (/1X, 'Column scale factors:')
 1070 FORMAT (/1X, 'Scaled A:')
C
      END
 

Sample Output

 
 A:
    2.00000    4.00000    8.00000
    2.00000    8.00000   16.00000
    2.00000   16.00000   32.00000



 Row scale factors:
    0.12500    0.06250    0.03125



 Column scale factors:
    4.00000    2.00000    1.00000



 Scaled A:
    1.00000    1.00000    1.00000
    0.50000    1.00000    1.00000
    0.25000    1.00000    1.00000






Previous Next Contents Generated Index Doc Set Home