PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
zlanhe.f
Go to the documentation of this file.
1  DOUBLE PRECISION FUNCTION zlanhe( NORM, UPLO, N, A, LDA, WORK )
2 *
3 * -- LAPACK auxiliary routine (version 3.2) --
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
5 * November 2006
6 *
7 * .. Scalar Arguments ..
8  CHARACTER norm, uplo
9  INTEGER lda, n
10 * ..
11 * .. Array Arguments ..
12  DOUBLE PRECISION work( * )
13  COMPLEX*16 a( lda, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * ZLANHE 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 * complex hermitian matrix A.
22 *
23 * Description
24 * ===========
25 *
26 * ZLANHE returns the value
27 *
28 * ZLANHE = ( 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 consistent matrix norm.
40 *
41 * Arguments
42 * =========
43 *
44 * NORM (input) CHARACTER*1
45 * Specifies the value to be returned in ZLANHE as described
46 * above.
47 *
48 * UPLO (input) CHARACTER*1
49 * Specifies whether the upper or lower triangular part of the
50 * hermitian 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, ZLANHE is
56 * set to zero.
57 *
58 * A (input) COMPLEX*16 array, dimension (LDA,N)
59 * The hermitian 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. Note that the imaginary parts of the diagonal
66 * elements need not be set and are assumed to be zero.
67 *
68 * LDA (input) INTEGER
69 * The leading dimension of the array A. LDA >= max(N,1).
70 *
71 * WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
72 * where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
73 * WORK is not referenced.
74 *
75 * =====================================================================
76 *
77 * .. Parameters ..
78  DOUBLE PRECISION one, zero
79  parameter( one = 1.0d+0, zero = 0.0d+0 )
80 * ..
81 * .. Local Scalars ..
82  INTEGER i, j
83  DOUBLE PRECISION absa, scale, sum, value
84 * ..
85 * .. External Functions ..
86  LOGICAL lsame
87  EXTERNAL lsame
88 * ..
89 * .. External Subroutines ..
90  EXTERNAL zlassq
91 * ..
92 * .. Intrinsic Functions ..
93  INTRINSIC abs, dble, max, sqrt
94 * ..
95 * .. Executable Statements ..
96 *
97  IF( n.EQ.0 ) THEN
98  value = zero
99  ELSE IF( lsame( norm, 'M' ) ) THEN
100 *
101 * Find max(abs(A(i,j))).
102 *
103  value = zero
104  IF( lsame( uplo, 'U' ) ) THEN
105  DO 20 j = 1, n
106  DO 10 i = 1, j - 1
107  value = max( value, abs( a( i, j ) ) )
108  10 continue
109  value = max( value, abs( dble( a( j, j ) ) ) )
110  20 continue
111  ELSE
112  DO 40 j = 1, n
113  value = max( value, abs( dble( a( j, j ) ) ) )
114  DO 30 i = j + 1, n
115  value = max( value, abs( a( i, j ) ) )
116  30 continue
117  40 continue
118  END IF
119  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
120  $ ( norm.EQ.'1' ) ) THEN
121 *
122 * Find normI(A) ( = norm1(A), since A is hermitian).
123 *
124  value = zero
125  IF( lsame( uplo, 'U' ) ) THEN
126  DO 60 j = 1, n
127  sum = zero
128  DO 50 i = 1, j - 1
129  absa = abs( a( i, j ) )
130  sum = sum + absa
131  work( i ) = work( i ) + absa
132  50 continue
133  work( j ) = sum + abs( dble( a( j, j ) ) )
134  60 continue
135  DO 70 i = 1, n
136  value = max( value, work( i ) )
137  70 continue
138  ELSE
139  DO 80 i = 1, n
140  work( i ) = zero
141  80 continue
142  DO 100 j = 1, n
143  sum = work( j ) + abs( dble( a( j, j ) ) )
144  DO 90 i = j + 1, n
145  absa = abs( a( i, j ) )
146  sum = sum + absa
147  work( i ) = work( i ) + absa
148  90 continue
149  value = max( value, sum )
150  100 continue
151  END IF
152  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
153 *
154 * Find normF(A).
155 *
156  scale = zero
157  sum = one
158  IF( lsame( uplo, 'U' ) ) THEN
159  DO 110 j = 2, n
160  CALL zlassq( j-1, a( 1, j ), 1, scale, sum )
161  110 continue
162  ELSE
163  DO 120 j = 1, n - 1
164  CALL zlassq( n-j, a( j+1, j ), 1, scale, sum )
165  120 continue
166  END IF
167  sum = 2*sum
168  DO 130 i = 1, n
169  IF( dble( a( i, i ) ).NE.zero ) THEN
170  absa = abs( dble( a( i, i ) ) )
171  IF( scale.LT.absa ) THEN
172  sum = one + sum*( scale / absa )**2
173  scale = absa
174  ELSE
175  sum = sum + ( absa / scale )**2
176  END IF
177  END IF
178  130 continue
179  value = scale*sqrt( sum )
180  END IF
181 *
182  zlanhe = value
183  return
184 *
185 * End of ZLANHE
186 *
187  END