001:       SUBROUTINE ZLAQSB( UPLO, N, KD, AB, LDAB, S, SCOND, AMAX, EQUED )
002: *
003: *  -- LAPACK auxiliary routine (version 3.2) --
004: *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
005: *     November 2006
006: *
007: *     .. Scalar Arguments ..
008:       CHARACTER          EQUED, UPLO
009:       INTEGER            KD, LDAB, N
010:       DOUBLE PRECISION   AMAX, SCOND
011: *     ..
012: *     .. Array Arguments ..
013:       DOUBLE PRECISION   S( * )
014:       COMPLEX*16         AB( LDAB, * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  ZLAQSB equilibrates a symmetric band matrix A using the scaling
021: *  factors in the vector S.
022: *
023: *  Arguments
024: *  =========
025: *
026: *  UPLO    (input) CHARACTER*1
027: *          Specifies whether the upper or lower triangular part of the
028: *          symmetric matrix A is stored.
029: *          = 'U':  Upper triangular
030: *          = 'L':  Lower triangular
031: *
032: *  N       (input) INTEGER
033: *          The order of the matrix A.  N >= 0.
034: *
035: *  KD      (input) INTEGER
036: *          The number of super-diagonals of the matrix A if UPLO = 'U',
037: *          or the number of sub-diagonals if UPLO = 'L'.  KD >= 0.
038: *
039: *  AB      (input/output) COMPLEX*16 array, dimension (LDAB,N)
040: *          On entry, the upper or lower triangle of the symmetric band
041: *          matrix A, stored in the first KD+1 rows of the array.  The
042: *          j-th column of A is stored in the j-th column of the array AB
043: *          as follows:
044: *          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
045: *          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
046: *
047: *          On exit, if INFO = 0, the triangular factor U or L from the
048: *          Cholesky factorization A = U'*U or A = L*L' of the band
049: *          matrix A, in the same storage format as A.
050: *
051: *  LDAB    (input) INTEGER
052: *          The leading dimension of the array AB.  LDAB >= KD+1.
053: *
054: *  S       (input) DOUBLE PRECISION array, dimension (N)
055: *          The scale factors for A.
056: *
057: *  SCOND   (input) DOUBLE PRECISION
058: *          Ratio of the smallest S(i) to the largest S(i).
059: *
060: *  AMAX    (input) DOUBLE PRECISION
061: *          Absolute value of largest matrix entry.
062: *
063: *  EQUED   (output) CHARACTER*1
064: *          Specifies whether or not equilibration was done.
065: *          = 'N':  No equilibration.
066: *          = 'Y':  Equilibration was done, i.e., A has been replaced by
067: *                  diag(S) * A * diag(S).
068: *
069: *  Internal Parameters
070: *  ===================
071: *
072: *  THRESH is a threshold value used to decide if scaling should be done
073: *  based on the ratio of the scaling factors.  If SCOND < THRESH,
074: *  scaling is done.
075: *
076: *  LARGE and SMALL are threshold values used to decide if scaling should
077: *  be done based on the absolute size of the largest matrix element.
078: *  If AMAX > LARGE or AMAX < SMALL, scaling is done.
079: *
080: *  =====================================================================
081: *
082: *     .. Parameters ..
083:       DOUBLE PRECISION   ONE, THRESH
084:       PARAMETER          ( ONE = 1.0D+0, THRESH = 0.1D+0 )
085: *     ..
086: *     .. Local Scalars ..
087:       INTEGER            I, J
088:       DOUBLE PRECISION   CJ, LARGE, SMALL
089: *     ..
090: *     .. External Functions ..
091:       LOGICAL            LSAME
092:       DOUBLE PRECISION   DLAMCH
093:       EXTERNAL           LSAME, DLAMCH
094: *     ..
095: *     .. Intrinsic Functions ..
096:       INTRINSIC          MAX, MIN
097: *     ..
098: *     .. Executable Statements ..
099: *
100: *     Quick return if possible
101: *
102:       IF( N.LE.0 ) THEN
103:          EQUED = 'N'
104:          RETURN
105:       END IF
106: *
107: *     Initialize LARGE and SMALL.
108: *
109:       SMALL = DLAMCH( 'Safe minimum' ) / DLAMCH( 'Precision' )
110:       LARGE = ONE / SMALL
111: *
112:       IF( SCOND.GE.THRESH .AND. AMAX.GE.SMALL .AND. AMAX.LE.LARGE ) THEN
113: *
114: *        No equilibration
115: *
116:          EQUED = 'N'
117:       ELSE
118: *
119: *        Replace A by diag(S) * A * diag(S).
120: *
121:          IF( LSAME( UPLO, 'U' ) ) THEN
122: *
123: *           Upper triangle of A is stored in band format.
124: *
125:             DO 20 J = 1, N
126:                CJ = S( J )
127:                DO 10 I = MAX( 1, J-KD ), J
128:                   AB( KD+1+I-J, J ) = CJ*S( I )*AB( KD+1+I-J, J )
129:    10          CONTINUE
130:    20       CONTINUE
131:          ELSE
132: *
133: *           Lower triangle of A is stored.
134: *
135:             DO 40 J = 1, N
136:                CJ = S( J )
137:                DO 30 I = J, MIN( N, J+KD )
138:                   AB( 1+I-J, J ) = CJ*S( I )*AB( 1+I-J, J )
139:    30          CONTINUE
140:    40       CONTINUE
141:          END IF
142:          EQUED = 'Y'
143:       END IF
144: *
145:       RETURN
146: *
147: *     End of ZLAQSB
148: *
149:       END
150: