LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dlansy.f
Go to the documentation of this file.
1*> \brief \b DLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real symmetric matrix.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DLANSY + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlansy.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlansy.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlansy.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* DOUBLE PRECISION FUNCTION DLANSY( NORM, UPLO, N, A, LDA, WORK )
20*
21* .. Scalar Arguments ..
22* CHARACTER NORM, UPLO
23* INTEGER LDA, N
24* ..
25* .. Array Arguments ..
26* DOUBLE PRECISION A( LDA, * ), WORK( * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> DLANSY 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.
38*> \endverbatim
39*>
40*> \return DLANSY
41*> \verbatim
42*>
43*> DLANSY = ( 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 DLANSY 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 to be referenced.
72*> = 'U': Upper triangular part of A is referenced
73*> = 'L': Lower triangular part of A is referenced
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, DLANSY is
80*> set to zero.
81*> \endverbatim
82*>
83*> \param[in] A
84*> \verbatim
85*> A is DOUBLE PRECISION array, dimension (LDA,N)
86*> The symmetric matrix A. If UPLO = 'U', the leading n by n
87*> upper triangular part of A contains the upper triangular part
88*> of the matrix A, and the strictly lower triangular part of A
89*> is not referenced. If UPLO = 'L', the leading n by n lower
90*> triangular part of A contains the lower triangular part of
91*> the matrix A, and the strictly upper triangular part of A is
92*> not referenced.
93*> \endverbatim
94*>
95*> \param[in] LDA
96*> \verbatim
97*> LDA is INTEGER
98*> The leading dimension of the array A. LDA >= max(N,1).
99*> \endverbatim
100*>
101*> \param[out] WORK
102*> \verbatim
103*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
104*> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
105*> WORK is not referenced.
106*> \endverbatim
107*
108* Authors:
109* ========
110*
111*> \author Univ. of Tennessee
112*> \author Univ. of California Berkeley
113*> \author Univ. of Colorado Denver
114*> \author NAG Ltd.
115*
116*> \ingroup lanhe
117*
118* =====================================================================
119 DOUBLE PRECISION FUNCTION dlansy( NORM, UPLO, N, A, LDA, WORK )
120*
121* -- LAPACK auxiliary routine --
122* -- LAPACK is a software package provided by Univ. of Tennessee, --
123* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
124*
125* .. Scalar Arguments ..
126 CHARACTER norm, uplo
127 INTEGER lda, n
128* ..
129* .. Array Arguments ..
130 DOUBLE PRECISION a( lda, * ), work( * )
131* ..
132*
133* =====================================================================
134*
135* .. Parameters ..
136 DOUBLE PRECISION one, zero
137 parameter( one = 1.0d+0, zero = 0.0d+0 )
138* ..
139* .. Local Scalars ..
140 INTEGER i, j
141 DOUBLE PRECISION absa, scale, sum, value
142* ..
143* .. External Subroutines ..
144 EXTERNAL dlassq
145* ..
146* .. External Functions ..
147 LOGICAL lsame, disnan
148 EXTERNAL lsame, disnan
149* ..
150* .. Intrinsic Functions ..
151 INTRINSIC abs, sqrt
152* ..
153* .. Executable Statements ..
154*
155 IF( n.EQ.0 ) THEN
156 VALUE = zero
157 ELSE IF( lsame( norm, 'M' ) ) THEN
158*
159* Find max(abs(A(i,j))).
160*
161 VALUE = zero
162 IF( lsame( uplo, 'U' ) ) THEN
163 DO 20 j = 1, n
164 DO 10 i = 1, j
165 sum = abs( a( i, j ) )
166 IF( VALUE .LT. sum .OR. disnan( sum ) ) VALUE = sum
167 10 CONTINUE
168 20 CONTINUE
169 ELSE
170 DO 40 j = 1, n
171 DO 30 i = j, n
172 sum = abs( a( i, j ) )
173 IF( VALUE .LT. sum .OR. disnan( sum ) ) VALUE = sum
174 30 CONTINUE
175 40 CONTINUE
176 END IF
177 ELSE IF( ( lsame( norm, 'I' ) ) .OR.
178 $ ( lsame( norm, 'O' ) ) .OR.
179 $ ( norm.EQ.'1' ) ) THEN
180*
181* Find normI(A) ( = norm1(A), since A is symmetric).
182*
183 VALUE = zero
184 IF( lsame( uplo, 'U' ) ) THEN
185 DO 60 j = 1, n
186 sum = zero
187 DO 50 i = 1, j - 1
188 absa = abs( a( i, j ) )
189 sum = sum + absa
190 work( i ) = work( i ) + absa
191 50 CONTINUE
192 work( j ) = sum + abs( a( j, j ) )
193 60 CONTINUE
194 DO 70 i = 1, n
195 sum = work( i )
196 IF( VALUE .LT. sum .OR. disnan( sum ) ) VALUE = sum
197 70 CONTINUE
198 ELSE
199 DO 80 i = 1, n
200 work( i ) = zero
201 80 CONTINUE
202 DO 100 j = 1, n
203 sum = work( j ) + abs( a( j, j ) )
204 DO 90 i = j + 1, n
205 absa = abs( a( i, j ) )
206 sum = sum + absa
207 work( i ) = work( i ) + absa
208 90 CONTINUE
209 IF( VALUE .LT. sum .OR. disnan( sum ) ) VALUE = sum
210 100 CONTINUE
211 END IF
212 ELSE IF( ( lsame( norm, 'F' ) ) .OR.
213 $ ( lsame( norm, 'E' ) ) ) THEN
214*
215* Find normF(A).
216*
217 scale = zero
218 sum = one
219 IF( lsame( uplo, 'U' ) ) THEN
220 DO 110 j = 2, n
221 CALL dlassq( j-1, a( 1, j ), 1, scale, sum )
222 110 CONTINUE
223 ELSE
224 DO 120 j = 1, n - 1
225 CALL dlassq( n-j, a( j+1, j ), 1, scale, sum )
226 120 CONTINUE
227 END IF
228 sum = 2*sum
229 CALL dlassq( n, a, lda+1, scale, sum )
230 VALUE = scale*sqrt( sum )
231 END IF
232*
233 dlansy = VALUE
234 RETURN
235*
236* End of DLANSY
237*
238 END
logical function disnan(din)
DISNAN tests input for NaN.
Definition disnan.f:57
double precision function dlansy(norm, uplo, n, a, lda, work)
DLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition dlansy.f:120
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