1*> \brief \b ZLANTB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a triangular band matrix.
2*
3*  =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6*            http://www.netlib.org/lapack/explore-html/
7*
8*> \htmlonly
9*> Download ZLANTB + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlantb.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlantb.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlantb.f">
15*> [TXT]</a>
16*> \endhtmlonly
17*
18*  Definition:
19*  ===========
20*
21*       DOUBLE PRECISION FUNCTION ZLANTB( NORM, UPLO, DIAG, N, K, AB,
22*                        LDAB, WORK )
23*
24*       .. Scalar Arguments ..
25*       CHARACTER          DIAG, NORM, UPLO
26*       INTEGER            K, LDAB, N
27*       ..
28*       .. Array Arguments ..
29*       DOUBLE PRECISION   WORK( * )
30*       COMPLEX*16         AB( LDAB, * )
31*       ..
32*
33*
34*> \par Purpose:
35*  =============
36*>
37*> \verbatim
38*>
39*> ZLANTB  returns the value of the one norm,  or the Frobenius norm, or
40*> the  infinity norm,  or the element of  largest absolute value  of an
41*> n by n triangular band matrix A,  with ( k + 1 ) diagonals.
42*> \endverbatim
43*>
44*> \return ZLANTB
45*> \verbatim
46*>
47*>    ZLANTB = ( max(abs(A(i,j))), NORM = 'M' or 'm'
48*>             (
49*>             ( norm1(A),         NORM = '1', 'O' or 'o'
50*>             (
51*>             ( normI(A),         NORM = 'I' or 'i'
52*>             (
53*>             ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
54*>
55*> where  norm1  denotes the  one norm of a matrix (maximum column sum),
56*> normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
57*> normF  denotes the  Frobenius norm of a matrix (square root of sum of
58*> squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
59*> \endverbatim
60*
61*  Arguments:
62*  ==========
63*
64*> \param[in] NORM
65*> \verbatim
66*>          NORM is CHARACTER*1
67*>          Specifies the value to be returned in ZLANTB as described
68*>          above.
69*> \endverbatim
70*>
71*> \param[in] UPLO
72*> \verbatim
73*>          UPLO is CHARACTER*1
74*>          Specifies whether the matrix A is upper or lower triangular.
75*>          = 'U':  Upper triangular
76*>          = 'L':  Lower triangular
77*> \endverbatim
78*>
79*> \param[in] DIAG
80*> \verbatim
81*>          DIAG is CHARACTER*1
82*>          Specifies whether or not the matrix A is unit triangular.
83*>          = 'N':  Non-unit triangular
84*>          = 'U':  Unit triangular
85*> \endverbatim
86*>
87*> \param[in] N
88*> \verbatim
89*>          N is INTEGER
90*>          The order of the matrix A.  N >= 0.  When N = 0, ZLANTB is
91*>          set to zero.
92*> \endverbatim
93*>
94*> \param[in] K
95*> \verbatim
96*>          K is INTEGER
97*>          The number of super-diagonals of the matrix A if UPLO = 'U',
98*>          or the number of sub-diagonals of the matrix A if UPLO = 'L'.
99*>          K >= 0.
100*> \endverbatim
101*>
102*> \param[in] AB
103*> \verbatim
104*>          AB is COMPLEX*16 array, dimension (LDAB,N)
105*>          The upper or lower triangular band matrix A, stored in the
106*>          first k+1 rows of AB.  The j-th column of A is stored
107*>          in the j-th column of the array AB as follows:
108*>          if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j;
109*>          if UPLO = 'L', AB(1+i-j,j)   = A(i,j) for j<=i<=min(n,j+k).
110*>          Note that when DIAG = 'U', the elements of the array AB
111*>          corresponding to the diagonal elements of the matrix A are
112*>          not referenced, but are assumed to be one.
113*> \endverbatim
114*>
115*> \param[in] LDAB
116*> \verbatim
117*>          LDAB is INTEGER
118*>          The leading dimension of the array AB.  LDAB >= K+1.
119*> \endverbatim
120*>
121*> \param[out] WORK
122*> \verbatim
123*>          WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
124*>          where LWORK >= N when NORM = 'I'; otherwise, WORK is not
125*>          referenced.
126*> \endverbatim
127*
128*  Authors:
129*  ========
130*
131*> \author Univ. of Tennessee
132*> \author Univ. of California Berkeley
133*> \author Univ. of Colorado Denver
134*> \author NAG Ltd.
135*
136*> \ingroup complex16OTHERauxiliary
137*
138*  =====================================================================
139      DOUBLE PRECISION FUNCTION ZLANTB( NORM, UPLO, DIAG, N, K, AB,
140     $                 LDAB, WORK )
141*
142*  -- LAPACK auxiliary routine --
143*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
144*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
145*
146      IMPLICIT NONE
147*     .. Scalar Arguments ..
148      CHARACTER          DIAG, NORM, UPLO
149      INTEGER            K, LDAB, N
150*     ..
151*     .. Array Arguments ..
152      DOUBLE PRECISION   WORK( * )
153      COMPLEX*16         AB( LDAB, * )
154*     ..
155*
156* =====================================================================
157*
158*     .. Parameters ..
159      DOUBLE PRECISION   ONE, ZERO
160      PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
161*     ..
162*     .. Local Scalars ..
163      LOGICAL            UDIAG
164      INTEGER            I, J, L
165      DOUBLE PRECISION   SUM, VALUE
166*     ..
167*     .. Local Arrays ..
168      DOUBLE PRECISION   SSQ( 2 ), COLSSQ( 2 )
169*     ..
170*     .. External Functions ..
171      LOGICAL            LSAME, DISNAN
172      EXTERNAL           LSAME, DISNAN
173*     ..
174*     .. External Subroutines ..
175      EXTERNAL           ZLASSQ, DCOMBSSQ
176*     ..
177*     .. Intrinsic Functions ..
178      INTRINSIC          ABS, MAX, MIN, SQRT
179*     ..
180*     .. Executable Statements ..
181*
182      IF( N.EQ.0 ) THEN
183         VALUE = ZERO
184      ELSE IF( LSAME( NORM, 'M' ) ) THEN
185*
186*        Find max(abs(A(i,j))).
187*
188         IF( LSAME( DIAG, 'U' ) ) THEN
189            VALUE = ONE
190            IF( LSAME( UPLO, 'U' ) ) THEN
191               DO 20 J = 1, N
192                  DO 10 I = MAX( K+2-J, 1 ), K
193                     SUM = ABS( AB( I, J ) )
194                     IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
195   10             CONTINUE
196   20          CONTINUE
197            ELSE
198               DO 40 J = 1, N
199                  DO 30 I = 2, MIN( N+1-J, K+1 )
200                     SUM = ABS( AB( I, J ) )
201                     IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
202   30             CONTINUE
203   40          CONTINUE
204            END IF
205         ELSE
206            VALUE = ZERO
207            IF( LSAME( UPLO, 'U' ) ) THEN
208               DO 60 J = 1, N
209                  DO 50 I = MAX( K+2-J, 1 ), K + 1
210                     SUM = ABS( AB( I, J ) )
211                     IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
212   50             CONTINUE
213   60          CONTINUE
214            ELSE
215               DO 80 J = 1, N
216                  DO 70 I = 1, MIN( N+1-J, K+1 )
217                     SUM = ABS( AB( I, J ) )
218                     IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
219   70             CONTINUE
220   80          CONTINUE
221            END IF
222         END IF
223      ELSE IF( ( LSAME( NORM, 'O' ) ) .OR. ( NORM.EQ.'1' ) ) THEN
224*
225*        Find norm1(A).
226*
227         VALUE = ZERO
228         UDIAG = LSAME( DIAG, 'U' )
229         IF( LSAME( UPLO, 'U' ) ) THEN
230            DO 110 J = 1, N
231               IF( UDIAG ) THEN
232                  SUM = ONE
233                  DO 90 I = MAX( K+2-J, 1 ), K
234                     SUM = SUM + ABS( AB( I, J ) )
235   90             CONTINUE
236               ELSE
237                  SUM = ZERO
238                  DO 100 I = MAX( K+2-J, 1 ), K + 1
239                     SUM = SUM + ABS( AB( I, J ) )
240  100             CONTINUE
241               END IF
242               IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
243  110       CONTINUE
244         ELSE
245            DO 140 J = 1, N
246               IF( UDIAG ) THEN
247                  SUM = ONE
248                  DO 120 I = 2, MIN( N+1-J, K+1 )
249                     SUM = SUM + ABS( AB( I, J ) )
250  120             CONTINUE
251               ELSE
252                  SUM = ZERO
253                  DO 130 I = 1, MIN( N+1-J, K+1 )
254                     SUM = SUM + ABS( AB( I, J ) )
255  130             CONTINUE
256               END IF
257               IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
258  140       CONTINUE
259         END IF
260      ELSE IF( LSAME( NORM, 'I' ) ) THEN
261*
262*        Find normI(A).
263*
264         VALUE = ZERO
265         IF( LSAME( UPLO, 'U' ) ) THEN
266            IF( LSAME( DIAG, 'U' ) ) THEN
267               DO 150 I = 1, N
268                  WORK( I ) = ONE
269  150          CONTINUE
270               DO 170 J = 1, N
271                  L = K + 1 - J
272                  DO 160 I = MAX( 1, J-K ), J - 1
273                     WORK( I ) = WORK( I ) + ABS( AB( L+I, J ) )
274  160             CONTINUE
275  170          CONTINUE
276            ELSE
277               DO 180 I = 1, N
278                  WORK( I ) = ZERO
279  180          CONTINUE
280               DO 200 J = 1, N
281                  L = K + 1 - J
282                  DO 190 I = MAX( 1, J-K ), J
283                     WORK( I ) = WORK( I ) + ABS( AB( L+I, J ) )
284  190             CONTINUE
285  200          CONTINUE
286            END IF
287         ELSE
288            IF( LSAME( DIAG, 'U' ) ) THEN
289               DO 210 I = 1, N
290                  WORK( I ) = ONE
291  210          CONTINUE
292               DO 230 J = 1, N
293                  L = 1 - J
294                  DO 220 I = J + 1, MIN( N, J+K )
295                     WORK( I ) = WORK( I ) + ABS( AB( L+I, J ) )
296  220             CONTINUE
297  230          CONTINUE
298            ELSE
299               DO 240 I = 1, N
300                  WORK( I ) = ZERO
301  240          CONTINUE
302               DO 260 J = 1, N
303                  L = 1 - J
304                  DO 250 I = J, MIN( N, J+K )
305                     WORK( I ) = WORK( I ) + ABS( AB( L+I, J ) )
306  250             CONTINUE
307  260          CONTINUE
308            END IF
309         END IF
310         DO 270 I = 1, N
311            SUM = WORK( I )
312            IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
313  270    CONTINUE
314      ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
315*
316*        Find normF(A).
317*        SSQ(1) is scale
318*        SSQ(2) is sum-of-squares
319*        For better accuracy, sum each column separately.
320*
321         IF( LSAME( UPLO, 'U' ) ) THEN
322            IF( LSAME( DIAG, 'U' ) ) THEN
323               SSQ( 1 ) = ONE
324               SSQ( 2 ) = N
325               IF( K.GT.0 ) THEN
326                  DO 280 J = 2, N
327                     COLSSQ( 1 ) = ZERO
328                     COLSSQ( 2 ) = ONE
329                     CALL ZLASSQ( MIN( J-1, K ),
330     $                            AB( MAX( K+2-J, 1 ), J ), 1,
331     $                            COLSSQ( 1 ), COLSSQ( 2 ) )
332                     CALL DCOMBSSQ( SSQ, COLSSQ )
333  280             CONTINUE
334               END IF
335            ELSE
336               SSQ( 1 ) = ZERO
337               SSQ( 2 ) = ONE
338               DO 290 J = 1, N
339                  COLSSQ( 1 ) = ZERO
340                  COLSSQ( 2 ) = ONE
341                  CALL ZLASSQ( MIN( J, K+1 ), AB( MAX( K+2-J, 1 ), J ),
342     $                         1, COLSSQ( 1 ), COLSSQ( 2 ) )
343                  CALL DCOMBSSQ( SSQ, COLSSQ )
344  290          CONTINUE
345            END IF
346         ELSE
347            IF( LSAME( DIAG, 'U' ) ) THEN
348               SSQ( 1 ) = ONE
349               SSQ( 2 ) = N
350               IF( K.GT.0 ) THEN
351                  DO 300 J = 1, N - 1
352                     COLSSQ( 1 ) = ZERO
353                     COLSSQ( 2 ) = ONE
354                     CALL ZLASSQ( MIN( N-J, K ), AB( 2, J ), 1,
355     $                            COLSSQ( 1 ), COLSSQ( 2 ) )
356                     CALL DCOMBSSQ( SSQ, COLSSQ )
357  300             CONTINUE
358               END IF
359            ELSE
360               SSQ( 1 ) = ZERO
361               SSQ( 2 ) = ONE
362               DO 310 J = 1, N
363                  COLSSQ( 1 ) = ZERO
364                  COLSSQ( 2 ) = ONE
365                  CALL ZLASSQ( MIN( N-J+1, K+1 ), AB( 1, J ), 1,
366     $                         COLSSQ( 1 ), COLSSQ( 2 ) )
367                  CALL DCOMBSSQ( SSQ, COLSSQ )
368  310          CONTINUE
369            END IF
370         END IF
371         VALUE = SSQ( 1 )*SQRT( SSQ( 2 ) )
372      END IF
373*
374      ZLANTB = VALUE
375      RETURN
376*
377*     End of ZLANTB
378*
379      END
380