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