LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
clanhb.f
Go to the documentation of this file.
1 *> \brief \b CLANHB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a Hermitian 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 CLANHB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clanhb.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clanhb.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clanhb.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * REAL FUNCTION CLANHB( NORM, UPLO, N, K, AB, LDAB,
22 * WORK )
23 *
24 * .. Scalar Arguments ..
25 * CHARACTER 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 *> CLANHB 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 hermitian band matrix A, with k super-diagonals.
42 *> \endverbatim
43 *>
44 *> \return CLANHB
45 *> \verbatim
46 *>
47 *> CLANHB = ( 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 CLANHB as described
68 *> above.
69 *> \endverbatim
70 *>
71 *> \param[in] UPLO
72 *> \verbatim
73 *> UPLO is CHARACTER*1
74 *> Specifies whether the upper or lower triangular part of the
75 *> band matrix A is supplied.
76 *> = 'U': Upper triangular
77 *> = 'L': Lower triangular
78 *> \endverbatim
79 *>
80 *> \param[in] N
81 *> \verbatim
82 *> N is INTEGER
83 *> The order of the matrix A. N >= 0. When N = 0, CLANHB is
84 *> set to zero.
85 *> \endverbatim
86 *>
87 *> \param[in] K
88 *> \verbatim
89 *> K is INTEGER
90 *> The number of super-diagonals or sub-diagonals of the
91 *> band matrix A. K >= 0.
92 *> \endverbatim
93 *>
94 *> \param[in] AB
95 *> \verbatim
96 *> AB is COMPLEX array, dimension (LDAB,N)
97 *> The upper or lower triangle of the hermitian band matrix A,
98 *> stored in the first K+1 rows of AB. The j-th column of A is
99 *> stored in the j-th column of the array AB as follows:
100 *> if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j;
101 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+k).
102 *> Note that the imaginary parts of the diagonal elements need
103 *> not be set and are assumed to be zero.
104 *> \endverbatim
105 *>
106 *> \param[in] LDAB
107 *> \verbatim
108 *> LDAB is INTEGER
109 *> The leading dimension of the array AB. LDAB >= K+1.
110 *> \endverbatim
111 *>
112 *> \param[out] WORK
113 *> \verbatim
114 *> WORK is REAL array, dimension (MAX(1,LWORK)),
115 *> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
116 *> WORK is not referenced.
117 *> \endverbatim
118 *
119 * Authors:
120 * ========
121 *
122 *> \author Univ. of Tennessee
123 *> \author Univ. of California Berkeley
124 *> \author Univ. of Colorado Denver
125 *> \author NAG Ltd.
126 *
127 *> \ingroup complexOTHERauxiliary
128 *
129 * =====================================================================
130  REAL function clanhb( norm, uplo, n, k, ab, ldab,
131  $ work )
132 *
133 * -- LAPACK auxiliary routine --
134 * -- LAPACK is a software package provided by Univ. of Tennessee, --
135 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
136 *
137  IMPLICIT NONE
138 * .. Scalar Arguments ..
139  CHARACTER norm, uplo
140  INTEGER k, ldab, n
141 * ..
142 * .. Array Arguments ..
143  REAL work( * )
144  COMPLEX ab( ldab, * )
145 * ..
146 *
147 * =====================================================================
148 *
149 * .. Parameters ..
150  REAL one, zero
151  parameter( one = 1.0e+0, zero = 0.0e+0 )
152 * ..
153 * .. Local Scalars ..
154  INTEGER i, j, l
155  REAL absa, sum, value
156 * ..
157 * .. Local Arrays ..
158  REAL ssq( 2 ), colssq( 2 )
159 * ..
160 * .. External Functions ..
161  LOGICAL lsame, sisnan
162  EXTERNAL lsame, sisnan
163 * ..
164 * .. External Subroutines ..
165  EXTERNAL classq, scombssq
166 * ..
167 * .. Intrinsic Functions ..
168  INTRINSIC abs, max, min, real, sqrt
169 * ..
170 * .. Executable Statements ..
171 *
172  IF( n.EQ.0 ) THEN
173  VALUE = zero
174  ELSE IF( lsame( norm, 'M' ) ) THEN
175 *
176 * Find max(abs(A(i,j))).
177 *
178  VALUE = zero
179  IF( lsame( uplo, 'U' ) ) THEN
180  DO 20 j = 1, n
181  DO 10 i = max( k+2-j, 1 ), k
182  sum = abs( ab( i, j ) )
183  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
184  10 CONTINUE
185  sum = abs( real( ab( k+1, j ) ) )
186  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
187  20 CONTINUE
188  ELSE
189  DO 40 j = 1, n
190  sum = abs( real( ab( 1, j ) ) )
191  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
192  DO 30 i = 2, min( n+1-j, k+1 )
193  sum = abs( ab( i, j ) )
194  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
195  30 CONTINUE
196  40 CONTINUE
197  END IF
198  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
199  $ ( norm.EQ.'1' ) ) THEN
200 *
201 * Find normI(A) ( = norm1(A), since A is hermitian).
202 *
203  VALUE = zero
204  IF( lsame( uplo, 'U' ) ) THEN
205  DO 60 j = 1, n
206  sum = zero
207  l = k + 1 - j
208  DO 50 i = max( 1, j-k ), j - 1
209  absa = abs( ab( l+i, j ) )
210  sum = sum + absa
211  work( i ) = work( i ) + absa
212  50 CONTINUE
213  work( j ) = sum + abs( real( ab( k+1, j ) ) )
214  60 CONTINUE
215  DO 70 i = 1, n
216  sum = work( i )
217  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
218  70 CONTINUE
219  ELSE
220  DO 80 i = 1, n
221  work( i ) = zero
222  80 CONTINUE
223  DO 100 j = 1, n
224  sum = work( j ) + abs( real( ab( 1, j ) ) )
225  l = 1 - j
226  DO 90 i = j + 1, min( n, j+k )
227  absa = abs( ab( l+i, j ) )
228  sum = sum + absa
229  work( i ) = work( i ) + absa
230  90 CONTINUE
231  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
232  100 CONTINUE
233  END IF
234  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
235 *
236 * Find normF(A).
237 * SSQ(1) is scale
238 * SSQ(2) is sum-of-squares
239 * For better accuracy, sum each column separately.
240 *
241  ssq( 1 ) = zero
242  ssq( 2 ) = one
243 *
244 * Sum off-diagonals
245 *
246  IF( k.GT.0 ) THEN
247  IF( lsame( uplo, 'U' ) ) THEN
248  DO 110 j = 2, n
249  colssq( 1 ) = zero
250  colssq( 2 ) = one
251  CALL classq( min( j-1, k ), ab( max( k+2-j, 1 ), j ),
252  $ 1, colssq( 1 ), colssq( 2 ) )
253  CALL scombssq( ssq, colssq )
254  110 CONTINUE
255  l = k + 1
256  ELSE
257  DO 120 j = 1, n - 1
258  colssq( 1 ) = zero
259  colssq( 2 ) = one
260  CALL classq( min( n-j, k ), ab( 2, j ), 1,
261  $ colssq( 1 ), colssq( 2 ) )
262  CALL scombssq( ssq, colssq )
263  120 CONTINUE
264  l = 1
265  END IF
266  ssq( 2 ) = 2*ssq( 2 )
267  ELSE
268  l = 1
269  END IF
270 *
271 * Sum diagonal
272 *
273  colssq( 1 ) = zero
274  colssq( 2 ) = one
275  DO 130 j = 1, n
276  IF( real( ab( l, j ) ).NE.zero ) THEN
277  absa = abs( real( ab( l, j ) ) )
278  IF( colssq( 1 ).LT.absa ) THEN
279  colssq( 2 ) = one + colssq(2)*( colssq(1) / absa )**2
280  colssq( 1 ) = absa
281  ELSE
282  colssq( 2 ) = colssq( 2 ) + ( absa / colssq( 1 ) )**2
283  END IF
284  END IF
285  130 CONTINUE
286  CALL scombssq( ssq, colssq )
287  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
288  END IF
289 *
290  clanhb = VALUE
291  RETURN
292 *
293 * End of CLANHB
294 *
295  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 clanhb(NORM, UPLO, N, K, AB, LDAB, WORK)
CLANHB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: clanhb.f:132