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