```001:       REAL             FUNCTION CLANGB( NORM, N, KL, KU, 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
011:       INTEGER            KL, KU, LDAB, N
012: *     ..
013: *     .. Array Arguments ..
014:       REAL               WORK( * )
015:       COMPLEX            AB( LDAB, * )
016: *     ..
017: *
018: *  Purpose
019: *  =======
020: *
021: *  CLANGB  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 band matrix  A,  with kl sub-diagonals and ku super-diagonals.
024: *
025: *  Description
026: *  ===========
027: *
028: *  CLANGB returns the value
029: *
030: *     CLANGB = ( 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 CLANGB as described
048: *          above.
049: *
050: *  N       (input) INTEGER
051: *          The order of the matrix A.  N >= 0.  When N = 0, CLANGB is
052: *          set to zero.
053: *
054: *  KL      (input) INTEGER
055: *          The number of sub-diagonals of the matrix A.  KL >= 0.
056: *
057: *  KU      (input) INTEGER
058: *          The number of super-diagonals of the matrix A.  KU >= 0.
059: *
060: *  AB      (input) COMPLEX array, dimension (LDAB,N)
061: *          The band matrix A, stored in rows 1 to KL+KU+1.  The j-th
062: *          column of A is stored in the j-th column of the array AB as
063: *          follows:
064: *          AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl).
065: *
066: *  LDAB    (input) INTEGER
067: *          The leading dimension of the array AB.  LDAB >= KL+KU+1.
068: *
069: *  WORK    (workspace) REAL array, dimension (MAX(1,LWORK)),
070: *          where LWORK >= N when NORM = 'I'; otherwise, WORK is not
071: *          referenced.
072: *
073: * =====================================================================
074: *
075: *     .. Parameters ..
076:       REAL               ONE, ZERO
077:       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
078: *     ..
079: *     .. Local Scalars ..
080:       INTEGER            I, J, K, L
081:       REAL               SCALE, SUM, VALUE
082: *     ..
083: *     .. External Functions ..
084:       LOGICAL            LSAME
085:       EXTERNAL           LSAME
086: *     ..
087: *     .. External Subroutines ..
088:       EXTERNAL           CLASSQ
089: *     ..
090: *     .. Intrinsic Functions ..
091:       INTRINSIC          ABS, MAX, MIN, SQRT
092: *     ..
093: *     .. Executable Statements ..
094: *
095:       IF( N.EQ.0 ) THEN
096:          VALUE = ZERO
097:       ELSE IF( LSAME( NORM, 'M' ) ) THEN
098: *
099: *        Find max(abs(A(i,j))).
100: *
101:          VALUE = ZERO
102:          DO 20 J = 1, N
103:             DO 10 I = MAX( KU+2-J, 1 ), MIN( N+KU+1-J, KL+KU+1 )
104:                VALUE = MAX( VALUE, ABS( AB( I, J ) ) )
105:    10       CONTINUE
106:    20    CONTINUE
107:       ELSE IF( ( LSAME( NORM, 'O' ) ) .OR. ( NORM.EQ.'1' ) ) THEN
108: *
109: *        Find norm1(A).
110: *
111:          VALUE = ZERO
112:          DO 40 J = 1, N
113:             SUM = ZERO
114:             DO 30 I = MAX( KU+2-J, 1 ), MIN( N+KU+1-J, KL+KU+1 )
115:                SUM = SUM + ABS( AB( I, J ) )
116:    30       CONTINUE
117:             VALUE = MAX( VALUE, SUM )
118:    40    CONTINUE
119:       ELSE IF( LSAME( NORM, 'I' ) ) THEN
120: *
121: *        Find normI(A).
122: *
123:          DO 50 I = 1, N
124:             WORK( I ) = ZERO
125:    50    CONTINUE
126:          DO 70 J = 1, N
127:             K = KU + 1 - J
128:             DO 60 I = MAX( 1, J-KU ), MIN( N, J+KL )
129:                WORK( I ) = WORK( I ) + ABS( AB( K+I, J ) )
130:    60       CONTINUE
131:    70    CONTINUE
132:          VALUE = ZERO
133:          DO 80 I = 1, N
134:             VALUE = MAX( VALUE, WORK( I ) )
135:    80    CONTINUE
136:       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
137: *
138: *        Find normF(A).
139: *
140:          SCALE = ZERO
141:          SUM = ONE
142:          DO 90 J = 1, N
143:             L = MAX( 1, J-KU )
144:             K = KU + 1 - J + L
145:             CALL CLASSQ( MIN( N, J+KL )-L+1, AB( K, J ), 1, SCALE, SUM )
146:    90    CONTINUE
147:          VALUE = SCALE*SQRT( SUM )
148:       END IF
149: *
150:       CLANGB = VALUE
151:       RETURN
152: *
153: *     End of CLANGB
154: *
155:       END
156: ```