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