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