1 /* ./src_f77/zlantr.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 
zlantr_(char * norm,char * uplo,char * diag,integer * m,integer * n,doublecomplex * a,integer * lda,doublereal * work,ftnlen norm_len,ftnlen uplo_len,ftnlen diag_len)12 doublereal zlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n,
13 	 doublecomplex *a, integer *lda, doublereal *work, ftnlen norm_len,
14 	ftnlen uplo_len, ftnlen diag_len)
15 {
16     /* System generated locals */
17     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
18     doublereal ret_val, d__1, d__2;
19 
20     /* Builtin functions */
21     double z_abs(doublecomplex *), sqrt(doublereal);
22 
23     /* Local variables */
24     static integer i__, j;
25     static doublereal sum, scale;
26     static logical udiag;
27     extern logical lsame_(char *, char *, ftnlen, ftnlen);
28     static doublereal value;
29     extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *,
30 	     doublereal *, doublereal *);
31 
32 
33 /*  -- LAPACK auxiliary routine (version 3.0) -- */
34 /*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
35 /*     Courant Institute, Argonne National Lab, and Rice University */
36 /*     October 31, 1992 */
37 
38 /*     .. Scalar Arguments .. */
39 /*     .. */
40 /*     .. Array Arguments .. */
41 /*     .. */
42 
43 /*  Purpose */
44 /*  ======= */
45 
46 /*  ZLANTR  returns the value of the one norm,  or the Frobenius norm, or */
47 /*  the  infinity norm,  or the  element of  largest absolute value  of a */
48 /*  trapezoidal or triangular matrix A. */
49 
50 /*  Description */
51 /*  =========== */
52 
53 /*  ZLANTR returns the value */
54 
55 /*     ZLANTR = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
56 /*              ( */
57 /*              ( norm1(A),         NORM = '1', 'O' or 'o' */
58 /*              ( */
59 /*              ( normI(A),         NORM = 'I' or 'i' */
60 /*              ( */
61 /*              ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
62 
63 /*  where  norm1  denotes the  one norm of a matrix (maximum column sum), */
64 /*  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
65 /*  normF  denotes the  Frobenius norm of a matrix (square root of sum of */
66 /*  squares).  Note that  max(abs(A(i,j)))  is not a  matrix norm. */
67 
68 /*  Arguments */
69 /*  ========= */
70 
71 /*  NORM    (input) CHARACTER*1 */
72 /*          Specifies the value to be returned in ZLANTR as described */
73 /*          above. */
74 
75 /*  UPLO    (input) CHARACTER*1 */
76 /*          Specifies whether the matrix A is upper or lower trapezoidal. */
77 /*          = 'U':  Upper trapezoidal */
78 /*          = 'L':  Lower trapezoidal */
79 /*          Note that A is triangular instead of trapezoidal if M = N. */
80 
81 /*  DIAG    (input) CHARACTER*1 */
82 /*          Specifies whether or not the matrix A has unit diagonal. */
83 /*          = 'N':  Non-unit diagonal */
84 /*          = 'U':  Unit diagonal */
85 
86 /*  M       (input) INTEGER */
87 /*          The number of rows of the matrix A.  M >= 0, and if */
88 /*          UPLO = 'U', M <= N.  When M = 0, ZLANTR is set to zero. */
89 
90 /*  N       (input) INTEGER */
91 /*          The number of columns of the matrix A.  N >= 0, and if */
92 /*          UPLO = 'L', N <= M.  When N = 0, ZLANTR is set to zero. */
93 
94 /*  A       (input) COMPLEX*16 array, dimension (LDA,N) */
95 /*          The trapezoidal matrix A (A is triangular if M = N). */
96 /*          If UPLO = 'U', the leading m by n upper trapezoidal part of */
97 /*          the array A contains the upper trapezoidal matrix, and the */
98 /*          strictly lower triangular part of A is not referenced. */
99 /*          If UPLO = 'L', the leading m by n lower trapezoidal part of */
100 /*          the array A contains the lower trapezoidal matrix, and the */
101 /*          strictly upper triangular part of A is not referenced.  Note */
102 /*          that when DIAG = 'U', the diagonal elements of A are not */
103 /*          referenced and are assumed to be one. */
104 
105 /*  LDA     (input) INTEGER */
106 /*          The leading dimension of the array A.  LDA >= max(M,1). */
107 
108 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK), */
109 /*          where LWORK >= M when NORM = 'I'; otherwise, WORK is not */
110 /*          referenced. */
111 
112 /* ===================================================================== */
113 
114 /*     .. Parameters .. */
115 /*     .. */
116 /*     .. Local Scalars .. */
117 /*     .. */
118 /*     .. External Functions .. */
119 /*     .. */
120 /*     .. External Subroutines .. */
121 /*     .. */
122 /*     .. Intrinsic Functions .. */
123 /*     .. */
124 /*     .. Executable Statements .. */
125 
126     /* Parameter adjustments */
127     a_dim1 = *lda;
128     a_offset = 1 + a_dim1;
129     a -= a_offset;
130     --work;
131 
132     /* Function Body */
133     if (min(*m,*n) == 0) {
134 	value = 0.;
135     } else if (lsame_(norm, "M", (ftnlen)1, (ftnlen)1)) {
136 
137 /*        Find max(abs(A(i,j))). */
138 
139 	if (lsame_(diag, "U", (ftnlen)1, (ftnlen)1)) {
140 	    value = 1.;
141 	    if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
142 		i__1 = *n;
143 		for (j = 1; j <= i__1; ++j) {
144 /* Computing MIN */
145 		    i__3 = *m, i__4 = j - 1;
146 		    i__2 = min(i__3,i__4);
147 		    for (i__ = 1; i__ <= i__2; ++i__) {
148 /* Computing MAX */
149 			d__1 = value, d__2 = z_abs(&a[i__ + j * a_dim1]);
150 			value = max(d__1,d__2);
151 /* L10: */
152 		    }
153 /* L20: */
154 		}
155 	    } else {
156 		i__1 = *n;
157 		for (j = 1; j <= i__1; ++j) {
158 		    i__2 = *m;
159 		    for (i__ = j + 1; i__ <= i__2; ++i__) {
160 /* Computing MAX */
161 			d__1 = value, d__2 = z_abs(&a[i__ + j * a_dim1]);
162 			value = max(d__1,d__2);
163 /* L30: */
164 		    }
165 /* L40: */
166 		}
167 	    }
168 	} else {
169 	    value = 0.;
170 	    if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
171 		i__1 = *n;
172 		for (j = 1; j <= i__1; ++j) {
173 		    i__2 = min(*m,j);
174 		    for (i__ = 1; i__ <= i__2; ++i__) {
175 /* Computing MAX */
176 			d__1 = value, d__2 = z_abs(&a[i__ + j * a_dim1]);
177 			value = max(d__1,d__2);
178 /* L50: */
179 		    }
180 /* L60: */
181 		}
182 	    } else {
183 		i__1 = *n;
184 		for (j = 1; j <= i__1; ++j) {
185 		    i__2 = *m;
186 		    for (i__ = j; i__ <= i__2; ++i__) {
187 /* Computing MAX */
188 			d__1 = value, d__2 = z_abs(&a[i__ + j * a_dim1]);
189 			value = max(d__1,d__2);
190 /* L70: */
191 		    }
192 /* L80: */
193 		}
194 	    }
195 	}
196     } else if (lsame_(norm, "O", (ftnlen)1, (ftnlen)1) || *(unsigned char *)
197 	    norm == '1') {
198 
199 /*        Find norm1(A). */
200 
201 	value = 0.;
202 	udiag = lsame_(diag, "U", (ftnlen)1, (ftnlen)1);
203 	if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
204 	    i__1 = *n;
205 	    for (j = 1; j <= i__1; ++j) {
206 		if (udiag && j <= *m) {
207 		    sum = 1.;
208 		    i__2 = j - 1;
209 		    for (i__ = 1; i__ <= i__2; ++i__) {
210 			sum += z_abs(&a[i__ + j * a_dim1]);
211 /* L90: */
212 		    }
213 		} else {
214 		    sum = 0.;
215 		    i__2 = min(*m,j);
216 		    for (i__ = 1; i__ <= i__2; ++i__) {
217 			sum += z_abs(&a[i__ + j * a_dim1]);
218 /* L100: */
219 		    }
220 		}
221 		value = max(value,sum);
222 /* L110: */
223 	    }
224 	} else {
225 	    i__1 = *n;
226 	    for (j = 1; j <= i__1; ++j) {
227 		if (udiag) {
228 		    sum = 1.;
229 		    i__2 = *m;
230 		    for (i__ = j + 1; i__ <= i__2; ++i__) {
231 			sum += z_abs(&a[i__ + j * a_dim1]);
232 /* L120: */
233 		    }
234 		} else {
235 		    sum = 0.;
236 		    i__2 = *m;
237 		    for (i__ = j; i__ <= i__2; ++i__) {
238 			sum += z_abs(&a[i__ + j * a_dim1]);
239 /* L130: */
240 		    }
241 		}
242 		value = max(value,sum);
243 /* L140: */
244 	    }
245 	}
246     } else if (lsame_(norm, "I", (ftnlen)1, (ftnlen)1)) {
247 
248 /*        Find normI(A). */
249 
250 	if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
251 	    if (lsame_(diag, "U", (ftnlen)1, (ftnlen)1)) {
252 		i__1 = *m;
253 		for (i__ = 1; i__ <= i__1; ++i__) {
254 		    work[i__] = 1.;
255 /* L150: */
256 		}
257 		i__1 = *n;
258 		for (j = 1; j <= i__1; ++j) {
259 /* Computing MIN */
260 		    i__3 = *m, i__4 = j - 1;
261 		    i__2 = min(i__3,i__4);
262 		    for (i__ = 1; i__ <= i__2; ++i__) {
263 			work[i__] += z_abs(&a[i__ + j * a_dim1]);
264 /* L160: */
265 		    }
266 /* L170: */
267 		}
268 	    } else {
269 		i__1 = *m;
270 		for (i__ = 1; i__ <= i__1; ++i__) {
271 		    work[i__] = 0.;
272 /* L180: */
273 		}
274 		i__1 = *n;
275 		for (j = 1; j <= i__1; ++j) {
276 		    i__2 = min(*m,j);
277 		    for (i__ = 1; i__ <= i__2; ++i__) {
278 			work[i__] += z_abs(&a[i__ + j * a_dim1]);
279 /* L190: */
280 		    }
281 /* L200: */
282 		}
283 	    }
284 	} else {
285 	    if (lsame_(diag, "U", (ftnlen)1, (ftnlen)1)) {
286 		i__1 = *n;
287 		for (i__ = 1; i__ <= i__1; ++i__) {
288 		    work[i__] = 1.;
289 /* L210: */
290 		}
291 		i__1 = *m;
292 		for (i__ = *n + 1; i__ <= i__1; ++i__) {
293 		    work[i__] = 0.;
294 /* L220: */
295 		}
296 		i__1 = *n;
297 		for (j = 1; j <= i__1; ++j) {
298 		    i__2 = *m;
299 		    for (i__ = j + 1; i__ <= i__2; ++i__) {
300 			work[i__] += z_abs(&a[i__ + j * a_dim1]);
301 /* L230: */
302 		    }
303 /* L240: */
304 		}
305 	    } else {
306 		i__1 = *m;
307 		for (i__ = 1; i__ <= i__1; ++i__) {
308 		    work[i__] = 0.;
309 /* L250: */
310 		}
311 		i__1 = *n;
312 		for (j = 1; j <= i__1; ++j) {
313 		    i__2 = *m;
314 		    for (i__ = j; i__ <= i__2; ++i__) {
315 			work[i__] += z_abs(&a[i__ + j * a_dim1]);
316 /* L260: */
317 		    }
318 /* L270: */
319 		}
320 	    }
321 	}
322 	value = 0.;
323 	i__1 = *m;
324 	for (i__ = 1; i__ <= i__1; ++i__) {
325 /* Computing MAX */
326 	    d__1 = value, d__2 = work[i__];
327 	    value = max(d__1,d__2);
328 /* L280: */
329 	}
330     } else if (lsame_(norm, "F", (ftnlen)1, (ftnlen)1) || lsame_(norm, "E", (
331 	    ftnlen)1, (ftnlen)1)) {
332 
333 /*        Find normF(A). */
334 
335 	if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
336 	    if (lsame_(diag, "U", (ftnlen)1, (ftnlen)1)) {
337 		scale = 1.;
338 		sum = (doublereal) min(*m,*n);
339 		i__1 = *n;
340 		for (j = 2; j <= i__1; ++j) {
341 /* Computing MIN */
342 		    i__3 = *m, i__4 = j - 1;
343 		    i__2 = min(i__3,i__4);
344 		    zlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
345 /* L290: */
346 		}
347 	    } else {
348 		scale = 0.;
349 		sum = 1.;
350 		i__1 = *n;
351 		for (j = 1; j <= i__1; ++j) {
352 		    i__2 = min(*m,j);
353 		    zlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
354 /* L300: */
355 		}
356 	    }
357 	} else {
358 	    if (lsame_(diag, "U", (ftnlen)1, (ftnlen)1)) {
359 		scale = 1.;
360 		sum = (doublereal) min(*m,*n);
361 		i__1 = *n;
362 		for (j = 1; j <= i__1; ++j) {
363 		    i__2 = *m - j;
364 /* Computing MIN */
365 		    i__3 = *m, i__4 = j + 1;
366 		    zlassq_(&i__2, &a[min(i__3,i__4) + j * a_dim1], &c__1, &
367 			    scale, &sum);
368 /* L310: */
369 		}
370 	    } else {
371 		scale = 0.;
372 		sum = 1.;
373 		i__1 = *n;
374 		for (j = 1; j <= i__1; ++j) {
375 		    i__2 = *m - j + 1;
376 		    zlassq_(&i__2, &a[j + j * a_dim1], &c__1, &scale, &sum);
377 /* L320: */
378 		}
379 	    }
380 	}
381 	value = scale * sqrt(sum);
382     }
383 
384     ret_val = value;
385     return ret_val;
386 
387 /*     End of ZLANTR */
388 
389 } /* zlantr_ */
390 
391