LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
 All Classes Files Functions Variables Typedefs Macros
slansy.f
Go to the documentation of this file.
1 *> \brief \b SLANSY 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 SLANSY + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slansy.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slansy.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slansy.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * REAL FUNCTION SLANSY( NORM, UPLO, N, A, LDA, WORK )
22 *
23 * .. Scalar Arguments ..
24 * CHARACTER NORM, UPLO
25 * INTEGER LDA, N
26 * ..
27 * .. Array Arguments ..
28 * REAL A( LDA, * ), WORK( * )
29 * ..
30 *
31 *
32 *> \par Purpose:
33 * =============
34 *>
35 *> \verbatim
36 *>
37 *> SLANSY 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 SLANSY
43 *> \verbatim
44 *>
45 *> SLANSY = ( 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 SLANSY 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, SLANSY is
82 *> set to zero.
83 *> \endverbatim
84 *>
85 *> \param[in] A
86 *> \verbatim
87 *> A is REAL 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 REAL 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 September 2012
119 *
120 *> \ingroup realSYauxiliary
121 *
122 * =====================================================================
123  REAL FUNCTION slansy( NORM, UPLO, N, A, LDA, WORK )
124 *
125 * -- LAPACK auxiliary routine (version 3.4.2) --
126 * -- LAPACK is a software package provided by Univ. of Tennessee, --
127 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
128 * September 2012
129 *
130 * .. Scalar Arguments ..
131  CHARACTER norm, uplo
132  INTEGER lda, n
133 * ..
134 * .. Array Arguments ..
135  REAL a( lda, * ), work( * )
136 * ..
137 *
138 * =====================================================================
139 *
140 * .. Parameters ..
141  REAL one, zero
142  parameter( one = 1.0e+0, zero = 0.0e+0 )
143 * ..
144 * .. Local Scalars ..
145  INTEGER i, j
146  REAL absa, scale, sum, value
147 * ..
148 * .. External Subroutines ..
149  EXTERNAL slassq
150 * ..
151 * .. External Functions ..
152  LOGICAL lsame, sisnan
153  EXTERNAL lsame, sisnan
154 * ..
155 * .. Intrinsic Functions ..
156  INTRINSIC abs, sqrt
157 * ..
158 * .. Executable Statements ..
159 *
160  IF( n.EQ.0 ) THEN
161  value = zero
162  ELSE IF( lsame( norm, 'M' ) ) THEN
163 *
164 * Find max(abs(A(i,j))).
165 *
166  value = zero
167  IF( lsame( uplo, 'U' ) ) THEN
168  DO 20 j = 1, n
169  DO 10 i = 1, j
170  sum = abs( a( i, j ) )
171  IF( value .LT. sum .OR. sisnan( sum ) ) value = sum
172  10 CONTINUE
173  20 CONTINUE
174  ELSE
175  DO 40 j = 1, n
176  DO 30 i = j, n
177  sum = abs( a( i, j ) )
178  IF( value .LT. sum .OR. sisnan( sum ) ) value = sum
179  30 CONTINUE
180  40 CONTINUE
181  END IF
182  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
183  $ ( norm.EQ.'1' ) ) THEN
184 *
185 * Find normI(A) ( = norm1(A), since A is symmetric).
186 *
187  value = zero
188  IF( lsame( uplo, 'U' ) ) THEN
189  DO 60 j = 1, n
190  sum = zero
191  DO 50 i = 1, j - 1
192  absa = abs( a( i, j ) )
193  sum = sum + absa
194  work( i ) = work( i ) + absa
195  50 CONTINUE
196  work( j ) = sum + abs( a( j, j ) )
197  60 CONTINUE
198  DO 70 i = 1, n
199  sum = work( i )
200  IF( value .LT. sum .OR. sisnan( sum ) ) value = sum
201  70 CONTINUE
202  ELSE
203  DO 80 i = 1, n
204  work( i ) = zero
205  80 CONTINUE
206  DO 100 j = 1, n
207  sum = work( j ) + abs( a( j, j ) )
208  DO 90 i = j + 1, n
209  absa = abs( a( i, j ) )
210  sum = sum + absa
211  work( i ) = work( i ) + absa
212  90 CONTINUE
213  IF( value .LT. sum .OR. sisnan( sum ) ) value = sum
214  100 CONTINUE
215  END IF
216  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
217 *
218 * Find normF(A).
219 *
220  scale = zero
221  sum = one
222  IF( lsame( uplo, 'U' ) ) THEN
223  DO 110 j = 2, n
224  CALL slassq( j-1, a( 1, j ), 1, scale, sum )
225  110 CONTINUE
226  ELSE
227  DO 120 j = 1, n - 1
228  CALL slassq( n-j, a( j+1, j ), 1, scale, sum )
229  120 CONTINUE
230  END IF
231  sum = 2*sum
232  CALL slassq( n, a, lda+1, scale, sum )
233  value = scale*sqrt( sum )
234  END IF
235 *
236  slansy = value
237  RETURN
238 *
239 * End of SLANSY
240 *
241  END