LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
clantb.f
Go to the documentation of this file.
1 *> \brief \b CLANTB
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download CLANTB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clantb.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clantb.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clantb.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * REAL FUNCTION CLANTB( 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 * REAL WORK( * )
30 * COMPLEX AB( LDAB, * )
31 * ..
32 *
33 *
34 *> \par Purpose:
35 * =============
36 *>
37 *> \verbatim
38 *>
39 *> CLANTB 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 CLANTB
45 *> \verbatim
46 *>
47 *> CLANTB = ( 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 CLANTB 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, CLANTB 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 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 REAL 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 *> \date November 2011
137 *
138 *> \ingroup complexOTHERauxiliary
139 *
140 * =====================================================================
141  REAL FUNCTION clantb( NORM, UPLO, DIAG, N, K, AB,
142  $ ldab, work )
143 *
144 * -- LAPACK auxiliary routine (version 3.4.0) --
145 * -- LAPACK is a software package provided by Univ. of Tennessee, --
146 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
147 * November 2011
148 *
149 * .. Scalar Arguments ..
150  CHARACTER diag, norm, uplo
151  INTEGER k, ldab, n
152 * ..
153 * .. Array Arguments ..
154  REAL work( * )
155  COMPLEX ab( ldab, * )
156 * ..
157 *
158 * =====================================================================
159 *
160 * .. Parameters ..
161  REAL one, zero
162  parameter( one = 1.0e+0, zero = 0.0e+0 )
163 * ..
164 * .. Local Scalars ..
165  LOGICAL udiag
166  INTEGER i, j, l
167  REAL scale, sum, value
168 * ..
169 * .. External Functions ..
170  LOGICAL lsame
171  EXTERNAL lsame
172 * ..
173 * .. External Subroutines ..
174  EXTERNAL classq
175 * ..
176 * .. Intrinsic Functions ..
177  INTRINSIC abs, max, min, sqrt
178 * ..
179 * .. Executable Statements ..
180 *
181  IF( n.EQ.0 ) THEN
182  value = zero
183  ELSE IF( lsame( norm, 'M' ) ) THEN
184 *
185 * Find max(abs(A(i,j))).
186 *
187  IF( lsame( diag, 'U' ) ) THEN
188  value = one
189  IF( lsame( uplo, 'U' ) ) THEN
190  DO 20 j = 1, n
191  DO 10 i = max( k+2-j, 1 ), k
192  value = max( value, abs( ab( i, j ) ) )
193  10 CONTINUE
194  20 CONTINUE
195  ELSE
196  DO 40 j = 1, n
197  DO 30 i = 2, min( n+1-j, k+1 )
198  value = max( value, abs( ab( i, j ) ) )
199  30 CONTINUE
200  40 CONTINUE
201  END IF
202  ELSE
203  value = zero
204  IF( lsame( uplo, 'U' ) ) THEN
205  DO 60 j = 1, n
206  DO 50 i = max( k+2-j, 1 ), k + 1
207  value = max( value, abs( ab( i, j ) ) )
208  50 CONTINUE
209  60 CONTINUE
210  ELSE
211  DO 80 j = 1, n
212  DO 70 i = 1, min( n+1-j, k+1 )
213  value = max( value, abs( ab( i, j ) ) )
214  70 CONTINUE
215  80 CONTINUE
216  END IF
217  END IF
218  ELSE IF( ( lsame( norm, 'O' ) ) .OR. ( norm.EQ.'1' ) ) THEN
219 *
220 * Find norm1(A).
221 *
222  value = zero
223  udiag = lsame( diag, 'U' )
224  IF( lsame( uplo, 'U' ) ) THEN
225  DO 110 j = 1, n
226  IF( udiag ) THEN
227  sum = one
228  DO 90 i = max( k+2-j, 1 ), k
229  sum = sum + abs( ab( i, j ) )
230  90 CONTINUE
231  ELSE
232  sum = zero
233  DO 100 i = max( k+2-j, 1 ), k + 1
234  sum = sum + abs( ab( i, j ) )
235  100 CONTINUE
236  END IF
237  value = max( value, sum )
238  110 CONTINUE
239  ELSE
240  DO 140 j = 1, n
241  IF( udiag ) THEN
242  sum = one
243  DO 120 i = 2, min( n+1-j, k+1 )
244  sum = sum + abs( ab( i, j ) )
245  120 CONTINUE
246  ELSE
247  sum = zero
248  DO 130 i = 1, min( n+1-j, k+1 )
249  sum = sum + abs( ab( i, j ) )
250  130 CONTINUE
251  END IF
252  value = max( value, sum )
253  140 CONTINUE
254  END IF
255  ELSE IF( lsame( norm, 'I' ) ) THEN
256 *
257 * Find normI(A).
258 *
259  value = zero
260  IF( lsame( uplo, 'U' ) ) THEN
261  IF( lsame( diag, 'U' ) ) THEN
262  DO 150 i = 1, n
263  work( i ) = one
264  150 CONTINUE
265  DO 170 j = 1, n
266  l = k + 1 - j
267  DO 160 i = max( 1, j-k ), j - 1
268  work( i ) = work( i ) + abs( ab( l+i, j ) )
269  160 CONTINUE
270  170 CONTINUE
271  ELSE
272  DO 180 i = 1, n
273  work( i ) = zero
274  180 CONTINUE
275  DO 200 j = 1, n
276  l = k + 1 - j
277  DO 190 i = max( 1, j-k ), j
278  work( i ) = work( i ) + abs( ab( l+i, j ) )
279  190 CONTINUE
280  200 CONTINUE
281  END IF
282  ELSE
283  IF( lsame( diag, 'U' ) ) THEN
284  DO 210 i = 1, n
285  work( i ) = one
286  210 CONTINUE
287  DO 230 j = 1, n
288  l = 1 - j
289  DO 220 i = j + 1, min( n, j+k )
290  work( i ) = work( i ) + abs( ab( l+i, j ) )
291  220 CONTINUE
292  230 CONTINUE
293  ELSE
294  DO 240 i = 1, n
295  work( i ) = zero
296  240 CONTINUE
297  DO 260 j = 1, n
298  l = 1 - j
299  DO 250 i = j, min( n, j+k )
300  work( i ) = work( i ) + abs( ab( l+i, j ) )
301  250 CONTINUE
302  260 CONTINUE
303  END IF
304  END IF
305  DO 270 i = 1, n
306  value = max( value, work( i ) )
307  270 CONTINUE
308  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
309 *
310 * Find normF(A).
311 *
312  IF( lsame( uplo, 'U' ) ) THEN
313  IF( lsame( diag, 'U' ) ) THEN
314  scale = one
315  sum = n
316  IF( k.GT.0 ) THEN
317  DO 280 j = 2, n
318  CALL classq( min( j-1, k ),
319  $ ab( max( k+2-j, 1 ), j ), 1, scale,
320  $ sum )
321  280 CONTINUE
322  END IF
323  ELSE
324  scale = zero
325  sum = one
326  DO 290 j = 1, n
327  CALL classq( min( j, k+1 ), ab( max( k+2-j, 1 ), j ),
328  $ 1, scale, sum )
329  290 CONTINUE
330  END IF
331  ELSE
332  IF( lsame( diag, 'U' ) ) THEN
333  scale = one
334  sum = n
335  IF( k.GT.0 ) THEN
336  DO 300 j = 1, n - 1
337  CALL classq( min( n-j, k ), ab( 2, j ), 1, scale,
338  $ sum )
339  300 CONTINUE
340  END IF
341  ELSE
342  scale = zero
343  sum = one
344  DO 310 j = 1, n
345  CALL classq( min( n-j+1, k+1 ), ab( 1, j ), 1, scale,
346  $ sum )
347  310 CONTINUE
348  END IF
349  END IF
350  value = scale*sqrt( sum )
351  END IF
352 *
353  clantb = value
354  RETURN
355 *
356 * End of CLANTB
357 *
358  END