```001:       DOUBLE PRECISION FUNCTION DLANGB( 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:       DOUBLE PRECISION   AB( LDAB, * ), WORK( * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  DLANGB  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: *  DLANGB returns the value
028: *
029: *     DLANGB = ( 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 DLANGB as described
047: *          above.
048: *
049: *  N       (input) INTEGER
050: *          The order of the matrix A.  N >= 0.  When N = 0, DLANGB 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) DOUBLE PRECISION 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) DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
069: *          where LWORK >= N when NORM = 'I'; otherwise, WORK is not
070: *          referenced.
071: *
072: * =====================================================================
073: *
074: *
075: *     .. Parameters ..
076:       DOUBLE PRECISION   ONE, ZERO
077:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
078: *     ..
079: *     .. Local Scalars ..
080:       INTEGER            I, J, K, L
081:       DOUBLE PRECISION   SCALE, SUM, VALUE
082: *     ..
083: *     .. External Subroutines ..
084:       EXTERNAL           DLASSQ
085: *     ..
086: *     .. External Functions ..
087:       LOGICAL            LSAME
088:       EXTERNAL           LSAME
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 DLASSQ( 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:       DLANGB = VALUE
151:       RETURN
152: *
153: *     End of DLANGB
154: *
155:       END
156: ```