C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / lapack-netlib / SRC / clanhf.c
1 #include <math.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <complex.h>
6 #ifdef complex
7 #undef complex
8 #endif
9 #ifdef I
10 #undef I
11 #endif
12
13 #if defined(_WIN64)
14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
16 #else
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
19 #endif
20
21 #ifdef LAPACK_ILP64
22 typedef BLASLONG blasint;
23 #if defined(_WIN64)
24 #define blasabs(x) llabs(x)
25 #else
26 #define blasabs(x) labs(x)
27 #endif
28 #else
29 typedef int blasint;
30 #define blasabs(x) abs(x)
31 #endif
32
33 typedef blasint integer;
34
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
38 typedef float real;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
42 #ifdef _MSC_VER
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
47 #else
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
52 #endif
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
55 typedef int logical;
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
59
60 #define TRUE_ (1)
61 #define FALSE_ (0)
62
63 /* Extern is for use with -E */
64 #ifndef Extern
65 #define Extern extern
66 #endif
67
68 /* I/O stuff */
69
70 typedef int flag;
71 typedef int ftnlen;
72 typedef int ftnint;
73
74 /*external read, write*/
75 typedef struct
76 {       flag cierr;
77         ftnint ciunit;
78         flag ciend;
79         char *cifmt;
80         ftnint cirec;
81 } cilist;
82
83 /*internal read, write*/
84 typedef struct
85 {       flag icierr;
86         char *iciunit;
87         flag iciend;
88         char *icifmt;
89         ftnint icirlen;
90         ftnint icirnum;
91 } icilist;
92
93 /*open*/
94 typedef struct
95 {       flag oerr;
96         ftnint ounit;
97         char *ofnm;
98         ftnlen ofnmlen;
99         char *osta;
100         char *oacc;
101         char *ofm;
102         ftnint orl;
103         char *oblnk;
104 } olist;
105
106 /*close*/
107 typedef struct
108 {       flag cerr;
109         ftnint cunit;
110         char *csta;
111 } cllist;
112
113 /*rewind, backspace, endfile*/
114 typedef struct
115 {       flag aerr;
116         ftnint aunit;
117 } alist;
118
119 /* inquire */
120 typedef struct
121 {       flag inerr;
122         ftnint inunit;
123         char *infile;
124         ftnlen infilen;
125         ftnint  *inex;  /*parameters in standard's order*/
126         ftnint  *inopen;
127         ftnint  *innum;
128         ftnint  *innamed;
129         char    *inname;
130         ftnlen  innamlen;
131         char    *inacc;
132         ftnlen  inacclen;
133         char    *inseq;
134         ftnlen  inseqlen;
135         char    *indir;
136         ftnlen  indirlen;
137         char    *infmt;
138         ftnlen  infmtlen;
139         char    *inform;
140         ftnint  informlen;
141         char    *inunf;
142         ftnlen  inunflen;
143         ftnint  *inrecl;
144         ftnint  *innrec;
145         char    *inblank;
146         ftnlen  inblanklen;
147 } inlist;
148
149 #define VOID void
150
151 union Multitype {       /* for multiple entry points */
152         integer1 g;
153         shortint h;
154         integer i;
155         /* longint j; */
156         real r;
157         doublereal d;
158         complex c;
159         doublecomplex z;
160         };
161
162 typedef union Multitype Multitype;
163
164 struct Vardesc {        /* for Namelist */
165         char *name;
166         char *addr;
167         ftnlen *dims;
168         int  type;
169         };
170 typedef struct Vardesc Vardesc;
171
172 struct Namelist {
173         char *name;
174         Vardesc **vars;
175         int nvars;
176         };
177 typedef struct Namelist Namelist;
178
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b)   ((a) >> (b) & 1)
186 #define bit_clear(a,b)  ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b)    ((a) |  ((uinteger)1 << (b)))
188
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
192 #ifdef _MSC_VER
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
195 #else
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
198 #endif
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) {         ftnlen i, nc, ll; char *f__rp, *lp;     ll = (llp); lp = (lpp);         for(i=0; i < (int)*(np); ++i) {                 nc = ll;                if((rnp)[i] < nc) nc = (rnp)[i];                ll -= nc;               f__rp = (rpp)[i];               while(--nc >= 0) *lp++ = *(f__rp)++;         }  while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
260
261 /* procedure parameter types for -A and -C++ */
262
263 #define F2C_proc_par_types 1
264 #ifdef __cplusplus
265 typedef logical (*L_fp)(...);
266 #else
267 typedef logical (*L_fp)();
268 #endif
269
270 static float spow_ui(float x, integer n) {
271         float pow=1.0; unsigned long int u;
272         if(n != 0) {
273                 if(n < 0) n = -n, x = 1/x;
274                 for(u = n; ; ) {
275                         if(u & 01) pow *= x;
276                         if(u >>= 1) x *= x;
277                         else break;
278                 }
279         }
280         return pow;
281 }
282 static double dpow_ui(double x, integer n) {
283         double pow=1.0; unsigned long int u;
284         if(n != 0) {
285                 if(n < 0) n = -n, x = 1/x;
286                 for(u = n; ; ) {
287                         if(u & 01) pow *= x;
288                         if(u >>= 1) x *= x;
289                         else break;
290                 }
291         }
292         return pow;
293 }
294 #ifdef _MSC_VER
295 static _Fcomplex cpow_ui(complex x, integer n) {
296         complex pow={1.0,0.0}; unsigned long int u;
297                 if(n != 0) {
298                 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
299                 for(u = n; ; ) {
300                         if(u & 01) pow.r *= x.r, pow.i *= x.i;
301                         if(u >>= 1) x.r *= x.r, x.i *= x.i;
302                         else break;
303                 }
304         }
305         _Fcomplex p={pow.r, pow.i};
306         return p;
307 }
308 #else
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310         _Complex float pow=1.0; unsigned long int u;
311         if(n != 0) {
312                 if(n < 0) n = -n, x = 1/x;
313                 for(u = n; ; ) {
314                         if(u & 01) pow *= x;
315                         if(u >>= 1) x *= x;
316                         else break;
317                 }
318         }
319         return pow;
320 }
321 #endif
322 #ifdef _MSC_VER
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324         _Dcomplex pow={1.0,0.0}; unsigned long int u;
325         if(n != 0) {
326                 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
327                 for(u = n; ; ) {
328                         if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329                         if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
330                         else break;
331                 }
332         }
333         _Dcomplex p = {pow._Val[0], pow._Val[1]};
334         return p;
335 }
336 #else
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338         _Complex double pow=1.0; unsigned long int u;
339         if(n != 0) {
340                 if(n < 0) n = -n, x = 1/x;
341                 for(u = n; ; ) {
342                         if(u & 01) pow *= x;
343                         if(u >>= 1) x *= x;
344                         else break;
345                 }
346         }
347         return pow;
348 }
349 #endif
350 static integer pow_ii(integer x, integer n) {
351         integer pow; unsigned long int u;
352         if (n <= 0) {
353                 if (n == 0 || x == 1) pow = 1;
354                 else if (x != -1) pow = x == 0 ? 1/x : 0;
355                 else n = -n;
356         }
357         if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
358                 u = n;
359                 for(pow = 1; ; ) {
360                         if(u & 01) pow *= x;
361                         if(u >>= 1) x *= x;
362                         else break;
363                 }
364         }
365         return pow;
366 }
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
368 {
369         double m; integer i, mi;
370         for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371                 if (w[i-1]>m) mi=i ,m=w[i-1];
372         return mi-s+1;
373 }
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
375 {
376         float m; integer i, mi;
377         for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378                 if (w[i-1]>m) mi=i ,m=w[i-1];
379         return mi-s+1;
380 }
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382         integer n = *n_, incx = *incx_, incy = *incy_, i;
383 #ifdef _MSC_VER
384         _Fcomplex zdotc = {0.0, 0.0};
385         if (incx == 1 && incy == 1) {
386                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387                         zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388                         zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
389                 }
390         } else {
391                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392                         zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393                         zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
394                 }
395         }
396         pCf(z) = zdotc;
397 }
398 #else
399         _Complex float zdotc = 0.0;
400         if (incx == 1 && incy == 1) {
401                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402                         zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
403                 }
404         } else {
405                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406                         zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
407                 }
408         }
409         pCf(z) = zdotc;
410 }
411 #endif
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413         integer n = *n_, incx = *incx_, incy = *incy_, i;
414 #ifdef _MSC_VER
415         _Dcomplex zdotc = {0.0, 0.0};
416         if (incx == 1 && incy == 1) {
417                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418                         zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419                         zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
420                 }
421         } else {
422                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423                         zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424                         zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
425                 }
426         }
427         pCd(z) = zdotc;
428 }
429 #else
430         _Complex double zdotc = 0.0;
431         if (incx == 1 && incy == 1) {
432                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433                         zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
434                 }
435         } else {
436                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437                         zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
438                 }
439         }
440         pCd(z) = zdotc;
441 }
442 #endif  
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444         integer n = *n_, incx = *incx_, incy = *incy_, i;
445 #ifdef _MSC_VER
446         _Fcomplex zdotc = {0.0, 0.0};
447         if (incx == 1 && incy == 1) {
448                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449                         zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450                         zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
451                 }
452         } else {
453                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454                         zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455                         zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
456                 }
457         }
458         pCf(z) = zdotc;
459 }
460 #else
461         _Complex float zdotc = 0.0;
462         if (incx == 1 && incy == 1) {
463                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464                         zdotc += Cf(&x[i]) * Cf(&y[i]);
465                 }
466         } else {
467                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468                         zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
469                 }
470         }
471         pCf(z) = zdotc;
472 }
473 #endif
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475         integer n = *n_, incx = *incx_, incy = *incy_, i;
476 #ifdef _MSC_VER
477         _Dcomplex zdotc = {0.0, 0.0};
478         if (incx == 1 && incy == 1) {
479                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480                         zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481                         zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
482                 }
483         } else {
484                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485                         zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486                         zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
487                 }
488         }
489         pCd(z) = zdotc;
490 }
491 #else
492         _Complex double zdotc = 0.0;
493         if (incx == 1 && incy == 1) {
494                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495                         zdotc += Cd(&x[i]) * Cd(&y[i]);
496                 }
497         } else {
498                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499                         zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
500                 }
501         }
502         pCd(z) = zdotc;
503 }
504 #endif
505 /*  -- translated by f2c (version 20000121).
506    You must link the resulting object file with the libraries:
507         -lf2c -lm   (in that order)
508 */
509
510
511
512
513 /* Table of constant values */
514
515 static integer c__1 = 1;
516
517 /* > \brief \b CLANHF returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the ele
518 ment of largest absolute value of a Hermitian matrix in RFP format. */
519
520 /*  =========== DOCUMENTATION =========== */
521
522 /* Online html documentation available at */
523 /*            http://www.netlib.org/lapack/explore-html/ */
524
525 /* > \htmlonly */
526 /* > Download CLANHF + dependencies */
527 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clanhf.
528 f"> */
529 /* > [TGZ]</a> */
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clanhf.
531 f"> */
532 /* > [ZIP]</a> */
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clanhf.
534 f"> */
535 /* > [TXT]</a> */
536 /* > \endhtmlonly */
537
538 /*  Definition: */
539 /*  =========== */
540
541 /*       REAL FUNCTION CLANHF( NORM, TRANSR, UPLO, N, A, WORK ) */
542
543 /*       CHARACTER          NORM, TRANSR, UPLO */
544 /*       INTEGER            N */
545 /*       REAL               WORK( 0: * ) */
546 /*       COMPLEX            A( 0: * ) */
547
548
549 /* > \par Purpose: */
550 /*  ============= */
551 /* > */
552 /* > \verbatim */
553 /* > */
554 /* > CLANHF  returns the value of the one norm,  or the Frobenius norm, or */
555 /* > the  infinity norm,  or the  element of  largest absolute value  of a */
556 /* > complex Hermitian matrix A in RFP format. */
557 /* > \endverbatim */
558 /* > */
559 /* > \return CLANHF */
560 /* > \verbatim */
561 /* > */
562 /* >    CLANHF = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */
563 /* >             ( */
564 /* >             ( norm1(A),         NORM = '1', 'O' or 'o' */
565 /* >             ( */
566 /* >             ( normI(A),         NORM = 'I' or 'i' */
567 /* >             ( */
568 /* >             ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
569 /* > */
570 /* > where  norm1  denotes the  one norm of a matrix (maximum column sum), */
571 /* > normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
572 /* > normF  denotes the  Frobenius norm of a matrix (square root of sum of */
573 /* > squares).  Note that  f2cmax(abs(A(i,j)))  is not a  matrix norm. */
574 /* > \endverbatim */
575
576 /*  Arguments: */
577 /*  ========== */
578
579 /* > \param[in] NORM */
580 /* > \verbatim */
581 /* >          NORM is CHARACTER */
582 /* >            Specifies the value to be returned in CLANHF as described */
583 /* >            above. */
584 /* > \endverbatim */
585 /* > */
586 /* > \param[in] TRANSR */
587 /* > \verbatim */
588 /* >          TRANSR is CHARACTER */
589 /* >            Specifies whether the RFP format of A is normal or */
590 /* >            conjugate-transposed format. */
591 /* >            = 'N':  RFP format is Normal */
592 /* >            = 'C':  RFP format is Conjugate-transposed */
593 /* > \endverbatim */
594 /* > */
595 /* > \param[in] UPLO */
596 /* > \verbatim */
597 /* >          UPLO is CHARACTER */
598 /* >            On entry, UPLO specifies whether the RFP matrix A came from */
599 /* >            an upper or lower triangular matrix as follows: */
600 /* > */
601 /* >            UPLO = 'U' or 'u' RFP A came from an upper triangular */
602 /* >            matrix */
603 /* > */
604 /* >            UPLO = 'L' or 'l' RFP A came from a  lower triangular */
605 /* >            matrix */
606 /* > \endverbatim */
607 /* > */
608 /* > \param[in] N */
609 /* > \verbatim */
610 /* >          N is INTEGER */
611 /* >            The order of the matrix A.  N >= 0.  When N = 0, CLANHF is */
612 /* >            set to zero. */
613 /* > \endverbatim */
614 /* > */
615 /* > \param[in] A */
616 /* > \verbatim */
617 /* >          A is COMPLEX array, dimension ( N*(N+1)/2 ); */
618 /* >            On entry, the matrix A in RFP Format. */
619 /* >            RFP Format is described by TRANSR, UPLO and N as follows: */
620 /* >            If TRANSR='N' then RFP A is (0:N,0:K-1) when N is even; */
621 /* >            K=N/2. RFP A is (0:N-1,0:K) when N is odd; K=N/2. If */
622 /* >            TRANSR = 'C' then RFP is the Conjugate-transpose of RFP A */
623 /* >            as defined when TRANSR = 'N'. The contents of RFP A are */
624 /* >            defined by UPLO as follows: If UPLO = 'U' the RFP A */
625 /* >            contains the ( N*(N+1)/2 ) elements of upper packed A */
626 /* >            either in normal or conjugate-transpose Format. If */
627 /* >            UPLO = 'L' the RFP A contains the ( N*(N+1) /2 ) elements */
628 /* >            of lower packed A either in normal or conjugate-transpose */
629 /* >            Format. The LDA of RFP A is (N+1)/2 when TRANSR = 'C'. When */
630 /* >            TRANSR is 'N' the LDA is N+1 when N is even and is N when */
631 /* >            is odd. See the Note below for more details. */
632 /* >            Unchanged on exit. */
633 /* > \endverbatim */
634 /* > */
635 /* > \param[out] WORK */
636 /* > \verbatim */
637 /* >          WORK is REAL array, dimension (LWORK), */
638 /* >            where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */
639 /* >            WORK is not referenced. */
640 /* > \endverbatim */
641
642 /*  Authors: */
643 /*  ======== */
644
645 /* > \author Univ. of Tennessee */
646 /* > \author Univ. of California Berkeley */
647 /* > \author Univ. of Colorado Denver */
648 /* > \author NAG Ltd. */
649
650 /* > \date December 2016 */
651
652 /* > \ingroup complexOTHERcomputational */
653
654 /* > \par Further Details: */
655 /*  ===================== */
656 /* > */
657 /* > \verbatim */
658 /* > */
659 /* >  We first consider Standard Packed Format when N is even. */
660 /* >  We give an example where N = 6. */
661 /* > */
662 /* >      AP is Upper             AP is Lower */
663 /* > */
664 /* >   00 01 02 03 04 05       00 */
665 /* >      11 12 13 14 15       10 11 */
666 /* >         22 23 24 25       20 21 22 */
667 /* >            33 34 35       30 31 32 33 */
668 /* >               44 45       40 41 42 43 44 */
669 /* >                  55       50 51 52 53 54 55 */
670 /* > */
671 /* > */
672 /* >  Let TRANSR = 'N'. RFP holds AP as follows: */
673 /* >  For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */
674 /* >  three columns of AP upper. The lower triangle A(4:6,0:2) consists of */
675 /* >  conjugate-transpose of the first three columns of AP upper. */
676 /* >  For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */
677 /* >  three columns of AP lower. The upper triangle A(0:2,0:2) consists of */
678 /* >  conjugate-transpose of the last three columns of AP lower. */
679 /* >  To denote conjugate we place -- above the element. This covers the */
680 /* >  case N even and TRANSR = 'N'. */
681 /* > */
682 /* >         RFP A                   RFP A */
683 /* > */
684 /* >                                -- -- -- */
685 /* >        03 04 05                33 43 53 */
686 /* >                                   -- -- */
687 /* >        13 14 15                00 44 54 */
688 /* >                                      -- */
689 /* >        23 24 25                10 11 55 */
690 /* > */
691 /* >        33 34 35                20 21 22 */
692 /* >        -- */
693 /* >        00 44 45                30 31 32 */
694 /* >        -- -- */
695 /* >        01 11 55                40 41 42 */
696 /* >        -- -- -- */
697 /* >        02 12 22                50 51 52 */
698 /* > */
699 /* >  Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate- */
700 /* >  transpose of RFP A above. One therefore gets: */
701 /* > */
702 /* > */
703 /* >           RFP A                   RFP A */
704 /* > */
705 /* >     -- -- -- --                -- -- -- -- -- -- */
706 /* >     03 13 23 33 00 01 02    33 00 10 20 30 40 50 */
707 /* >     -- -- -- -- --                -- -- -- -- -- */
708 /* >     04 14 24 34 44 11 12    43 44 11 21 31 41 51 */
709 /* >     -- -- -- -- -- --                -- -- -- -- */
710 /* >     05 15 25 35 45 55 22    53 54 55 22 32 42 52 */
711 /* > */
712 /* > */
713 /* >  We next  consider Standard Packed Format when N is odd. */
714 /* >  We give an example where N = 5. */
715 /* > */
716 /* >     AP is Upper                 AP is Lower */
717 /* > */
718 /* >   00 01 02 03 04              00 */
719 /* >      11 12 13 14              10 11 */
720 /* >         22 23 24              20 21 22 */
721 /* >            33 34              30 31 32 33 */
722 /* >               44              40 41 42 43 44 */
723 /* > */
724 /* > */
725 /* >  Let TRANSR = 'N'. RFP holds AP as follows: */
726 /* >  For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */
727 /* >  three columns of AP upper. The lower triangle A(3:4,0:1) consists of */
728 /* >  conjugate-transpose of the first two   columns of AP upper. */
729 /* >  For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */
730 /* >  three columns of AP lower. The upper triangle A(0:1,1:2) consists of */
731 /* >  conjugate-transpose of the last two   columns of AP lower. */
732 /* >  To denote conjugate we place -- above the element. This covers the */
733 /* >  case N odd  and TRANSR = 'N'. */
734 /* > */
735 /* >         RFP A                   RFP A */
736 /* > */
737 /* >                                   -- -- */
738 /* >        02 03 04                00 33 43 */
739 /* >                                      -- */
740 /* >        12 13 14                10 11 44 */
741 /* > */
742 /* >        22 23 24                20 21 22 */
743 /* >        -- */
744 /* >        00 33 34                30 31 32 */
745 /* >        -- -- */
746 /* >        01 11 44                40 41 42 */
747 /* > */
748 /* >  Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate- */
749 /* >  transpose of RFP A above. One therefore gets: */
750 /* > */
751 /* > */
752 /* >           RFP A                   RFP A */
753 /* > */
754 /* >     -- -- --                   -- -- -- -- -- -- */
755 /* >     02 12 22 00 01             00 10 20 30 40 50 */
756 /* >     -- -- -- --                   -- -- -- -- -- */
757 /* >     03 13 23 33 11             33 11 21 31 41 51 */
758 /* >     -- -- -- -- --                   -- -- -- -- */
759 /* >     04 14 24 34 44             43 44 22 32 42 52 */
760 /* > \endverbatim */
761 /* > */
762 /*  ===================================================================== */
763 real clanhf_(char *norm, char *transr, char *uplo, integer *n, complex *a, 
764         real *work)
765 {
766     /* System generated locals */
767     integer i__1, i__2;
768     real ret_val, r__1;
769
770     /* Local variables */
771     real temp;
772     integer i__, j, k, l;
773     real s, scale;
774     extern logical lsame_(char *, char *);
775     real value;
776     integer n1;
777     real aa;
778     extern /* Subroutine */ int classq_(integer *, complex *, integer *, real 
779             *, real *);
780     extern logical sisnan_(real *);
781     integer lda, ifm, noe, ilu;
782
783
784 /*  -- LAPACK computational routine (version 3.7.0) -- */
785 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
786 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
787 /*     December 2016 */
788
789
790 /*  ===================================================================== */
791
792
793     if (*n == 0) {
794         ret_val = 0.f;
795         return ret_val;
796     } else if (*n == 1) {
797         ret_val = (r__1 = a[0].r, abs(r__1));
798         return ret_val;
799     }
800
801 /*     set noe = 1 if n is odd. if n is even set noe=0 */
802
803     noe = 1;
804     if (*n % 2 == 0) {
805         noe = 0;
806     }
807
808 /*     set ifm = 0 when form='C' or 'c' and 1 otherwise */
809
810     ifm = 1;
811     if (lsame_(transr, "C")) {
812         ifm = 0;
813     }
814
815 /*     set ilu = 0 when uplo='U or 'u' and 1 otherwise */
816
817     ilu = 1;
818     if (lsame_(uplo, "U")) {
819         ilu = 0;
820     }
821
822 /*     set lda = (n+1)/2 when ifm = 0 */
823 /*     set lda = n when ifm = 1 and noe = 1 */
824 /*     set lda = n+1 when ifm = 1 and noe = 0 */
825
826     if (ifm == 1) {
827         if (noe == 1) {
828             lda = *n;
829         } else {
830 /*           noe=0 */
831             lda = *n + 1;
832         }
833     } else {
834 /*        ifm=0 */
835         lda = (*n + 1) / 2;
836     }
837
838     if (lsame_(norm, "M")) {
839
840 /*       Find f2cmax(abs(A(i,j))). */
841
842         k = (*n + 1) / 2;
843         value = 0.f;
844         if (noe == 1) {
845 /*           n is odd & n = k + k - 1 */
846             if (ifm == 1) {
847 /*              A is n by k */
848                 if (ilu == 1) {
849 /*                 uplo ='L' */
850                     j = 0;
851 /*                 -> L(0,0) */
852                     i__1 = j + j * lda;
853                     temp = (r__1 = a[i__1].r, abs(r__1));
854                     if (value < temp || sisnan_(&temp)) {
855                         value = temp;
856                     }
857                     i__1 = *n - 1;
858                     for (i__ = 1; i__ <= i__1; ++i__) {
859                         temp = c_abs(&a[i__ + j * lda]);
860                         if (value < temp || sisnan_(&temp)) {
861                             value = temp;
862                         }
863                     }
864                     i__1 = k - 1;
865                     for (j = 1; j <= i__1; ++j) {
866                         i__2 = j - 2;
867                         for (i__ = 0; i__ <= i__2; ++i__) {
868                             temp = c_abs(&a[i__ + j * lda]);
869                             if (value < temp || sisnan_(&temp)) {
870                                 value = temp;
871                             }
872                         }
873                         i__ = j - 1;
874 /*                    L(k+j,k+j) */
875                         i__2 = i__ + j * lda;
876                         temp = (r__1 = a[i__2].r, abs(r__1));
877                         if (value < temp || sisnan_(&temp)) {
878                             value = temp;
879                         }
880                         i__ = j;
881 /*                    -> L(j,j) */
882                         i__2 = i__ + j * lda;
883                         temp = (r__1 = a[i__2].r, abs(r__1));
884                         if (value < temp || sisnan_(&temp)) {
885                             value = temp;
886                         }
887                         i__2 = *n - 1;
888                         for (i__ = j + 1; i__ <= i__2; ++i__) {
889                             temp = c_abs(&a[i__ + j * lda]);
890                             if (value < temp || sisnan_(&temp)) {
891                                 value = temp;
892                             }
893                         }
894                     }
895                 } else {
896 /*                 uplo = 'U' */
897                     i__1 = k - 2;
898                     for (j = 0; j <= i__1; ++j) {
899                         i__2 = k + j - 2;
900                         for (i__ = 0; i__ <= i__2; ++i__) {
901                             temp = c_abs(&a[i__ + j * lda]);
902                             if (value < temp || sisnan_(&temp)) {
903                                 value = temp;
904                             }
905                         }
906                         i__ = k + j - 1;
907 /*                    -> U(i,i) */
908                         i__2 = i__ + j * lda;
909                         temp = (r__1 = a[i__2].r, abs(r__1));
910                         if (value < temp || sisnan_(&temp)) {
911                             value = temp;
912                         }
913                         ++i__;
914 /*                    =k+j; i -> U(j,j) */
915                         i__2 = i__ + j * lda;
916                         temp = (r__1 = a[i__2].r, abs(r__1));
917                         if (value < temp || sisnan_(&temp)) {
918                             value = temp;
919                         }
920                         i__2 = *n - 1;
921                         for (i__ = k + j + 1; i__ <= i__2; ++i__) {
922                             temp = c_abs(&a[i__ + j * lda]);
923                             if (value < temp || sisnan_(&temp)) {
924                                 value = temp;
925                             }
926                         }
927                     }
928                     i__1 = *n - 2;
929                     for (i__ = 0; i__ <= i__1; ++i__) {
930                         temp = c_abs(&a[i__ + j * lda]);
931                         if (value < temp || sisnan_(&temp)) {
932                             value = temp;
933                         }
934 /*                    j=k-1 */
935                     }
936 /*                 i=n-1 -> U(n-1,n-1) */
937                     i__1 = i__ + j * lda;
938                     temp = (r__1 = a[i__1].r, abs(r__1));
939                     if (value < temp || sisnan_(&temp)) {
940                         value = temp;
941                     }
942                 }
943             } else {
944 /*              xpose case; A is k by n */
945                 if (ilu == 1) {
946 /*                 uplo ='L' */
947                     i__1 = k - 2;
948                     for (j = 0; j <= i__1; ++j) {
949                         i__2 = j - 1;
950                         for (i__ = 0; i__ <= i__2; ++i__) {
951                             temp = c_abs(&a[i__ + j * lda]);
952                             if (value < temp || sisnan_(&temp)) {
953                                 value = temp;
954                             }
955                         }
956                         i__ = j;
957 /*                    L(i,i) */
958                         i__2 = i__ + j * lda;
959                         temp = (r__1 = a[i__2].r, abs(r__1));
960                         if (value < temp || sisnan_(&temp)) {
961                             value = temp;
962                         }
963                         i__ = j + 1;
964 /*                    L(j+k,j+k) */
965                         i__2 = i__ + j * lda;
966                         temp = (r__1 = a[i__2].r, abs(r__1));
967                         if (value < temp || sisnan_(&temp)) {
968                             value = temp;
969                         }
970                         i__2 = k - 1;
971                         for (i__ = j + 2; i__ <= i__2; ++i__) {
972                             temp = c_abs(&a[i__ + j * lda]);
973                             if (value < temp || sisnan_(&temp)) {
974                                 value = temp;
975                             }
976                         }
977                     }
978                     j = k - 1;
979                     i__1 = k - 2;
980                     for (i__ = 0; i__ <= i__1; ++i__) {
981                         temp = c_abs(&a[i__ + j * lda]);
982                         if (value < temp || sisnan_(&temp)) {
983                             value = temp;
984                         }
985                     }
986                     i__ = k - 1;
987 /*                 -> L(i,i) is at A(i,j) */
988                     i__1 = i__ + j * lda;
989                     temp = (r__1 = a[i__1].r, abs(r__1));
990                     if (value < temp || sisnan_(&temp)) {
991                         value = temp;
992                     }
993                     i__1 = *n - 1;
994                     for (j = k; j <= i__1; ++j) {
995                         i__2 = k - 1;
996                         for (i__ = 0; i__ <= i__2; ++i__) {
997                             temp = c_abs(&a[i__ + j * lda]);
998                             if (value < temp || sisnan_(&temp)) {
999                                 value = temp;
1000                             }
1001                         }
1002                     }
1003                 } else {
1004 /*                 uplo = 'U' */
1005                     i__1 = k - 2;
1006                     for (j = 0; j <= i__1; ++j) {
1007                         i__2 = k - 1;
1008                         for (i__ = 0; i__ <= i__2; ++i__) {
1009                             temp = c_abs(&a[i__ + j * lda]);
1010                             if (value < temp || sisnan_(&temp)) {
1011                                 value = temp;
1012                             }
1013                         }
1014                     }
1015                     j = k - 1;
1016 /*                 -> U(j,j) is at A(0,j) */
1017                     i__1 = j * lda;
1018                     temp = (r__1 = a[i__1].r, abs(r__1));
1019                     if (value < temp || sisnan_(&temp)) {
1020                         value = temp;
1021                     }
1022                     i__1 = k - 1;
1023                     for (i__ = 1; i__ <= i__1; ++i__) {
1024                         temp = c_abs(&a[i__ + j * lda]);
1025                         if (value < temp || sisnan_(&temp)) {
1026                             value = temp;
1027                         }
1028                     }
1029                     i__1 = *n - 1;
1030                     for (j = k; j <= i__1; ++j) {
1031                         i__2 = j - k - 1;
1032                         for (i__ = 0; i__ <= i__2; ++i__) {
1033                             temp = c_abs(&a[i__ + j * lda]);
1034                             if (value < temp || sisnan_(&temp)) {
1035                                 value = temp;
1036                             }
1037                         }
1038                         i__ = j - k;
1039 /*                    -> U(i,i) at A(i,j) */
1040                         i__2 = i__ + j * lda;
1041                         temp = (r__1 = a[i__2].r, abs(r__1));
1042                         if (value < temp || sisnan_(&temp)) {
1043                             value = temp;
1044                         }
1045                         i__ = j - k + 1;
1046 /*                    U(j,j) */
1047                         i__2 = i__ + j * lda;
1048                         temp = (r__1 = a[i__2].r, abs(r__1));
1049                         if (value < temp || sisnan_(&temp)) {
1050                             value = temp;
1051                         }
1052                         i__2 = k - 1;
1053                         for (i__ = j - k + 2; i__ <= i__2; ++i__) {
1054                             temp = c_abs(&a[i__ + j * lda]);
1055                             if (value < temp || sisnan_(&temp)) {
1056                                 value = temp;
1057                             }
1058                         }
1059                     }
1060                 }
1061             }
1062         } else {
1063 /*           n is even & k = n/2 */
1064             if (ifm == 1) {
1065 /*              A is n+1 by k */
1066                 if (ilu == 1) {
1067 /*                 uplo ='L' */
1068                     j = 0;
1069 /*                 -> L(k,k) & j=1 -> L(0,0) */
1070                     i__1 = j + j * lda;
1071                     temp = (r__1 = a[i__1].r, abs(r__1));
1072                     if (value < temp || sisnan_(&temp)) {
1073                         value = temp;
1074                     }
1075                     i__1 = j + 1 + j * lda;
1076                     temp = (r__1 = a[i__1].r, abs(r__1));
1077                     if (value < temp || sisnan_(&temp)) {
1078                         value = temp;
1079                     }
1080                     i__1 = *n;
1081                     for (i__ = 2; i__ <= i__1; ++i__) {
1082                         temp = c_abs(&a[i__ + j * lda]);
1083                         if (value < temp || sisnan_(&temp)) {
1084                             value = temp;
1085                         }
1086                     }
1087                     i__1 = k - 1;
1088                     for (j = 1; j <= i__1; ++j) {
1089                         i__2 = j - 1;
1090                         for (i__ = 0; i__ <= i__2; ++i__) {
1091                             temp = c_abs(&a[i__ + j * lda]);
1092                             if (value < temp || sisnan_(&temp)) {
1093                                 value = temp;
1094                             }
1095                         }
1096                         i__ = j;
1097 /*                    L(k+j,k+j) */
1098                         i__2 = i__ + j * lda;
1099                         temp = (r__1 = a[i__2].r, abs(r__1));
1100                         if (value < temp || sisnan_(&temp)) {
1101                             value = temp;
1102                         }
1103                         i__ = j + 1;
1104 /*                    -> L(j,j) */
1105                         i__2 = i__ + j * lda;
1106                         temp = (r__1 = a[i__2].r, abs(r__1));
1107                         if (value < temp || sisnan_(&temp)) {
1108                             value = temp;
1109                         }
1110                         i__2 = *n;
1111                         for (i__ = j + 2; i__ <= i__2; ++i__) {
1112                             temp = c_abs(&a[i__ + j * lda]);
1113                             if (value < temp || sisnan_(&temp)) {
1114                                 value = temp;
1115                             }
1116                         }
1117                     }
1118                 } else {
1119 /*                 uplo = 'U' */
1120                     i__1 = k - 2;
1121                     for (j = 0; j <= i__1; ++j) {
1122                         i__2 = k + j - 1;
1123                         for (i__ = 0; i__ <= i__2; ++i__) {
1124                             temp = c_abs(&a[i__ + j * lda]);
1125                             if (value < temp || sisnan_(&temp)) {
1126                                 value = temp;
1127                             }
1128                         }
1129                         i__ = k + j;
1130 /*                    -> U(i,i) */
1131                         i__2 = i__ + j * lda;
1132                         temp = (r__1 = a[i__2].r, abs(r__1));
1133                         if (value < temp || sisnan_(&temp)) {
1134                             value = temp;
1135                         }
1136                         ++i__;
1137 /*                    =k+j+1; i -> U(j,j) */
1138                         i__2 = i__ + j * lda;
1139                         temp = (r__1 = a[i__2].r, abs(r__1));
1140                         if (value < temp || sisnan_(&temp)) {
1141                             value = temp;
1142                         }
1143                         i__2 = *n;
1144                         for (i__ = k + j + 2; i__ <= i__2; ++i__) {
1145                             temp = c_abs(&a[i__ + j * lda]);
1146                             if (value < temp || sisnan_(&temp)) {
1147                                 value = temp;
1148                             }
1149                         }
1150                     }
1151                     i__1 = *n - 2;
1152                     for (i__ = 0; i__ <= i__1; ++i__) {
1153                         temp = c_abs(&a[i__ + j * lda]);
1154                         if (value < temp || sisnan_(&temp)) {
1155                             value = temp;
1156                         }
1157 /*                 j=k-1 */
1158                     }
1159 /*                 i=n-1 -> U(n-1,n-1) */
1160                     i__1 = i__ + j * lda;
1161                     temp = (r__1 = a[i__1].r, abs(r__1));
1162                     if (value < temp || sisnan_(&temp)) {
1163                         value = temp;
1164                     }
1165                     i__ = *n;
1166 /*                 -> U(k-1,k-1) */
1167                     i__1 = i__ + j * lda;
1168                     temp = (r__1 = a[i__1].r, abs(r__1));
1169                     if (value < temp || sisnan_(&temp)) {
1170                         value = temp;
1171                     }
1172                 }
1173             } else {
1174 /*              xpose case; A is k by n+1 */
1175                 if (ilu == 1) {
1176 /*                 uplo ='L' */
1177                     j = 0;
1178 /*                 -> L(k,k) at A(0,0) */
1179                     i__1 = j + j * lda;
1180                     temp = (r__1 = a[i__1].r, abs(r__1));
1181                     if (value < temp || sisnan_(&temp)) {
1182                         value = temp;
1183                     }
1184                     i__1 = k - 1;
1185                     for (i__ = 1; i__ <= i__1; ++i__) {
1186                         temp = c_abs(&a[i__ + j * lda]);
1187                         if (value < temp || sisnan_(&temp)) {
1188                             value = temp;
1189                         }
1190                     }
1191                     i__1 = k - 1;
1192                     for (j = 1; j <= i__1; ++j) {
1193                         i__2 = j - 2;
1194                         for (i__ = 0; i__ <= i__2; ++i__) {
1195                             temp = c_abs(&a[i__ + j * lda]);
1196                             if (value < temp || sisnan_(&temp)) {
1197                                 value = temp;
1198                             }
1199                         }
1200                         i__ = j - 1;
1201 /*                    L(i,i) */
1202                         i__2 = i__ + j * lda;
1203                         temp = (r__1 = a[i__2].r, abs(r__1));
1204                         if (value < temp || sisnan_(&temp)) {
1205                             value = temp;
1206                         }
1207                         i__ = j;
1208 /*                    L(j+k,j+k) */
1209                         i__2 = i__ + j * lda;
1210                         temp = (r__1 = a[i__2].r, abs(r__1));
1211                         if (value < temp || sisnan_(&temp)) {
1212                             value = temp;
1213                         }
1214                         i__2 = k - 1;
1215                         for (i__ = j + 1; i__ <= i__2; ++i__) {
1216                             temp = c_abs(&a[i__ + j * lda]);
1217                             if (value < temp || sisnan_(&temp)) {
1218                                 value = temp;
1219                             }
1220                         }
1221                     }
1222                     j = k;
1223                     i__1 = k - 2;
1224                     for (i__ = 0; i__ <= i__1; ++i__) {
1225                         temp = c_abs(&a[i__ + j * lda]);
1226                         if (value < temp || sisnan_(&temp)) {
1227                             value = temp;
1228                         }
1229                     }
1230                     i__ = k - 1;
1231 /*                 -> L(i,i) is at A(i,j) */
1232                     i__1 = i__ + j * lda;
1233                     temp = (r__1 = a[i__1].r, abs(r__1));
1234                     if (value < temp || sisnan_(&temp)) {
1235                         value = temp;
1236                     }
1237                     i__1 = *n;
1238                     for (j = k + 1; j <= i__1; ++j) {
1239                         i__2 = k - 1;
1240                         for (i__ = 0; i__ <= i__2; ++i__) {
1241                             temp = c_abs(&a[i__ + j * lda]);
1242                             if (value < temp || sisnan_(&temp)) {
1243                                 value = temp;
1244                             }
1245                         }
1246                     }
1247                 } else {
1248 /*                 uplo = 'U' */
1249                     i__1 = k - 1;
1250                     for (j = 0; j <= i__1; ++j) {
1251                         i__2 = k - 1;
1252                         for (i__ = 0; i__ <= i__2; ++i__) {
1253                             temp = c_abs(&a[i__ + j * lda]);
1254                             if (value < temp || sisnan_(&temp)) {
1255                                 value = temp;
1256                             }
1257                         }
1258                     }
1259                     j = k;
1260 /*                 -> U(j,j) is at A(0,j) */
1261                     i__1 = j * lda;
1262                     temp = (r__1 = a[i__1].r, abs(r__1));
1263                     if (value < temp || sisnan_(&temp)) {
1264                         value = temp;
1265                     }
1266                     i__1 = k - 1;
1267                     for (i__ = 1; i__ <= i__1; ++i__) {
1268                         temp = c_abs(&a[i__ + j * lda]);
1269                         if (value < temp || sisnan_(&temp)) {
1270                             value = temp;
1271                         }
1272                     }
1273                     i__1 = *n - 1;
1274                     for (j = k + 1; j <= i__1; ++j) {
1275                         i__2 = j - k - 2;
1276                         for (i__ = 0; i__ <= i__2; ++i__) {
1277                             temp = c_abs(&a[i__ + j * lda]);
1278                             if (value < temp || sisnan_(&temp)) {
1279                                 value = temp;
1280                             }
1281                         }
1282                         i__ = j - k - 1;
1283 /*                    -> U(i,i) at A(i,j) */
1284                         i__2 = i__ + j * lda;
1285                         temp = (r__1 = a[i__2].r, abs(r__1));
1286                         if (value < temp || sisnan_(&temp)) {
1287                             value = temp;
1288                         }
1289                         i__ = j - k;
1290 /*                    U(j,j) */
1291                         i__2 = i__ + j * lda;
1292                         temp = (r__1 = a[i__2].r, abs(r__1));
1293                         if (value < temp || sisnan_(&temp)) {
1294                             value = temp;
1295                         }
1296                         i__2 = k - 1;
1297                         for (i__ = j - k + 1; i__ <= i__2; ++i__) {
1298                             temp = c_abs(&a[i__ + j * lda]);
1299                             if (value < temp || sisnan_(&temp)) {
1300                                 value = temp;
1301                             }
1302                         }
1303                     }
1304                     j = *n;
1305                     i__1 = k - 2;
1306                     for (i__ = 0; i__ <= i__1; ++i__) {
1307                         temp = c_abs(&a[i__ + j * lda]);
1308                         if (value < temp || sisnan_(&temp)) {
1309                             value = temp;
1310                         }
1311                     }
1312                     i__ = k - 1;
1313 /*                 U(k,k) at A(i,j) */
1314                     i__1 = i__ + j * lda;
1315                     temp = (r__1 = a[i__1].r, abs(r__1));
1316                     if (value < temp || sisnan_(&temp)) {
1317                         value = temp;
1318                     }
1319                 }
1320             }
1321         }
1322     } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') {
1323
1324 /*       Find normI(A) ( = norm1(A), since A is Hermitian). */
1325
1326         if (ifm == 1) {
1327 /*           A is 'N' */
1328             k = *n / 2;
1329             if (noe == 1) {
1330 /*              n is odd & A is n by (n+1)/2 */
1331                 if (ilu == 0) {
1332 /*                 uplo = 'U' */
1333                     i__1 = k - 1;
1334                     for (i__ = 0; i__ <= i__1; ++i__) {
1335                         work[i__] = 0.f;
1336                     }
1337                     i__1 = k;
1338                     for (j = 0; j <= i__1; ++j) {
1339                         s = 0.f;
1340                         i__2 = k + j - 1;
1341                         for (i__ = 0; i__ <= i__2; ++i__) {
1342                             aa = c_abs(&a[i__ + j * lda]);
1343 /*                       -> A(i,j+k) */
1344                             s += aa;
1345                             work[i__] += aa;
1346                         }
1347                         i__2 = i__ + j * lda;
1348                         aa = (r__1 = a[i__2].r, abs(r__1));
1349 /*                    -> A(j+k,j+k) */
1350                         work[j + k] = s + aa;
1351                         if (i__ == k + k) {
1352                             goto L10;
1353                         }
1354                         ++i__;
1355                         i__2 = i__ + j * lda;
1356                         aa = (r__1 = a[i__2].r, abs(r__1));
1357 /*                    -> A(j,j) */
1358                         work[j] += aa;
1359                         s = 0.f;
1360                         i__2 = k - 1;
1361                         for (l = j + 1; l <= i__2; ++l) {
1362                             ++i__;
1363                             aa = c_abs(&a[i__ + j * lda]);
1364 /*                       -> A(l,j) */
1365                             s += aa;
1366                             work[l] += aa;
1367                         }
1368                         work[j] += s;
1369                     }
1370 L10:
1371                     value = work[0];
1372                     i__1 = *n - 1;
1373                     for (i__ = 1; i__ <= i__1; ++i__) {
1374                         temp = work[i__];
1375                         if (value < temp || sisnan_(&temp)) {
1376                             value = temp;
1377                         }
1378                     }
1379                 } else {
1380 /*                 ilu = 1 & uplo = 'L' */
1381                     ++k;
1382 /*                 k=(n+1)/2 for n odd and ilu=1 */
1383                     i__1 = *n - 1;
1384                     for (i__ = k; i__ <= i__1; ++i__) {
1385                         work[i__] = 0.f;
1386                     }
1387                     for (j = k - 1; j >= 0; --j) {
1388                         s = 0.f;
1389                         i__1 = j - 2;
1390                         for (i__ = 0; i__ <= i__1; ++i__) {
1391                             aa = c_abs(&a[i__ + j * lda]);
1392 /*                       -> A(j+k,i+k) */
1393                             s += aa;
1394                             work[i__ + k] += aa;
1395                         }
1396                         if (j > 0) {
1397                             i__1 = i__ + j * lda;
1398                             aa = (r__1 = a[i__1].r, abs(r__1));
1399 /*                       -> A(j+k,j+k) */
1400                             s += aa;
1401                             work[i__ + k] += s;
1402 /*                       i=j */
1403                             ++i__;
1404                         }
1405                         i__1 = i__ + j * lda;
1406                         aa = (r__1 = a[i__1].r, abs(r__1));
1407 /*                    -> A(j,j) */
1408                         work[j] = aa;
1409                         s = 0.f;
1410                         i__1 = *n - 1;
1411                         for (l = j + 1; l <= i__1; ++l) {
1412                             ++i__;
1413                             aa = c_abs(&a[i__ + j * lda]);
1414 /*                       -> A(l,j) */
1415                             s += aa;
1416                             work[l] += aa;
1417                         }
1418                         work[j] += s;
1419                     }
1420                     value = work[0];
1421                     i__1 = *n - 1;
1422                     for (i__ = 1; i__ <= i__1; ++i__) {
1423                         temp = work[i__];
1424                         if (value < temp || sisnan_(&temp)) {
1425                             value = temp;
1426                         }
1427                     }
1428                 }
1429             } else {
1430 /*              n is even & A is n+1 by k = n/2 */
1431                 if (ilu == 0) {
1432 /*                 uplo = 'U' */
1433                     i__1 = k - 1;
1434                     for (i__ = 0; i__ <= i__1; ++i__) {
1435                         work[i__] = 0.f;
1436                     }
1437                     i__1 = k - 1;
1438                     for (j = 0; j <= i__1; ++j) {
1439                         s = 0.f;
1440                         i__2 = k + j - 1;
1441                         for (i__ = 0; i__ <= i__2; ++i__) {
1442                             aa = c_abs(&a[i__ + j * lda]);
1443 /*                       -> A(i,j+k) */
1444                             s += aa;
1445                             work[i__] += aa;
1446                         }
1447                         i__2 = i__ + j * lda;
1448                         aa = (r__1 = a[i__2].r, abs(r__1));
1449 /*                    -> A(j+k,j+k) */
1450                         work[j + k] = s + aa;
1451                         ++i__;
1452                         i__2 = i__ + j * lda;
1453                         aa = (r__1 = a[i__2].r, abs(r__1));
1454 /*                    -> A(j,j) */
1455                         work[j] += aa;
1456                         s = 0.f;
1457                         i__2 = k - 1;
1458                         for (l = j + 1; l <= i__2; ++l) {
1459                             ++i__;
1460                             aa = c_abs(&a[i__ + j * lda]);
1461 /*                       -> A(l,j) */
1462                             s += aa;
1463                             work[l] += aa;
1464                         }
1465                         work[j] += s;
1466                     }
1467                     value = work[0];
1468                     i__1 = *n - 1;
1469                     for (i__ = 1; i__ <= i__1; ++i__) {
1470                         temp = work[i__];
1471                         if (value < temp || sisnan_(&temp)) {
1472                             value = temp;
1473                         }
1474                     }
1475                 } else {
1476 /*                 ilu = 1 & uplo = 'L' */
1477                     i__1 = *n - 1;
1478                     for (i__ = k; i__ <= i__1; ++i__) {
1479                         work[i__] = 0.f;
1480                     }
1481                     for (j = k - 1; j >= 0; --j) {
1482                         s = 0.f;
1483                         i__1 = j - 1;
1484                         for (i__ = 0; i__ <= i__1; ++i__) {
1485                             aa = c_abs(&a[i__ + j * lda]);
1486 /*                       -> A(j+k,i+k) */
1487                             s += aa;
1488                             work[i__ + k] += aa;
1489                         }
1490                         i__1 = i__ + j * lda;
1491                         aa = (r__1 = a[i__1].r, abs(r__1));
1492 /*                    -> A(j+k,j+k) */
1493                         s += aa;
1494                         work[i__ + k] += s;
1495 /*                    i=j */
1496                         ++i__;
1497                         i__1 = i__ + j * lda;
1498                         aa = (r__1 = a[i__1].r, abs(r__1));
1499 /*                    -> A(j,j) */
1500                         work[j] = aa;
1501                         s = 0.f;
1502                         i__1 = *n - 1;
1503                         for (l = j + 1; l <= i__1; ++l) {
1504                             ++i__;
1505                             aa = c_abs(&a[i__ + j * lda]);
1506 /*                       -> A(l,j) */
1507                             s += aa;
1508                             work[l] += aa;
1509                         }
1510                         work[j] += s;
1511                     }
1512                     value = work[0];
1513                     i__1 = *n - 1;
1514                     for (i__ = 1; i__ <= i__1; ++i__) {
1515                         temp = work[i__];
1516                         if (value < temp || sisnan_(&temp)) {
1517                             value = temp;
1518                         }
1519                     }
1520                 }
1521             }
1522         } else {
1523 /*           ifm=0 */
1524             k = *n / 2;
1525             if (noe == 1) {
1526 /*              n is odd & A is (n+1)/2 by n */
1527                 if (ilu == 0) {
1528 /*                 uplo = 'U' */
1529                     n1 = k;
1530 /*                 n/2 */
1531                     ++k;
1532 /*                 k is the row size and lda */
1533                     i__1 = *n - 1;
1534                     for (i__ = n1; i__ <= i__1; ++i__) {
1535                         work[i__] = 0.f;
1536                     }
1537                     i__1 = n1 - 1;
1538                     for (j = 0; j <= i__1; ++j) {
1539                         s = 0.f;
1540                         i__2 = k - 1;
1541                         for (i__ = 0; i__ <= i__2; ++i__) {
1542                             aa = c_abs(&a[i__ + j * lda]);
1543 /*                       A(j,n1+i) */
1544                             work[i__ + n1] += aa;
1545                             s += aa;
1546                         }
1547                         work[j] = s;
1548                     }
1549 /*                 j=n1=k-1 is special */
1550                     i__1 = j * lda;
1551                     s = (r__1 = a[i__1].r, abs(r__1));
1552 /*                 A(k-1,k-1) */
1553                     i__1 = k - 1;
1554                     for (i__ = 1; i__ <= i__1; ++i__) {
1555                         aa = c_abs(&a[i__ + j * lda]);
1556 /*                    A(k-1,i+n1) */
1557                         work[i__ + n1] += aa;
1558                         s += aa;
1559                     }
1560                     work[j] += s;
1561                     i__1 = *n - 1;
1562                     for (j = k; j <= i__1; ++j) {
1563                         s = 0.f;
1564                         i__2 = j - k - 1;
1565                         for (i__ = 0; i__ <= i__2; ++i__) {
1566                             aa = c_abs(&a[i__ + j * lda]);
1567 /*                       A(i,j-k) */
1568                             work[i__] += aa;
1569                             s += aa;
1570                         }
1571 /*                    i=j-k */
1572                         i__2 = i__ + j * lda;
1573                         aa = (r__1 = a[i__2].r, abs(r__1));
1574 /*                    A(j-k,j-k) */
1575                         s += aa;
1576                         work[j - k] += s;
1577                         ++i__;
1578                         i__2 = i__ + j * lda;
1579                         s = (r__1 = a[i__2].r, abs(r__1));
1580 /*                    A(j,j) */
1581                         i__2 = *n - 1;
1582                         for (l = j + 1; l <= i__2; ++l) {
1583                             ++i__;
1584                             aa = c_abs(&a[i__ + j * lda]);
1585 /*                       A(j,l) */
1586                             work[l] += aa;
1587                             s += aa;
1588                         }
1589                         work[j] += s;
1590                     }
1591                     value = work[0];
1592                     i__1 = *n - 1;
1593                     for (i__ = 1; i__ <= i__1; ++i__) {
1594                         temp = work[i__];
1595                         if (value < temp || sisnan_(&temp)) {
1596                             value = temp;
1597                         }
1598                     }
1599                 } else {
1600 /*                 ilu=1 & uplo = 'L' */
1601                     ++k;
1602 /*                 k=(n+1)/2 for n odd and ilu=1 */
1603                     i__1 = *n - 1;
1604                     for (i__ = k; i__ <= i__1; ++i__) {
1605                         work[i__] = 0.f;
1606                     }
1607                     i__1 = k - 2;
1608                     for (j = 0; j <= i__1; ++j) {
1609 /*                    process */
1610                         s = 0.f;
1611                         i__2 = j - 1;
1612                         for (i__ = 0; i__ <= i__2; ++i__) {
1613                             aa = c_abs(&a[i__ + j * lda]);
1614 /*                       A(j,i) */
1615                             work[i__] += aa;
1616                             s += aa;
1617                         }
1618                         i__2 = i__ + j * lda;
1619                         aa = (r__1 = a[i__2].r, abs(r__1));
1620 /*                    i=j so process of A(j,j) */
1621                         s += aa;
1622                         work[j] = s;
1623 /*                    is initialised here */
1624                         ++i__;
1625 /*                    i=j process A(j+k,j+k) */
1626                         i__2 = i__ + j * lda;
1627                         aa = (r__1 = a[i__2].r, abs(r__1));
1628                         s = aa;
1629                         i__2 = *n - 1;
1630                         for (l = k + j + 1; l <= i__2; ++l) {
1631                             ++i__;
1632                             aa = c_abs(&a[i__ + j * lda]);
1633 /*                       A(l,k+j) */
1634                             s += aa;
1635                             work[l] += aa;
1636                         }
1637                         work[k + j] += s;
1638                     }
1639 /*                 j=k-1 is special :process col A(k-1,0:k-1) */
1640                     s = 0.f;
1641                     i__1 = k - 2;
1642                     for (i__ = 0; i__ <= i__1; ++i__) {
1643                         aa = c_abs(&a[i__ + j * lda]);
1644 /*                    A(k,i) */
1645                         work[i__] += aa;
1646                         s += aa;
1647                     }
1648 /*                 i=k-1 */
1649                     i__1 = i__ + j * lda;
1650                     aa = (r__1 = a[i__1].r, abs(r__1));
1651 /*                 A(k-1,k-1) */
1652                     s += aa;
1653                     work[i__] = s;
1654 /*                 done with col j=k+1 */
1655                     i__1 = *n - 1;
1656                     for (j = k; j <= i__1; ++j) {
1657 /*                    process col j of A = A(j,0:k-1) */
1658                         s = 0.f;
1659                         i__2 = k - 1;
1660                         for (i__ = 0; i__ <= i__2; ++i__) {
1661                             aa = c_abs(&a[i__ + j * lda]);
1662 /*                       A(j,i) */
1663                             work[i__] += aa;
1664                             s += aa;
1665                         }
1666                         work[j] += s;
1667                     }
1668                     value = work[0];
1669                     i__1 = *n - 1;
1670                     for (i__ = 1; i__ <= i__1; ++i__) {
1671                         temp = work[i__];
1672                         if (value < temp || sisnan_(&temp)) {
1673                             value = temp;
1674                         }
1675                     }
1676                 }
1677             } else {
1678 /*              n is even & A is k=n/2 by n+1 */
1679                 if (ilu == 0) {
1680 /*                 uplo = 'U' */
1681                     i__1 = *n - 1;
1682                     for (i__ = k; i__ <= i__1; ++i__) {
1683                         work[i__] = 0.f;
1684                     }
1685                     i__1 = k - 1;
1686                     for (j = 0; j <= i__1; ++j) {
1687                         s = 0.f;
1688                         i__2 = k - 1;
1689                         for (i__ = 0; i__ <= i__2; ++i__) {
1690                             aa = c_abs(&a[i__ + j * lda]);
1691 /*                       A(j,i+k) */
1692                             work[i__ + k] += aa;
1693                             s += aa;
1694                         }
1695                         work[j] = s;
1696                     }
1697 /*                 j=k */
1698                     i__1 = j * lda;
1699                     aa = (r__1 = a[i__1].r, abs(r__1));
1700 /*                 A(k,k) */
1701                     s = aa;
1702                     i__1 = k - 1;
1703                     for (i__ = 1; i__ <= i__1; ++i__) {
1704                         aa = c_abs(&a[i__ + j * lda]);
1705 /*                    A(k,k+i) */
1706                         work[i__ + k] += aa;
1707                         s += aa;
1708                     }
1709                     work[j] += s;
1710                     i__1 = *n - 1;
1711                     for (j = k + 1; j <= i__1; ++j) {
1712                         s = 0.f;
1713                         i__2 = j - 2 - k;
1714                         for (i__ = 0; i__ <= i__2; ++i__) {
1715                             aa = c_abs(&a[i__ + j * lda]);
1716 /*                       A(i,j-k-1) */
1717                             work[i__] += aa;
1718                             s += aa;
1719                         }
1720 /*                    i=j-1-k */
1721                         i__2 = i__ + j * lda;
1722                         aa = (r__1 = a[i__2].r, abs(r__1));
1723 /*                    A(j-k-1,j-k-1) */
1724                         s += aa;
1725                         work[j - k - 1] += s;
1726                         ++i__;
1727                         i__2 = i__ + j * lda;
1728                         aa = (r__1 = a[i__2].r, abs(r__1));
1729 /*                    A(j,j) */
1730                         s = aa;
1731                         i__2 = *n - 1;
1732                         for (l = j + 1; l <= i__2; ++l) {
1733                             ++i__;
1734                             aa = c_abs(&a[i__ + j * lda]);
1735 /*                       A(j,l) */
1736                             work[l] += aa;
1737                             s += aa;
1738                         }
1739                         work[j] += s;
1740                     }
1741 /*                 j=n */
1742                     s = 0.f;
1743                     i__1 = k - 2;
1744                     for (i__ = 0; i__ <= i__1; ++i__) {
1745                         aa = c_abs(&a[i__ + j * lda]);
1746 /*                    A(i,k-1) */
1747                         work[i__] += aa;
1748                         s += aa;
1749                     }
1750 /*                 i=k-1 */
1751                     i__1 = i__ + j * lda;
1752                     aa = (r__1 = a[i__1].r, abs(r__1));
1753 /*                 A(k-1,k-1) */
1754                     s += aa;
1755                     work[i__] += s;
1756                     value = work[0];
1757                     i__1 = *n - 1;
1758                     for (i__ = 1; i__ <= i__1; ++i__) {
1759                         temp = work[i__];
1760                         if (value < temp || sisnan_(&temp)) {
1761                             value = temp;
1762                         }
1763                     }
1764                 } else {
1765 /*                 ilu=1 & uplo = 'L' */
1766                     i__1 = *n - 1;
1767                     for (i__ = k; i__ <= i__1; ++i__) {
1768                         work[i__] = 0.f;
1769                     }
1770 /*                 j=0 is special :process col A(k:n-1,k) */
1771                     s = (r__1 = a[0].r, abs(r__1));
1772 /*                 A(k,k) */
1773                     i__1 = k - 1;
1774                     for (i__ = 1; i__ <= i__1; ++i__) {
1775                         aa = c_abs(&a[i__]);
1776 /*                    A(k+i,k) */
1777                         work[i__ + k] += aa;
1778                         s += aa;
1779                     }
1780                     work[k] += s;
1781                     i__1 = k - 1;
1782                     for (j = 1; j <= i__1; ++j) {
1783 /*                    process */
1784                         s = 0.f;
1785                         i__2 = j - 2;
1786                         for (i__ = 0; i__ <= i__2; ++i__) {
1787                             aa = c_abs(&a[i__ + j * lda]);
1788 /*                       A(j-1,i) */
1789                             work[i__] += aa;
1790                             s += aa;
1791                         }
1792                         i__2 = i__ + j * lda;
1793                         aa = (r__1 = a[i__2].r, abs(r__1));
1794 /*                    i=j-1 so process of A(j-1,j-1) */
1795                         s += aa;
1796                         work[j - 1] = s;
1797 /*                    is initialised here */
1798                         ++i__;
1799 /*                    i=j process A(j+k,j+k) */
1800                         i__2 = i__ + j * lda;
1801                         aa = (r__1 = a[i__2].r, abs(r__1));
1802                         s = aa;
1803                         i__2 = *n - 1;
1804                         for (l = k + j + 1; l <= i__2; ++l) {
1805                             ++i__;
1806                             aa = c_abs(&a[i__ + j * lda]);
1807 /*                       A(l,k+j) */
1808                             s += aa;
1809                             work[l] += aa;
1810                         }
1811                         work[k + j] += s;
1812                     }
1813 /*                 j=k is special :process col A(k,0:k-1) */
1814                     s = 0.f;
1815                     i__1 = k - 2;
1816                     for (i__ = 0; i__ <= i__1; ++i__) {
1817                         aa = c_abs(&a[i__ + j * lda]);
1818 /*                    A(k,i) */
1819                         work[i__] += aa;
1820                         s += aa;
1821                     }
1822
1823 /*                 i=k-1 */
1824                     i__1 = i__ + j * lda;
1825                     aa = (r__1 = a[i__1].r, abs(r__1));
1826 /*                 A(k-1,k-1) */
1827                     s += aa;
1828                     work[i__] = s;
1829 /*                 done with col j=k+1 */
1830                     i__1 = *n;
1831                     for (j = k + 1; j <= i__1; ++j) {
1832
1833 /*                    process col j-1 of A = A(j-1,0:k-1) */
1834                         s = 0.f;
1835                         i__2 = k - 1;
1836                         for (i__ = 0; i__ <= i__2; ++i__) {
1837                             aa = c_abs(&a[i__ + j * lda]);
1838 /*                       A(j-1,i) */
1839                             work[i__] += aa;
1840                             s += aa;
1841                         }
1842                         work[j - 1] += s;
1843                     }
1844                     value = work[0];
1845                     i__1 = *n - 1;
1846                     for (i__ = 1; i__ <= i__1; ++i__) {
1847                         temp = work[i__];
1848                         if (value < temp || sisnan_(&temp)) {
1849                             value = temp;
1850                         }
1851                     }
1852                 }
1853             }
1854         }
1855     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
1856
1857 /*       Find normF(A). */
1858
1859         k = (*n + 1) / 2;
1860         scale = 0.f;
1861         s = 1.f;
1862         if (noe == 1) {
1863 /*           n is odd */
1864             if (ifm == 1) {
1865 /*              A is normal & A is n by k */
1866                 if (ilu == 0) {
1867 /*                 A is upper */
1868                     i__1 = k - 3;
1869                     for (j = 0; j <= i__1; ++j) {
1870                         i__2 = k - j - 2;
1871                         classq_(&i__2, &a[k + j + 1 + j * lda], &c__1, &scale,
1872                                  &s);
1873 /*                    L at A(k,0) */
1874                     }
1875                     i__1 = k - 1;
1876                     for (j = 0; j <= i__1; ++j) {
1877                         i__2 = k + j - 1;
1878                         classq_(&i__2, &a[j * lda], &c__1, &scale, &s);
1879 /*                    trap U at A(0,0) */
1880                     }
1881                     s += s;
1882 /*                 double s for the off diagonal elements */
1883                     l = k - 1;
1884 /*                 -> U(k,k) at A(k-1,0) */
1885                     i__1 = k - 2;
1886                     for (i__ = 0; i__ <= i__1; ++i__) {
1887                         i__2 = l;
1888                         aa = a[i__2].r;
1889 /*                    U(k+i,k+i) */
1890                         if (aa != 0.f) {
1891                             if (scale < aa) {
1892 /* Computing 2nd power */
1893                                 r__1 = scale / aa;
1894                                 s = s * (r__1 * r__1) + 1.f;
1895                                 scale = aa;
1896                             } else {
1897 /* Computing 2nd power */
1898                                 r__1 = aa / scale;
1899                                 s += r__1 * r__1;
1900                             }
1901                         }
1902                         i__2 = l + 1;
1903                         aa = a[i__2].r;
1904 /*                    U(i,i) */
1905                         if (aa != 0.f) {
1906                             if (scale < aa) {
1907 /* Computing 2nd power */
1908                                 r__1 = scale / aa;
1909                                 s = s * (r__1 * r__1) + 1.f;
1910                                 scale = aa;
1911                             } else {
1912 /* Computing 2nd power */
1913                                 r__1 = aa / scale;
1914                                 s += r__1 * r__1;
1915                             }
1916                         }
1917                         l = l + lda + 1;
1918                     }
1919                     i__1 = l;
1920                     aa = a[i__1].r;
1921 /*                 U(n-1,n-1) */
1922                     if (aa != 0.f) {
1923                         if (scale < aa) {
1924 /* Computing 2nd power */
1925                             r__1 = scale / aa;
1926                             s = s * (r__1 * r__1) + 1.f;
1927                             scale = aa;
1928                         } else {
1929 /* Computing 2nd power */
1930                             r__1 = aa / scale;
1931                             s += r__1 * r__1;
1932                         }
1933                     }
1934                 } else {
1935 /*                 ilu=1 & A is lower */
1936                     i__1 = k - 1;
1937                     for (j = 0; j <= i__1; ++j) {
1938                         i__2 = *n - j - 1;
1939                         classq_(&i__2, &a[j + 1 + j * lda], &c__1, &scale, &s)
1940                                 ;
1941 /*                    trap L at A(0,0) */
1942                     }
1943                     i__1 = k - 2;
1944                     for (j = 1; j <= i__1; ++j) {
1945                         classq_(&j, &a[(j + 1) * lda], &c__1, &scale, &s);
1946 /*                    U at A(0,1) */
1947                     }
1948                     s += s;
1949 /*                 double s for the off diagonal elements */
1950                     aa = a[0].r;
1951 /*                 L(0,0) at A(0,0) */
1952                     if (aa != 0.f) {
1953                         if (scale < aa) {
1954 /* Computing 2nd power */
1955                             r__1 = scale / aa;
1956                             s = s * (r__1 * r__1) + 1.f;
1957                             scale = aa;
1958                         } else {
1959 /* Computing 2nd power */
1960                             r__1 = aa / scale;
1961                             s += r__1 * r__1;
1962                         }
1963                     }
1964                     l = lda;
1965 /*                 -> L(k,k) at A(0,1) */
1966                     i__1 = k - 1;
1967                     for (i__ = 1; i__ <= i__1; ++i__) {
1968                         i__2 = l;
1969                         aa = a[i__2].r;
1970 /*                    L(k-1+i,k-1+i) */
1971                         if (aa != 0.f) {
1972                             if (scale < aa) {
1973 /* Computing 2nd power */
1974                                 r__1 = scale / aa;
1975                                 s = s * (r__1 * r__1) + 1.f;
1976                                 scale = aa;
1977                             } else {
1978 /* Computing 2nd power */
1979                                 r__1 = aa / scale;
1980                                 s += r__1 * r__1;
1981                             }
1982                         }
1983                         i__2 = l + 1;
1984                         aa = a[i__2].r;
1985 /*                    L(i,i) */
1986                         if (aa != 0.f) {
1987                             if (scale < aa) {
1988 /* Computing 2nd power */
1989                                 r__1 = scale / aa;
1990                                 s = s * (r__1 * r__1) + 1.f;
1991                                 scale = aa;
1992                             } else {
1993 /* Computing 2nd power */
1994                                 r__1 = aa / scale;
1995                                 s += r__1 * r__1;
1996                             }
1997                         }
1998                         l = l + lda + 1;
1999                     }
2000                 }
2001             } else {
2002 /*              A is xpose & A is k by n */
2003                 if (ilu == 0) {
2004 /*                 A**H is upper */
2005                     i__1 = k - 2;
2006                     for (j = 1; j <= i__1; ++j) {
2007                         classq_(&j, &a[(k + j) * lda], &c__1, &scale, &s);
2008 /*                    U at A(0,k) */
2009                     }
2010                     i__1 = k - 2;
2011                     for (j = 0; j <= i__1; ++j) {
2012                         classq_(&k, &a[j * lda], &c__1, &scale, &s);
2013 /*                    k by k-1 rect. at A(0,0) */
2014                     }
2015                     i__1 = k - 2;
2016                     for (j = 0; j <= i__1; ++j) {
2017                         i__2 = k - j - 1;
2018                         classq_(&i__2, &a[j + 1 + (j + k - 1) * lda], &c__1, &
2019                                 scale, &s);
2020 /*                    L at A(0,k-1) */
2021                     }
2022                     s += s;
2023 /*                 double s for the off diagonal elements */
2024                     l = k * lda - lda;
2025 /*                 -> U(k-1,k-1) at A(0,k-1) */
2026                     i__1 = l;
2027                     aa = a[i__1].r;
2028 /*                 U(k-1,k-1) */
2029                     if (aa != 0.f) {
2030                         if (scale < aa) {
2031 /* Computing 2nd power */
2032                             r__1 = scale / aa;
2033                             s = s * (r__1 * r__1) + 1.f;
2034                             scale = aa;
2035                         } else {
2036 /* Computing 2nd power */
2037                             r__1 = aa / scale;
2038                             s += r__1 * r__1;
2039                         }
2040                     }
2041                     l += lda;
2042 /*                 -> U(0,0) at A(0,k) */
2043                     i__1 = *n - 1;
2044                     for (j = k; j <= i__1; ++j) {
2045                         i__2 = l;
2046                         aa = a[i__2].r;
2047 /*                    -> U(j-k,j-k) */
2048                         if (aa != 0.f) {
2049                             if (scale < aa) {
2050 /* Computing 2nd power */
2051                                 r__1 = scale / aa;
2052                                 s = s * (r__1 * r__1) + 1.f;
2053                                 scale = aa;
2054                             } else {
2055 /* Computing 2nd power */
2056                                 r__1 = aa / scale;
2057                                 s += r__1 * r__1;
2058                             }
2059                         }
2060                         i__2 = l + 1;
2061                         aa = a[i__2].r;
2062 /*                    -> U(j,j) */
2063                         if (aa != 0.f) {
2064                             if (scale < aa) {
2065 /* Computing 2nd power */
2066                                 r__1 = scale / aa;
2067                                 s = s * (r__1 * r__1) + 1.f;
2068                                 scale = aa;
2069                             } else {
2070 /* Computing 2nd power */
2071                                 r__1 = aa / scale;
2072                                 s += r__1 * r__1;
2073                             }
2074                         }
2075                         l = l + lda + 1;
2076                     }
2077                 } else {
2078 /*                 A**H is lower */
2079                     i__1 = k - 1;
2080                     for (j = 1; j <= i__1; ++j) {
2081                         classq_(&j, &a[j * lda], &c__1, &scale, &s);
2082 /*                    U at A(0,0) */
2083                     }
2084                     i__1 = *n - 1;
2085                     for (j = k; j <= i__1; ++j) {
2086                         classq_(&k, &a[j * lda], &c__1, &scale, &s);
2087 /*                    k by k-1 rect. at A(0,k) */
2088                     }
2089                     i__1 = k - 3;
2090                     for (j = 0; j <= i__1; ++j) {
2091                         i__2 = k - j - 2;
2092                         classq_(&i__2, &a[j + 2 + j * lda], &c__1, &scale, &s)
2093                                 ;
2094 /*                    L at A(1,0) */
2095                     }
2096                     s += s;
2097 /*                 double s for the off diagonal elements */
2098                     l = 0;
2099 /*                 -> L(0,0) at A(0,0) */
2100                     i__1 = k - 2;
2101                     for (i__ = 0; i__ <= i__1; ++i__) {
2102                         i__2 = l;
2103                         aa = a[i__2].r;
2104 /*                    L(i,i) */
2105                         if (aa != 0.f) {
2106                             if (scale < aa) {
2107 /* Computing 2nd power */
2108                                 r__1 = scale / aa;
2109                                 s = s * (r__1 * r__1) + 1.f;
2110                                 scale = aa;
2111                             } else {
2112 /* Computing 2nd power */
2113                                 r__1 = aa / scale;
2114                                 s += r__1 * r__1;
2115                             }
2116                         }
2117                         i__2 = l + 1;
2118                         aa = a[i__2].r;
2119 /*                    L(k+i,k+i) */
2120                         if (aa != 0.f) {
2121                             if (scale < aa) {
2122 /* Computing 2nd power */
2123                                 r__1 = scale / aa;
2124                                 s = s * (r__1 * r__1) + 1.f;
2125                                 scale = aa;
2126                             } else {
2127 /* Computing 2nd power */
2128                                 r__1 = aa / scale;
2129                                 s += r__1 * r__1;
2130                             }
2131                         }
2132                         l = l + lda + 1;
2133                     }
2134 /*                 L-> k-1 + (k-1)*lda or L(k-1,k-1) at A(k-1,k-1) */
2135                     i__1 = l;
2136                     aa = a[i__1].r;
2137 /*                 L(k-1,k-1) at A(k-1,k-1) */
2138                     if (aa != 0.f) {
2139                         if (scale < aa) {
2140 /* Computing 2nd power */
2141                             r__1 = scale / aa;
2142                             s = s * (r__1 * r__1) + 1.f;
2143                             scale = aa;
2144                         } else {
2145 /* Computing 2nd power */
2146                             r__1 = aa / scale;
2147                             s += r__1 * r__1;
2148                         }
2149                     }
2150                 }
2151             }
2152         } else {
2153 /*           n is even */
2154             if (ifm == 1) {
2155 /*              A is normal */
2156                 if (ilu == 0) {
2157 /*                 A is upper */
2158                     i__1 = k - 2;
2159                     for (j = 0; j <= i__1; ++j) {
2160                         i__2 = k - j - 1;
2161                         classq_(&i__2, &a[k + j + 2 + j * lda], &c__1, &scale,
2162                                  &s);
2163 /*                 L at A(k+1,0) */
2164                     }
2165                     i__1 = k - 1;
2166                     for (j = 0; j <= i__1; ++j) {
2167                         i__2 = k + j;
2168                         classq_(&i__2, &a[j * lda], &c__1, &scale, &s);
2169 /*                 trap U at A(0,0) */
2170                     }
2171                     s += s;
2172 /*                 double s for the off diagonal elements */
2173                     l = k;
2174 /*                 -> U(k,k) at A(k,0) */
2175                     i__1 = k - 1;
2176                     for (i__ = 0; i__ <= i__1; ++i__) {
2177                         i__2 = l;
2178                         aa = a[i__2].r;
2179 /*                    U(k+i,k+i) */
2180                         if (aa != 0.f) {
2181                             if (scale < aa) {
2182 /* Computing 2nd power */
2183                                 r__1 = scale / aa;
2184                                 s = s * (r__1 * r__1) + 1.f;
2185                                 scale = aa;
2186                             } else {
2187 /* Computing 2nd power */
2188                                 r__1 = aa / scale;
2189                                 s += r__1 * r__1;
2190                             }
2191                         }
2192                         i__2 = l + 1;
2193                         aa = a[i__2].r;
2194 /*                    U(i,i) */
2195                         if (aa != 0.f) {
2196                             if (scale < aa) {
2197 /* Computing 2nd power */
2198                                 r__1 = scale / aa;
2199                                 s = s * (r__1 * r__1) + 1.f;
2200                                 scale = aa;
2201                             } else {
2202 /* Computing 2nd power */
2203                                 r__1 = aa / scale;
2204                                 s += r__1 * r__1;
2205                             }
2206                         }
2207                         l = l + lda + 1;
2208                     }
2209                 } else {
2210 /*                 ilu=1 & A is lower */
2211                     i__1 = k - 1;
2212                     for (j = 0; j <= i__1; ++j) {
2213                         i__2 = *n - j - 1;
2214                         classq_(&i__2, &a[j + 2 + j * lda], &c__1, &scale, &s)
2215                                 ;
2216 /*                    trap L at A(1,0) */
2217                     }
2218                     i__1 = k - 1;
2219                     for (j = 1; j <= i__1; ++j) {
2220                         classq_(&j, &a[j * lda], &c__1, &scale, &s);
2221 /*                    U at A(0,0) */
2222                     }
2223                     s += s;
2224 /*                 double s for the off diagonal elements */
2225                     l = 0;
2226 /*                 -> L(k,k) at A(0,0) */
2227                     i__1 = k - 1;
2228                     for (i__ = 0; i__ <= i__1; ++i__) {
2229                         i__2 = l;
2230                         aa = a[i__2].r;
2231 /*                    L(k-1+i,k-1+i) */
2232                         if (aa != 0.f) {
2233                             if (scale < aa) {
2234 /* Computing 2nd power */
2235                                 r__1 = scale / aa;
2236                                 s = s * (r__1 * r__1) + 1.f;
2237                                 scale = aa;
2238                             } else {
2239 /* Computing 2nd power */
2240                                 r__1 = aa / scale;
2241                                 s += r__1 * r__1;
2242                             }
2243                         }
2244                         i__2 = l + 1;
2245                         aa = a[i__2].r;
2246 /*                    L(i,i) */
2247                         if (aa != 0.f) {
2248                             if (scale < aa) {
2249 /* Computing 2nd power */
2250                                 r__1 = scale / aa;
2251                                 s = s * (r__1 * r__1) + 1.f;
2252                                 scale = aa;
2253                             } else {
2254 /* Computing 2nd power */
2255                                 r__1 = aa / scale;
2256                                 s += r__1 * r__1;
2257                             }
2258                         }
2259                         l = l + lda + 1;
2260                     }
2261                 }
2262             } else {
2263 /*              A is xpose */
2264                 if (ilu == 0) {
2265 /*                 A**H is upper */
2266                     i__1 = k - 1;
2267                     for (j = 1; j <= i__1; ++j) {
2268                         classq_(&j, &a[(k + 1 + j) * lda], &c__1, &scale, &s);
2269 /*                 U at A(0,k+1) */
2270                     }
2271                     i__1 = k - 1;
2272                     for (j = 0; j <= i__1; ++j) {
2273                         classq_(&k, &a[j * lda], &c__1, &scale, &s);
2274 /*                 k by k rect. at A(0,0) */
2275                     }
2276                     i__1 = k - 2;
2277                     for (j = 0; j <= i__1; ++j) {
2278                         i__2 = k - j - 1;
2279                         classq_(&i__2, &a[j + 1 + (j + k) * lda], &c__1, &
2280                                 scale, &s);
2281 /*                 L at A(0,k) */
2282                     }
2283                     s += s;
2284 /*                 double s for the off diagonal elements */
2285                     l = k * lda;
2286 /*                 -> U(k,k) at A(0,k) */
2287                     i__1 = l;
2288                     aa = a[i__1].r;
2289 /*                 U(k,k) */
2290                     if (aa != 0.f) {
2291                         if (scale < aa) {
2292 /* Computing 2nd power */
2293                             r__1 = scale / aa;
2294                             s = s * (r__1 * r__1) + 1.f;
2295                             scale = aa;
2296                         } else {
2297 /* Computing 2nd power */
2298                             r__1 = aa / scale;
2299                             s += r__1 * r__1;
2300                         }
2301                     }
2302                     l += lda;
2303 /*                 -> U(0,0) at A(0,k+1) */
2304                     i__1 = *n - 1;
2305                     for (j = k + 1; j <= i__1; ++j) {
2306                         i__2 = l;
2307                         aa = a[i__2].r;
2308 /*                    -> U(j-k-1,j-k-1) */
2309                         if (aa != 0.f) {
2310                             if (scale < aa) {
2311 /* Computing 2nd power */
2312                                 r__1 = scale / aa;
2313                                 s = s * (r__1 * r__1) + 1.f;
2314                                 scale = aa;
2315                             } else {
2316 /* Computing 2nd power */
2317                                 r__1 = aa / scale;
2318                                 s += r__1 * r__1;
2319                             }
2320                         }
2321                         i__2 = l + 1;
2322                         aa = a[i__2].r;
2323 /*                    -> U(j,j) */
2324                         if (aa != 0.f) {
2325                             if (scale < aa) {
2326 /* Computing 2nd power */
2327                                 r__1 = scale / aa;
2328                                 s = s * (r__1 * r__1) + 1.f;
2329                                 scale = aa;
2330                             } else {
2331 /* Computing 2nd power */
2332                                 r__1 = aa / scale;
2333                                 s += r__1 * r__1;
2334                             }
2335                         }
2336                         l = l + lda + 1;
2337                     }
2338 /*                 L=k-1+n*lda */
2339 /*                 -> U(k-1,k-1) at A(k-1,n) */
2340                     i__1 = l;
2341                     aa = a[i__1].r;
2342 /*                 U(k,k) */
2343                     if (aa != 0.f) {
2344                         if (scale < aa) {
2345 /* Computing 2nd power */
2346                             r__1 = scale / aa;
2347                             s = s * (r__1 * r__1) + 1.f;
2348                             scale = aa;
2349                         } else {
2350 /* Computing 2nd power */
2351                             r__1 = aa / scale;
2352                             s += r__1 * r__1;
2353                         }
2354                     }
2355                 } else {
2356 /*                 A**H is lower */
2357                     i__1 = k - 1;
2358                     for (j = 1; j <= i__1; ++j) {
2359                         classq_(&j, &a[(j + 1) * lda], &c__1, &scale, &s);
2360 /*                 U at A(0,1) */
2361                     }
2362                     i__1 = *n;
2363                     for (j = k + 1; j <= i__1; ++j) {
2364                         classq_(&k, &a[j * lda], &c__1, &scale, &s);
2365 /*                 k by k rect. at A(0,k+1) */
2366                     }
2367                     i__1 = k - 2;
2368                     for (j = 0; j <= i__1; ++j) {
2369                         i__2 = k - j - 1;
2370                         classq_(&i__2, &a[j + 1 + j * lda], &c__1, &scale, &s)
2371                                 ;
2372 /*                 L at A(0,0) */
2373                     }
2374                     s += s;
2375 /*                 double s for the off diagonal elements */
2376                     l = 0;
2377 /*                 -> L(k,k) at A(0,0) */
2378                     i__1 = l;
2379                     aa = a[i__1].r;
2380 /*                 L(k,k) at A(0,0) */
2381                     if (aa != 0.f) {
2382                         if (scale < aa) {
2383 /* Computing 2nd power */
2384                             r__1 = scale / aa;
2385                             s = s * (r__1 * r__1) + 1.f;
2386                             scale = aa;
2387                         } else {
2388 /* Computing 2nd power */
2389                             r__1 = aa / scale;
2390                             s += r__1 * r__1;
2391                         }
2392                     }
2393                     l = lda;
2394 /*                 -> L(0,0) at A(0,1) */
2395                     i__1 = k - 2;
2396                     for (i__ = 0; i__ <= i__1; ++i__) {
2397                         i__2 = l;
2398                         aa = a[i__2].r;
2399 /*                    L(i,i) */
2400                         if (aa != 0.f) {
2401                             if (scale < aa) {
2402 /* Computing 2nd power */
2403                                 r__1 = scale / aa;
2404                                 s = s * (r__1 * r__1) + 1.f;
2405                                 scale = aa;
2406                             } else {
2407 /* Computing 2nd power */
2408                                 r__1 = aa / scale;
2409                                 s += r__1 * r__1;
2410                             }
2411                         }
2412                         i__2 = l + 1;
2413                         aa = a[i__2].r;
2414 /*                    L(k+i+1,k+i+1) */
2415                         if (aa != 0.f) {
2416                             if (scale < aa) {
2417 /* Computing 2nd power */
2418                                 r__1 = scale / aa;
2419                                 s = s * (r__1 * r__1) + 1.f;
2420                                 scale = aa;
2421                             } else {
2422 /* Computing 2nd power */
2423                                 r__1 = aa / scale;
2424                                 s += r__1 * r__1;
2425                             }
2426                         }
2427                         l = l + lda + 1;
2428                     }
2429 /*                 L-> k - 1 + k*lda or L(k-1,k-1) at A(k-1,k) */
2430                     i__1 = l;
2431                     aa = a[i__1].r;
2432 /*                 L(k-1,k-1) at A(k-1,k) */
2433                     if (aa != 0.f) {
2434                         if (scale < aa) {
2435 /* Computing 2nd power */
2436                             r__1 = scale / aa;
2437                             s = s * (r__1 * r__1) + 1.f;
2438                             scale = aa;
2439                         } else {
2440 /* Computing 2nd power */
2441                             r__1 = aa / scale;
2442                             s += r__1 * r__1;
2443                         }
2444                     }
2445                 }
2446             }
2447         }
2448         value = scale * sqrt(s);
2449     }
2450
2451     ret_val = value;
2452     return ret_val;
2453
2454 /*     End of CLANHF */
2455
2456 } /* clanhf_ */
2457