KTH framework for Nek5000 toolboxes; testing version  0.0.1
dlansy.f
Go to the documentation of this file.
1  DOUBLE PRECISION FUNCTION dlansy( NORM, UPLO, N, A, LDA, WORK )
2 *
3 * -- LAPACK auxiliary routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * October 31, 1992
7 *
8 * .. Scalar Arguments ..
9  CHARACTER norm, uplo
10  INTEGER lda, n
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION a( lda, * ), work( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DLANSY returns the value of the one norm, or the Frobenius norm, or
20 * the infinity norm, or the element of largest absolute value of a
21 * real symmetric matrix A.
22 *
23 * Description
24 * ===========
25 *
26 * DLANSY returns the value
27 *
28 * DLANSY = ( max(abs(A(i,j))), NORM = 'M' or 'm'
29 * (
30 * ( norm1(A), NORM = '1', 'O' or 'o'
31 * (
32 * ( normI(A), NORM = 'I' or 'i'
33 * (
34 * ( normF(A), NORM = 'F', 'f', 'E' or 'e'
35 *
36 * where norm1 denotes the one norm of a matrix (maximum column sum),
37 * normI denotes the infinity norm of a matrix (maximum row sum) and
38 * normF denotes the Frobenius norm of a matrix (square root of sum of
39 * squares). Note that max(abs(A(i,j))) is not a matrix norm.
40 *
41 * Arguments
42 * =========
43 *
44 * NORM (input) CHARACTER*1
45 * Specifies the value to be returned in DLANSY as described
46 * above.
47 *
48 * UPLO (input) CHARACTER*1
49 * Specifies whether the upper or lower triangular part of the
50 * symmetric matrix A is to be referenced.
51 * = 'U': Upper triangular part of A is referenced
52 * = 'L': Lower triangular part of A is referenced
53 *
54 * N (input) INTEGER
55 * The order of the matrix A. N >= 0. When N = 0, DLANSY is
56 * set to zero.
57 *
58 * A (input) DOUBLE PRECISION array, dimension (LDA,N)
59 * The symmetric matrix A. If UPLO = 'U', the leading n by n
60 * upper triangular part of A contains the upper triangular part
61 * of the matrix A, and the strictly lower triangular part of A
62 * is not referenced. If UPLO = 'L', the leading n by n lower
63 * triangular part of A contains the lower triangular part of
64 * the matrix A, and the strictly upper triangular part of A is
65 * not referenced.
66 *
67 * LDA (input) INTEGER
68 * The leading dimension of the array A. LDA >= max(N,1).
69 *
70 * WORK (workspace) DOUBLE PRECISION array, dimension (LWORK),
71 * where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
72 * WORK is not referenced.
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77  DOUBLE PRECISION one, zero
78  parameter( one = 1.0d+0, zero = 0.0d+0 )
79 * ..
80 * .. Local Scalars ..
81  INTEGER i, j
82  DOUBLE PRECISION absa, scale, sum, value
83 * ..
84 * .. External Subroutines ..
85  EXTERNAL dlassq
86 * ..
87 * .. External Functions ..
88  LOGICAL lsame
89  EXTERNAL lsame
90 * ..
91 * .. Intrinsic Functions ..
92  INTRINSIC abs, max, sqrt
93 * ..
94 * .. Executable Statements ..
95 *
96  IF( n.EQ.0 ) THEN
97  VALUE = zero
98  ELSE IF( lsame( norm, 'M' ) ) THEN
99 *
100 * Find max(abs(A(i,j))).
101 *
102  VALUE = zero
103  IF( lsame( uplo, 'U' ) ) THEN
104  DO 20 j = 1, n
105  DO 10 i = 1, j
106  VALUE = max( VALUE, abs( a( i, j ) ) )
107  10 CONTINUE
108  20 CONTINUE
109  ELSE
110  DO 40 j = 1, n
111  DO 30 i = j, n
112  VALUE = max( VALUE, abs( a( i, j ) ) )
113  30 CONTINUE
114  40 CONTINUE
115  END IF
116  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
117  $ ( norm.EQ.'1' ) ) THEN
118 *
119 * Find normI(A) ( = norm1(A), since A is symmetric).
120 *
121  VALUE = zero
122  IF( lsame( uplo, 'U' ) ) THEN
123  DO 60 j = 1, n
124  sum = zero
125  DO 50 i = 1, j - 1
126  absa = abs( a( i, j ) )
127  sum = sum + absa
128  work( i ) = work( i ) + absa
129  50 CONTINUE
130  work( j ) = sum + abs( a( j, j ) )
131  60 CONTINUE
132  DO 70 i = 1, n
133  VALUE = max( VALUE, work( i ) )
134  70 CONTINUE
135  ELSE
136  DO 80 i = 1, n
137  work( i ) = zero
138  80 CONTINUE
139  DO 100 j = 1, n
140  sum = work( j ) + abs( a( j, j ) )
141  DO 90 i = j + 1, n
142  absa = abs( a( i, j ) )
143  sum = sum + absa
144  work( i ) = work( i ) + absa
145  90 CONTINUE
146  VALUE = max( VALUE, sum )
147  100 CONTINUE
148  END IF
149  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
150 *
151 * Find normF(A).
152 *
153  scale = zero
154  sum = one
155  IF( lsame( uplo, 'U' ) ) THEN
156  DO 110 j = 2, n
157  CALL dlassq( j-1, a( 1, j ), 1, scale, sum )
158  110 CONTINUE
159  ELSE
160  DO 120 j = 1, n - 1
161  CALL dlassq( n-j, a( j+1, j ), 1, scale, sum )
162  120 CONTINUE
163  END IF
164  sum = 2*sum
165  CALL dlassq( n, a, lda+1, scale, sum )
166  VALUE = scale*sqrt( sum )
167  END IF
168 *
169  dlansy = VALUE
170  RETURN
171 *
172 * End of DLANSY
173 *
174  END
subroutine scale(xyzl, nl)
Definition: connect2.f:602
double precision function dlansy(NORM, UPLO, N, A, LDA, WORK)
Definition: dlansy.f:2
subroutine dlassq(N, X, INCX, SCALE, SUMSQ)
Definition: dlassq.f:2
logical function lsame(CA, CB)
Definition: lsame.f:2