LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
clantb.f
Go to the documentation of this file.
1 *> \brief \b CLANTB 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 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 *> \ingroup complexOTHERauxiliary
137 *
138 * =====================================================================
139  REAL function clantb( 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  REAL work( * )
153  COMPLEX ab( ldab, * )
154 * ..
155 *
156 * =====================================================================
157 *
158 * .. Parameters ..
159  REAL one, zero
160  parameter( one = 1.0e+0, zero = 0.0e+0 )
161 * ..
162 * .. Local Scalars ..
163  LOGICAL udiag
164  INTEGER i, j, l
165  REAL sum, value
166 * ..
167 * .. Local Arrays ..
168  REAL ssq( 2 ), colssq( 2 )
169 * ..
170 * .. External Functions ..
171  LOGICAL lsame, sisnan
172  EXTERNAL lsame, sisnan
173 * ..
174 * .. External Subroutines ..
175  EXTERNAL classq, scombssq
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. sisnan( 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. sisnan( 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. sisnan( 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. sisnan( 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. sisnan( 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. sisnan( 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. sisnan( 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 classq( min( j-1, k ),
330  $ ab( max( k+2-j, 1 ), j ), 1,
331  $ colssq( 1 ), colssq( 2 ) )
332  CALL scombssq( 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 classq( min( j, k+1 ), ab( max( k+2-j, 1 ), j ),
342  $ 1, colssq( 1 ), colssq( 2 ) )
343  CALL scombssq( 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 classq( min( n-j, k ), ab( 2, j ), 1,
355  $ colssq( 1 ), colssq( 2 ) )
356  CALL scombssq( 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 classq( min( n-j+1, k+1 ), ab( 1, j ), 1,
366  $ colssq( 1 ), colssq( 2 ) )
367  CALL scombssq( ssq, colssq )
368  310 CONTINUE
369  END IF
370  END IF
371  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
372  END IF
373 *
374  clantb = VALUE
375  RETURN
376 *
377 * End of CLANTB
378 *
379  END
subroutine scombssq(V1, V2)
SCOMBSSQ adds two scaled sum of squares quantities
Definition: scombssq.f:60
subroutine classq(n, x, incx, scl, sumsq)
CLASSQ updates a sum of squares represented in scaled form.
Definition: classq.f90:126
logical function sisnan(SIN)
SISNAN tests input for NaN.
Definition: sisnan.f:59
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
real function clantb(NORM, UPLO, DIAG, N, K, AB, LDAB, WORK)
CLANTB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: clantb.f:141