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