LAPACK  3.9.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 *> \date December 2016
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.7.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 * December 2016
148 *
149  IMPLICIT NONE
150 * .. Scalar Arguments ..
151  CHARACTER diag, norm, uplo
152  INTEGER k, ldab, n
153 * ..
154 * .. Array Arguments ..
155  REAL work( * )
156  COMPLEX ab( ldab, * )
157 * ..
158 *
159 * =====================================================================
160 *
161 * .. Parameters ..
162  REAL one, zero
163  parameter( one = 1.0e+0, zero = 0.0e+0 )
164 * ..
165 * .. Local Scalars ..
166  LOGICAL udiag
167  INTEGER i, j, l
168  REAL sum, value
169 * ..
170 * .. Local Arrays ..
171  REAL ssq( 2 ), colssq( 2 )
172 * ..
173 * .. External Functions ..
174  LOGICAL lsame, sisnan
175  EXTERNAL lsame, sisnan
176 * ..
177 * .. External Subroutines ..
178  EXTERNAL classq, scombssq
179 * ..
180 * .. Intrinsic Functions ..
181  INTRINSIC abs, max, min, sqrt
182 * ..
183 * .. Executable Statements ..
184 *
185  IF( n.EQ.0 ) THEN
186  VALUE = zero
187  ELSE IF( lsame( norm, 'M' ) ) THEN
188 *
189 * Find max(abs(A(i,j))).
190 *
191  IF( lsame( diag, 'U' ) ) THEN
192  VALUE = one
193  IF( lsame( uplo, 'U' ) ) THEN
194  DO 20 j = 1, n
195  DO 10 i = max( k+2-j, 1 ), k
196  sum = abs( ab( i, j ) )
197  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
198  10 CONTINUE
199  20 CONTINUE
200  ELSE
201  DO 40 j = 1, n
202  DO 30 i = 2, min( n+1-j, k+1 )
203  sum = abs( ab( i, j ) )
204  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
205  30 CONTINUE
206  40 CONTINUE
207  END IF
208  ELSE
209  VALUE = zero
210  IF( lsame( uplo, 'U' ) ) THEN
211  DO 60 j = 1, n
212  DO 50 i = max( k+2-j, 1 ), k + 1
213  sum = abs( ab( i, j ) )
214  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
215  50 CONTINUE
216  60 CONTINUE
217  ELSE
218  DO 80 j = 1, n
219  DO 70 i = 1, min( n+1-j, k+1 )
220  sum = abs( ab( i, j ) )
221  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
222  70 CONTINUE
223  80 CONTINUE
224  END IF
225  END IF
226  ELSE IF( ( lsame( norm, 'O' ) ) .OR. ( norm.EQ.'1' ) ) THEN
227 *
228 * Find norm1(A).
229 *
230  VALUE = zero
231  udiag = lsame( diag, 'U' )
232  IF( lsame( uplo, 'U' ) ) THEN
233  DO 110 j = 1, n
234  IF( udiag ) THEN
235  sum = one
236  DO 90 i = max( k+2-j, 1 ), k
237  sum = sum + abs( ab( i, j ) )
238  90 CONTINUE
239  ELSE
240  sum = zero
241  DO 100 i = max( k+2-j, 1 ), k + 1
242  sum = sum + abs( ab( i, j ) )
243  100 CONTINUE
244  END IF
245  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
246  110 CONTINUE
247  ELSE
248  DO 140 j = 1, n
249  IF( udiag ) THEN
250  sum = one
251  DO 120 i = 2, min( n+1-j, k+1 )
252  sum = sum + abs( ab( i, j ) )
253  120 CONTINUE
254  ELSE
255  sum = zero
256  DO 130 i = 1, min( n+1-j, k+1 )
257  sum = sum + abs( ab( i, j ) )
258  130 CONTINUE
259  END IF
260  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
261  140 CONTINUE
262  END IF
263  ELSE IF( lsame( norm, 'I' ) ) THEN
264 *
265 * Find normI(A).
266 *
267  VALUE = zero
268  IF( lsame( uplo, 'U' ) ) THEN
269  IF( lsame( diag, 'U' ) ) THEN
270  DO 150 i = 1, n
271  work( i ) = one
272  150 CONTINUE
273  DO 170 j = 1, n
274  l = k + 1 - j
275  DO 160 i = max( 1, j-k ), j - 1
276  work( i ) = work( i ) + abs( ab( l+i, j ) )
277  160 CONTINUE
278  170 CONTINUE
279  ELSE
280  DO 180 i = 1, n
281  work( i ) = zero
282  180 CONTINUE
283  DO 200 j = 1, n
284  l = k + 1 - j
285  DO 190 i = max( 1, j-k ), j
286  work( i ) = work( i ) + abs( ab( l+i, j ) )
287  190 CONTINUE
288  200 CONTINUE
289  END IF
290  ELSE
291  IF( lsame( diag, 'U' ) ) THEN
292  DO 210 i = 1, n
293  work( i ) = one
294  210 CONTINUE
295  DO 230 j = 1, n
296  l = 1 - j
297  DO 220 i = j + 1, min( n, j+k )
298  work( i ) = work( i ) + abs( ab( l+i, j ) )
299  220 CONTINUE
300  230 CONTINUE
301  ELSE
302  DO 240 i = 1, n
303  work( i ) = zero
304  240 CONTINUE
305  DO 260 j = 1, n
306  l = 1 - j
307  DO 250 i = j, min( n, j+k )
308  work( i ) = work( i ) + abs( ab( l+i, j ) )
309  250 CONTINUE
310  260 CONTINUE
311  END IF
312  END IF
313  DO 270 i = 1, n
314  sum = work( i )
315  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
316  270 CONTINUE
317  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
318 *
319 * Find normF(A).
320 * SSQ(1) is scale
321 * SSQ(2) is sum-of-squares
322 * For better accuracy, sum each column separately.
323 *
324  IF( lsame( uplo, 'U' ) ) THEN
325  IF( lsame( diag, 'U' ) ) THEN
326  ssq( 1 ) = one
327  ssq( 2 ) = n
328  IF( k.GT.0 ) THEN
329  DO 280 j = 2, n
330  colssq( 1 ) = zero
331  colssq( 2 ) = one
332  CALL classq( min( j-1, k ),
333  $ ab( max( k+2-j, 1 ), j ), 1,
334  $ colssq( 1 ), colssq( 2 ) )
335  CALL scombssq( ssq, colssq )
336  280 CONTINUE
337  END IF
338  ELSE
339  ssq( 1 ) = zero
340  ssq( 2 ) = one
341  DO 290 j = 1, n
342  colssq( 1 ) = zero
343  colssq( 2 ) = one
344  CALL classq( min( j, k+1 ), ab( max( k+2-j, 1 ), j ),
345  $ 1, colssq( 1 ), colssq( 2 ) )
346  CALL scombssq( ssq, colssq )
347  290 CONTINUE
348  END IF
349  ELSE
350  IF( lsame( diag, 'U' ) ) THEN
351  ssq( 1 ) = one
352  ssq( 2 ) = n
353  IF( k.GT.0 ) THEN
354  DO 300 j = 1, n - 1
355  colssq( 1 ) = zero
356  colssq( 2 ) = one
357  CALL classq( min( n-j, k ), ab( 2, j ), 1,
358  $ colssq( 1 ), colssq( 2 ) )
359  CALL scombssq( ssq, colssq )
360  300 CONTINUE
361  END IF
362  ELSE
363  ssq( 1 ) = zero
364  ssq( 2 ) = one
365  DO 310 j = 1, n
366  colssq( 1 ) = zero
367  colssq( 2 ) = one
368  CALL classq( min( n-j+1, k+1 ), ab( 1, j ), 1,
369  $ colssq( 1 ), colssq( 2 ) )
370  CALL scombssq( ssq, colssq )
371  310 CONTINUE
372  END IF
373  END IF
374  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
375  END IF
376 *
377  clantb = VALUE
378  RETURN
379 *
380 * End of CLANTB
381 *
382  END
classq
subroutine classq(N, X, INCX, SCALE, SUMSQ)
CLASSQ updates a sum of squares represented in scaled form.
Definition: classq.f:108
sisnan
logical function sisnan(SIN)
SISNAN tests input for NaN.
Definition: sisnan.f:61
clantb
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:143
lsame
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
scombssq
subroutine scombssq(V1, V2)
SCOMBSSQ adds two scaled sum of squares quantities
Definition: scombssq.f:62