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