1 /* ./src_f77/clanhs.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 /* Table of constant values */
9
10 static integer c__1 = 1;
11
clanhs_(char * norm,integer * n,complex * a,integer * lda,real * work,ftnlen norm_len)12 doublereal clanhs_(char *norm, integer *n, complex *a, integer *lda, real *
13 work, ftnlen norm_len)
14 {
15 /* System generated locals */
16 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
17 real ret_val, r__1, r__2;
18
19 /* Builtin functions */
20 double c_abs(complex *), sqrt(doublereal);
21
22 /* Local variables */
23 static integer i__, j;
24 static real sum, scale;
25 extern logical lsame_(char *, char *, ftnlen, ftnlen);
26 static real value;
27 extern /* Subroutine */ int classq_(integer *, complex *, integer *, real
28 *, real *);
29
30
31 /* -- LAPACK auxiliary routine (version 3.0) -- */
32 /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
33 /* Courant Institute, Argonne National Lab, and Rice University */
34 /* October 31, 1992 */
35
36 /* .. Scalar Arguments .. */
37 /* .. */
38 /* .. Array Arguments .. */
39 /* .. */
40
41 /* Purpose */
42 /* ======= */
43
44 /* CLANHS returns the value of the one norm, or the Frobenius norm, or */
45 /* the infinity norm, or the element of largest absolute value of a */
46 /* Hessenberg matrix A. */
47
48 /* Description */
49 /* =========== */
50
51 /* CLANHS returns the value */
52
53 /* CLANHS = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
54 /* ( */
55 /* ( norm1(A), NORM = '1', 'O' or 'o' */
56 /* ( */
57 /* ( normI(A), NORM = 'I' or 'i' */
58 /* ( */
59 /* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */
60
61 /* where norm1 denotes the one norm of a matrix (maximum column sum), */
62 /* normI denotes the infinity norm of a matrix (maximum row sum) and */
63 /* normF denotes the Frobenius norm of a matrix (square root of sum of */
64 /* squares). Note that max(abs(A(i,j))) is not a matrix norm. */
65
66 /* Arguments */
67 /* ========= */
68
69 /* NORM (input) CHARACTER*1 */
70 /* Specifies the value to be returned in CLANHS as described */
71 /* above. */
72
73 /* N (input) INTEGER */
74 /* The order of the matrix A. N >= 0. When N = 0, CLANHS is */
75 /* set to zero. */
76
77 /* A (input) COMPLEX array, dimension (LDA,N) */
78 /* The n by n upper Hessenberg matrix A; the part of A below the */
79 /* first sub-diagonal is not referenced. */
80
81 /* LDA (input) INTEGER */
82 /* The leading dimension of the array A. LDA >= max(N,1). */
83
84 /* WORK (workspace) REAL array, dimension (LWORK), */
85 /* where LWORK >= N when NORM = 'I'; otherwise, WORK is not */
86 /* referenced. */
87
88 /* ===================================================================== */
89
90 /* .. Parameters .. */
91 /* .. */
92 /* .. Local Scalars .. */
93 /* .. */
94 /* .. External Functions .. */
95 /* .. */
96 /* .. External Subroutines .. */
97 /* .. */
98 /* .. Intrinsic Functions .. */
99 /* .. */
100 /* .. Executable Statements .. */
101
102 /* Parameter adjustments */
103 a_dim1 = *lda;
104 a_offset = 1 + a_dim1;
105 a -= a_offset;
106 --work;
107
108 /* Function Body */
109 if (*n == 0) {
110 value = 0.f;
111 } else if (lsame_(norm, "M", (ftnlen)1, (ftnlen)1)) {
112
113 /* Find max(abs(A(i,j))). */
114
115 value = 0.f;
116 i__1 = *n;
117 for (j = 1; j <= i__1; ++j) {
118 /* Computing MIN */
119 i__3 = *n, i__4 = j + 1;
120 i__2 = min(i__3,i__4);
121 for (i__ = 1; i__ <= i__2; ++i__) {
122 /* Computing MAX */
123 r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]);
124 value = dmax(r__1,r__2);
125 /* L10: */
126 }
127 /* L20: */
128 }
129 } else if (lsame_(norm, "O", (ftnlen)1, (ftnlen)1) || *(unsigned char *)
130 norm == '1') {
131
132 /* Find norm1(A). */
133
134 value = 0.f;
135 i__1 = *n;
136 for (j = 1; j <= i__1; ++j) {
137 sum = 0.f;
138 /* Computing MIN */
139 i__3 = *n, i__4 = j + 1;
140 i__2 = min(i__3,i__4);
141 for (i__ = 1; i__ <= i__2; ++i__) {
142 sum += c_abs(&a[i__ + j * a_dim1]);
143 /* L30: */
144 }
145 value = dmax(value,sum);
146 /* L40: */
147 }
148 } else if (lsame_(norm, "I", (ftnlen)1, (ftnlen)1)) {
149
150 /* Find normI(A). */
151
152 i__1 = *n;
153 for (i__ = 1; i__ <= i__1; ++i__) {
154 work[i__] = 0.f;
155 /* L50: */
156 }
157 i__1 = *n;
158 for (j = 1; j <= i__1; ++j) {
159 /* Computing MIN */
160 i__3 = *n, i__4 = j + 1;
161 i__2 = min(i__3,i__4);
162 for (i__ = 1; i__ <= i__2; ++i__) {
163 work[i__] += c_abs(&a[i__ + j * a_dim1]);
164 /* L60: */
165 }
166 /* L70: */
167 }
168 value = 0.f;
169 i__1 = *n;
170 for (i__ = 1; i__ <= i__1; ++i__) {
171 /* Computing MAX */
172 r__1 = value, r__2 = work[i__];
173 value = dmax(r__1,r__2);
174 /* L80: */
175 }
176 } else if (lsame_(norm, "F", (ftnlen)1, (ftnlen)1) || lsame_(norm, "E", (
177 ftnlen)1, (ftnlen)1)) {
178
179 /* Find normF(A). */
180
181 scale = 0.f;
182 sum = 1.f;
183 i__1 = *n;
184 for (j = 1; j <= i__1; ++j) {
185 /* Computing MIN */
186 i__3 = *n, i__4 = j + 1;
187 i__2 = min(i__3,i__4);
188 classq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
189 /* L90: */
190 }
191 value = scale * sqrt(sum);
192 }
193
194 ret_val = value;
195 return ret_val;
196
197 /* End of CLANHS */
198
199 } /* clanhs_ */
200
201