```001:       REAL             FUNCTION CLANSB( NORM, UPLO, N, K, AB, LDAB,
002:      \$                 WORK )
003: *
004: *  -- LAPACK auxiliary routine (version 3.2) --
005: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
006: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
007: *     November 2006
008: *
009: *     .. Scalar Arguments ..
010:       CHARACTER          NORM, UPLO
011:       INTEGER            K, LDAB, N
012: *     ..
013: *     .. Array Arguments ..
014:       REAL               WORK( * )
015:       COMPLEX            AB( LDAB, * )
016: *     ..
017: *
018: *  Purpose
019: *  =======
020: *
021: *  CLANSB  returns the value of the one norm,  or the Frobenius norm, or
022: *  the  infinity norm,  or the element of  largest absolute value  of an
023: *  n by n symmetric band matrix A,  with k super-diagonals.
024: *
025: *  Description
026: *  ===========
027: *
028: *  CLANSB returns the value
029: *
030: *     CLANSB = ( max(abs(A(i,j))), NORM = 'M' or 'm'
031: *              (
032: *              ( norm1(A),         NORM = '1', 'O' or 'o'
033: *              (
034: *              ( normI(A),         NORM = 'I' or 'i'
035: *              (
036: *              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
037: *
038: *  where  norm1  denotes the  one norm of a matrix (maximum column sum),
039: *  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
040: *  normF  denotes the  Frobenius norm of a matrix (square root of sum of
041: *  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
042: *
043: *  Arguments
044: *  =========
045: *
046: *  NORM    (input) CHARACTER*1
047: *          Specifies the value to be returned in CLANSB as described
048: *          above.
049: *
050: *  UPLO    (input) CHARACTER*1
051: *          Specifies whether the upper or lower triangular part of the
052: *          band matrix A is supplied.
053: *          = 'U':  Upper triangular part is supplied
054: *          = 'L':  Lower triangular part is supplied
055: *
056: *  N       (input) INTEGER
057: *          The order of the matrix A.  N >= 0.  When N = 0, CLANSB is
058: *          set to zero.
059: *
060: *  K       (input) INTEGER
061: *          The number of super-diagonals or sub-diagonals of the
062: *          band matrix A.  K >= 0.
063: *
064: *  AB      (input) COMPLEX array, dimension (LDAB,N)
065: *          The upper or lower triangle of the symmetric band matrix A,
066: *          stored in the first K+1 rows of AB.  The j-th column of A is
067: *          stored in the j-th column of the array AB as follows:
068: *          if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j;
069: *          if UPLO = 'L', AB(1+i-j,j)   = A(i,j) for j<=i<=min(n,j+k).
070: *
071: *  LDAB    (input) INTEGER
072: *          The leading dimension of the array AB.  LDAB >= K+1.
073: *
074: *  WORK    (workspace) REAL array, dimension (MAX(1,LWORK)),
075: *          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
076: *          WORK is not referenced.
077: *
078: * =====================================================================
079: *
080: *     .. Parameters ..
081:       REAL               ONE, ZERO
082:       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
083: *     ..
084: *     .. Local Scalars ..
085:       INTEGER            I, J, L
086:       REAL               ABSA, SCALE, SUM, VALUE
087: *     ..
088: *     .. External Functions ..
089:       LOGICAL            LSAME
090:       EXTERNAL           LSAME
091: *     ..
092: *     .. External Subroutines ..
093:       EXTERNAL           CLASSQ
094: *     ..
095: *     .. Intrinsic Functions ..
096:       INTRINSIC          ABS, MAX, MIN, SQRT
097: *     ..
098: *     .. Executable Statements ..
099: *
100:       IF( N.EQ.0 ) THEN
101:          VALUE = ZERO
102:       ELSE IF( LSAME( NORM, 'M' ) ) THEN
103: *
104: *        Find max(abs(A(i,j))).
105: *
106:          VALUE = ZERO
107:          IF( LSAME( UPLO, 'U' ) ) THEN
108:             DO 20 J = 1, N
109:                DO 10 I = MAX( K+2-J, 1 ), K + 1
110:                   VALUE = MAX( VALUE, ABS( AB( I, J ) ) )
111:    10          CONTINUE
112:    20       CONTINUE
113:          ELSE
114:             DO 40 J = 1, N
115:                DO 30 I = 1, MIN( N+1-J, K+1 )
116:                   VALUE = MAX( VALUE, ABS( AB( I, J ) ) )
117:    30          CONTINUE
118:    40       CONTINUE
119:          END IF
120:       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
121:      \$         ( NORM.EQ.'1' ) ) THEN
122: *
123: *        Find normI(A) ( = norm1(A), since A is symmetric).
124: *
125:          VALUE = ZERO
126:          IF( LSAME( UPLO, 'U' ) ) THEN
127:             DO 60 J = 1, N
128:                SUM = ZERO
129:                L = K + 1 - J
130:                DO 50 I = MAX( 1, J-K ), J - 1
131:                   ABSA = ABS( AB( L+I, J ) )
132:                   SUM = SUM + ABSA
133:                   WORK( I ) = WORK( I ) + ABSA
134:    50          CONTINUE
135:                WORK( J ) = SUM + ABS( AB( K+1, J ) )
136:    60       CONTINUE
137:             DO 70 I = 1, N
138:                VALUE = MAX( VALUE, WORK( I ) )
139:    70       CONTINUE
140:          ELSE
141:             DO 80 I = 1, N
142:                WORK( I ) = ZERO
143:    80       CONTINUE
144:             DO 100 J = 1, N
145:                SUM = WORK( J ) + ABS( AB( 1, J ) )
146:                L = 1 - J
147:                DO 90 I = J + 1, MIN( N, J+K )
148:                   ABSA = ABS( AB( L+I, J ) )
149:                   SUM = SUM + ABSA
150:                   WORK( I ) = WORK( I ) + ABSA
151:    90          CONTINUE
152:                VALUE = MAX( VALUE, SUM )
153:   100       CONTINUE
154:          END IF
155:       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
156: *
157: *        Find normF(A).
158: *
159:          SCALE = ZERO
160:          SUM = ONE
161:          IF( K.GT.0 ) THEN
162:             IF( LSAME( UPLO, 'U' ) ) THEN
163:                DO 110 J = 2, N
164:                   CALL CLASSQ( MIN( J-1, K ), AB( MAX( K+2-J, 1 ), J ),
165:      \$                         1, SCALE, SUM )
166:   110          CONTINUE
167:                L = K + 1
168:             ELSE
169:                DO 120 J = 1, N - 1
170:                   CALL CLASSQ( MIN( N-J, K ), AB( 2, J ), 1, SCALE,
171:      \$                         SUM )
172:   120          CONTINUE
173:                L = 1
174:             END IF
175:             SUM = 2*SUM
176:          ELSE
177:             L = 1
178:          END IF
179:          CALL CLASSQ( N, AB( L, 1 ), LDAB, SCALE, SUM )
180:          VALUE = SCALE*SQRT( SUM )
181:       END IF
182: *
183:       CLANSB = VALUE
184:       RETURN
185: *
186: *     End of CLANSB
187: *
188:       END
189: ```