LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
clansp.f
Go to the documentation of this file.
1*> \brief \b CLANSP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a symmetric matrix supplied in packed form.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CLANSP + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clansp.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clansp.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clansp.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* REAL FUNCTION CLANSP( NORM, UPLO, N, AP, WORK )
20*
21* .. Scalar Arguments ..
22* CHARACTER NORM, UPLO
23* INTEGER N
24* ..
25* .. Array Arguments ..
26* REAL WORK( * )
27* COMPLEX AP( * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> CLANSP returns the value of the one norm, or the Frobenius norm, or
37*> the infinity norm, or the element of largest absolute value of a
38*> complex symmetric matrix A, supplied in packed form.
39*> \endverbatim
40*>
41*> \return CLANSP
42*> \verbatim
43*>
44*> CLANSP = ( max(abs(A(i,j))), NORM = 'M' or 'm'
45*> (
46*> ( norm1(A), NORM = '1', 'O' or 'o'
47*> (
48*> ( normI(A), NORM = 'I' or 'i'
49*> (
50*> ( normF(A), NORM = 'F', 'f', 'E' or 'e'
51*>
52*> where norm1 denotes the one norm of a matrix (maximum column sum),
53*> normI denotes the infinity norm of a matrix (maximum row sum) and
54*> normF denotes the Frobenius norm of a matrix (square root of sum of
55*> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.
56*> \endverbatim
57*
58* Arguments:
59* ==========
60*
61*> \param[in] NORM
62*> \verbatim
63*> NORM is CHARACTER*1
64*> Specifies the value to be returned in CLANSP as described
65*> above.
66*> \endverbatim
67*>
68*> \param[in] UPLO
69*> \verbatim
70*> UPLO is CHARACTER*1
71*> Specifies whether the upper or lower triangular part of the
72*> symmetric matrix A is supplied.
73*> = 'U': Upper triangular part of A is supplied
74*> = 'L': Lower triangular part of A is supplied
75*> \endverbatim
76*>
77*> \param[in] N
78*> \verbatim
79*> N is INTEGER
80*> The order of the matrix A. N >= 0. When N = 0, CLANSP is
81*> set to zero.
82*> \endverbatim
83*>
84*> \param[in] AP
85*> \verbatim
86*> AP is COMPLEX array, dimension (N*(N+1)/2)
87*> The upper or lower triangle of the symmetric matrix A, packed
88*> columnwise in a linear array. The j-th column of A is stored
89*> in the array AP as follows:
90*> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
91*> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
92*> \endverbatim
93*>
94*> \param[out] WORK
95*> \verbatim
96*> WORK is REAL array, dimension (MAX(1,LWORK)),
97*> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
98*> WORK is not referenced.
99*> \endverbatim
100*
101* Authors:
102* ========
103*
104*> \author Univ. of Tennessee
105*> \author Univ. of California Berkeley
106*> \author Univ. of Colorado Denver
107*> \author NAG Ltd.
108*
109*> \ingroup lanhp
110*
111* =====================================================================
112 REAL function clansp( norm, uplo, n, ap, work )
113*
114* -- LAPACK auxiliary routine --
115* -- LAPACK is a software package provided by Univ. of Tennessee, --
116* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
117*
118* .. Scalar Arguments ..
119 CHARACTER norm, uplo
120 INTEGER n
121* ..
122* .. Array Arguments ..
123 REAL work( * )
124 COMPLEX ap( * )
125* ..
126*
127* =====================================================================
128*
129* .. Parameters ..
130 REAL one, zero
131 parameter( one = 1.0e+0, zero = 0.0e+0 )
132* ..
133* .. Local Scalars ..
134 INTEGER i, j, k
135 REAL absa, scale, sum, value
136* ..
137* .. External Functions ..
138 LOGICAL lsame, sisnan
139 EXTERNAL lsame, sisnan
140* ..
141* .. External Subroutines ..
142 EXTERNAL classq
143* ..
144* .. Intrinsic Functions ..
145 INTRINSIC abs, aimag, real, sqrt
146* ..
147* .. Executable Statements ..
148*
149 IF( n.EQ.0 ) THEN
150 VALUE = zero
151 ELSE IF( lsame( norm, 'M' ) ) THEN
152*
153* Find max(abs(A(i,j))).
154*
155 VALUE = zero
156 IF( lsame( uplo, 'U' ) ) THEN
157 k = 1
158 DO 20 j = 1, n
159 DO 10 i = k, k + j - 1
160 sum = abs( ap( i ) )
161 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
162 10 CONTINUE
163 k = k + j
164 20 CONTINUE
165 ELSE
166 k = 1
167 DO 40 j = 1, n
168 DO 30 i = k, k + n - j
169 sum = abs( ap( i ) )
170 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
171 30 CONTINUE
172 k = k + n - j + 1
173 40 CONTINUE
174 END IF
175 ELSE IF( ( lsame( norm, 'I' ) ) .OR.
176 $ ( lsame( norm, 'O' ) ) .OR.
177 $ ( norm.EQ.'1' ) ) THEN
178*
179* Find normI(A) ( = norm1(A), since A is symmetric).
180*
181 VALUE = zero
182 k = 1
183 IF( lsame( uplo, 'U' ) ) THEN
184 DO 60 j = 1, n
185 sum = zero
186 DO 50 i = 1, j - 1
187 absa = abs( ap( k ) )
188 sum = sum + absa
189 work( i ) = work( i ) + absa
190 k = k + 1
191 50 CONTINUE
192 work( j ) = sum + abs( ap( k ) )
193 k = k + 1
194 60 CONTINUE
195 DO 70 i = 1, n
196 sum = work( i )
197 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
198 70 CONTINUE
199 ELSE
200 DO 80 i = 1, n
201 work( i ) = zero
202 80 CONTINUE
203 DO 100 j = 1, n
204 sum = work( j ) + abs( ap( k ) )
205 k = k + 1
206 DO 90 i = j + 1, n
207 absa = abs( ap( k ) )
208 sum = sum + absa
209 work( i ) = work( i ) + absa
210 k = k + 1
211 90 CONTINUE
212 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
213 100 CONTINUE
214 END IF
215 ELSE IF( ( lsame( norm, 'F' ) ) .OR.
216 $ ( lsame( norm, 'E' ) ) ) THEN
217*
218* Find normF(A).
219*
220 scale = zero
221 sum = one
222 k = 2
223 IF( lsame( uplo, 'U' ) ) THEN
224 DO 110 j = 2, n
225 CALL classq( j-1, ap( k ), 1, scale, sum )
226 k = k + j
227 110 CONTINUE
228 ELSE
229 DO 120 j = 1, n - 1
230 CALL classq( n-j, ap( k ), 1, scale, sum )
231 k = k + n - j + 1
232 120 CONTINUE
233 END IF
234 sum = 2*sum
235 k = 1
236 DO 130 i = 1, n
237 IF( real( ap( k ) ).NE.zero ) THEN
238 absa = abs( real( ap( k ) ) )
239 IF( scale.LT.absa ) THEN
240 sum = one + sum*( scale / absa )**2
241 scale = absa
242 ELSE
243 sum = sum + ( absa / scale )**2
244 END IF
245 END IF
246 IF( aimag( ap( k ) ).NE.zero ) THEN
247 absa = abs( aimag( ap( k ) ) )
248 IF( scale.LT.absa ) THEN
249 sum = one + sum*( scale / absa )**2
250 scale = absa
251 ELSE
252 sum = sum + ( absa / scale )**2
253 END IF
254 END IF
255 IF( lsame( uplo, 'U' ) ) THEN
256 k = k + i + 1
257 ELSE
258 k = k + n - i + 1
259 END IF
260 130 CONTINUE
261 VALUE = scale*sqrt( sum )
262 END IF
263*
264 clansp = VALUE
265 RETURN
266*
267* End of CLANSP
268*
269 END
logical function sisnan(sin)
SISNAN tests input for NaN.
Definition sisnan.f:57
real function clansp(norm, uplo, n, ap, work)
CLANSP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition clansp.f:113
subroutine classq(n, x, incx, scale, sumsq)
CLASSQ updates a sum of squares represented in scaled form.
Definition classq.f90:122
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48