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