C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / lapack-netlib / SRC / dlansf.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 DLANSF 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 symmetric 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 DLANSF + dependencies */
527 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlansf.
528 f"> */
529 /* > [TGZ]</a> */
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlansf.
531 f"> */
532 /* > [ZIP]</a> */
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlansf.
534 f"> */
535 /* > [TXT]</a> */
536 /* > \endhtmlonly */
537
538 /*  Definition: */
539 /*  =========== */
540
541 /*       DOUBLE PRECISION FUNCTION DLANSF( NORM, TRANSR, UPLO, N, A, WORK ) */
542
543 /*       CHARACTER          NORM, TRANSR, UPLO */
544 /*       INTEGER            N */
545 /*       DOUBLE PRECISION   A( 0: * ), WORK( 0: * ) */
546
547
548 /* > \par Purpose: */
549 /*  ============= */
550 /* > */
551 /* > \verbatim */
552 /* > */
553 /* > DLANSF returns the value of the one norm, or the Frobenius norm, or */
554 /* > the infinity norm, or the element of largest absolute value of a */
555 /* > real symmetric matrix A in RFP format. */
556 /* > \endverbatim */
557 /* > */
558 /* > \return DLANSF */
559 /* > \verbatim */
560 /* > */
561 /* >    DLANSF = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */
562 /* >             ( */
563 /* >             ( norm1(A),         NORM = '1', 'O' or 'o' */
564 /* >             ( */
565 /* >             ( normI(A),         NORM = 'I' or 'i' */
566 /* >             ( */
567 /* >             ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
568 /* > */
569 /* > where  norm1  denotes the  one norm of a matrix (maximum column sum), */
570 /* > normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
571 /* > normF  denotes the  Frobenius norm of a matrix (square root of sum of */
572 /* > squares).  Note that  f2cmax(abs(A(i,j)))  is not a  matrix norm. */
573 /* > \endverbatim */
574
575 /*  Arguments: */
576 /*  ========== */
577
578 /* > \param[in] NORM */
579 /* > \verbatim */
580 /* >          NORM is CHARACTER*1 */
581 /* >          Specifies the value to be returned in DLANSF as described */
582 /* >          above. */
583 /* > \endverbatim */
584 /* > */
585 /* > \param[in] TRANSR */
586 /* > \verbatim */
587 /* >          TRANSR is CHARACTER*1 */
588 /* >          Specifies whether the RFP format of A is normal or */
589 /* >          transposed format. */
590 /* >          = 'N':  RFP format is Normal; */
591 /* >          = 'T':  RFP format is Transpose. */
592 /* > \endverbatim */
593 /* > */
594 /* > \param[in] UPLO */
595 /* > \verbatim */
596 /* >          UPLO is CHARACTER*1 */
597 /* >           On entry, UPLO specifies whether the RFP matrix A came from */
598 /* >           an upper or lower triangular matrix as follows: */
599 /* >           = 'U': RFP A came from an upper triangular matrix; */
600 /* >           = 'L': RFP A came from a lower triangular matrix. */
601 /* > \endverbatim */
602 /* > */
603 /* > \param[in] N */
604 /* > \verbatim */
605 /* >          N is INTEGER */
606 /* >          The order of the matrix A. N >= 0. When N = 0, DLANSF is */
607 /* >          set to zero. */
608 /* > \endverbatim */
609 /* > */
610 /* > \param[in] A */
611 /* > \verbatim */
612 /* >          A is DOUBLE PRECISION array, dimension ( N*(N+1)/2 ); */
613 /* >          On entry, the upper (if UPLO = 'U') or lower (if UPLO = 'L') */
614 /* >          part of the symmetric matrix A stored in RFP format. See the */
615 /* >          "Notes" below for more details. */
616 /* >          Unchanged on exit. */
617 /* > \endverbatim */
618 /* > */
619 /* > \param[out] WORK */
620 /* > \verbatim */
621 /* >          WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
622 /* >          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */
623 /* >          WORK is not referenced. */
624 /* > \endverbatim */
625
626 /*  Authors: */
627 /*  ======== */
628
629 /* > \author Univ. of Tennessee */
630 /* > \author Univ. of California Berkeley */
631 /* > \author Univ. of Colorado Denver */
632 /* > \author NAG Ltd. */
633
634 /* > \date December 2016 */
635
636 /* > \ingroup doubleOTHERcomputational */
637
638 /* > \par Further Details: */
639 /*  ===================== */
640 /* > */
641 /* > \verbatim */
642 /* > */
643 /* >  We first consider Rectangular Full Packed (RFP) Format when N is */
644 /* >  even. We give an example where N = 6. */
645 /* > */
646 /* >      AP is Upper             AP is Lower */
647 /* > */
648 /* >   00 01 02 03 04 05       00 */
649 /* >      11 12 13 14 15       10 11 */
650 /* >         22 23 24 25       20 21 22 */
651 /* >            33 34 35       30 31 32 33 */
652 /* >               44 45       40 41 42 43 44 */
653 /* >                  55       50 51 52 53 54 55 */
654 /* > */
655 /* > */
656 /* >  Let TRANSR = 'N'. RFP holds AP as follows: */
657 /* >  For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */
658 /* >  three columns of AP upper. The lower triangle A(4:6,0:2) consists of */
659 /* >  the transpose of the first three columns of AP upper. */
660 /* >  For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */
661 /* >  three columns of AP lower. The upper triangle A(0:2,0:2) consists of */
662 /* >  the transpose of the last three columns of AP lower. */
663 /* >  This covers the case N even and TRANSR = 'N'. */
664 /* > */
665 /* >         RFP A                   RFP A */
666 /* > */
667 /* >        03 04 05                33 43 53 */
668 /* >        13 14 15                00 44 54 */
669 /* >        23 24 25                10 11 55 */
670 /* >        33 34 35                20 21 22 */
671 /* >        00 44 45                30 31 32 */
672 /* >        01 11 55                40 41 42 */
673 /* >        02 12 22                50 51 52 */
674 /* > */
675 /* >  Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */
676 /* >  transpose of RFP A above. One therefore gets: */
677 /* > */
678 /* > */
679 /* >           RFP A                   RFP A */
680 /* > */
681 /* >     03 13 23 33 00 01 02    33 00 10 20 30 40 50 */
682 /* >     04 14 24 34 44 11 12    43 44 11 21 31 41 51 */
683 /* >     05 15 25 35 45 55 22    53 54 55 22 32 42 52 */
684 /* > */
685 /* > */
686 /* >  We then consider Rectangular Full Packed (RFP) Format when N is */
687 /* >  odd. We give an example where N = 5. */
688 /* > */
689 /* >     AP is Upper                 AP is Lower */
690 /* > */
691 /* >   00 01 02 03 04              00 */
692 /* >      11 12 13 14              10 11 */
693 /* >         22 23 24              20 21 22 */
694 /* >            33 34              30 31 32 33 */
695 /* >               44              40 41 42 43 44 */
696 /* > */
697 /* > */
698 /* >  Let TRANSR = 'N'. RFP holds AP as follows: */
699 /* >  For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */
700 /* >  three columns of AP upper. The lower triangle A(3:4,0:1) consists of */
701 /* >  the transpose of the first two columns of AP upper. */
702 /* >  For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */
703 /* >  three columns of AP lower. The upper triangle A(0:1,1:2) consists of */
704 /* >  the transpose of the last two columns of AP lower. */
705 /* >  This covers the case N odd and TRANSR = 'N'. */
706 /* > */
707 /* >         RFP A                   RFP A */
708 /* > */
709 /* >        02 03 04                00 33 43 */
710 /* >        12 13 14                10 11 44 */
711 /* >        22 23 24                20 21 22 */
712 /* >        00 33 34                30 31 32 */
713 /* >        01 11 44                40 41 42 */
714 /* > */
715 /* >  Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */
716 /* >  transpose of RFP A above. One therefore gets: */
717 /* > */
718 /* >           RFP A                   RFP A */
719 /* > */
720 /* >     02 12 22 00 01             00 10 20 30 40 50 */
721 /* >     03 13 23 33 11             33 11 21 31 41 51 */
722 /* >     04 14 24 34 44             43 44 22 32 42 52 */
723 /* > \endverbatim */
724
725 /*  ===================================================================== */
726 doublereal dlansf_(char *norm, char *transr, char *uplo, integer *n, 
727         doublereal *a, doublereal *work)
728 {
729     /* System generated locals */
730     integer i__1, i__2;
731     doublereal ret_val, d__1;
732
733     /* Local variables */
734     doublereal temp;
735     integer i__, j, k, l;
736     doublereal s, scale;
737     extern logical lsame_(char *, char *);
738     doublereal value;
739     integer n1;
740     doublereal aa;
741     extern logical disnan_(doublereal *);
742     extern /* Subroutine */ int dlassq_(integer *, doublereal *, integer *, 
743             doublereal *, doublereal *);
744     integer lda, ifm, noe, ilu;
745
746
747 /*  -- LAPACK computational routine (version 3.7.0) -- */
748 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
749 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
750 /*     December 2016 */
751
752
753 /*  ===================================================================== */
754
755
756     if (*n == 0) {
757         ret_val = 0.;
758         return ret_val;
759     } else if (*n == 1) {
760         ret_val = abs(a[0]);
761         return ret_val;
762     }
763
764 /*     set noe = 1 if n is odd. if n is even set noe=0 */
765
766     noe = 1;
767     if (*n % 2 == 0) {
768         noe = 0;
769     }
770
771 /*     set ifm = 0 when form='T or 't' and 1 otherwise */
772
773     ifm = 1;
774     if (lsame_(transr, "T")) {
775         ifm = 0;
776     }
777
778 /*     set ilu = 0 when uplo='U or 'u' and 1 otherwise */
779
780     ilu = 1;
781     if (lsame_(uplo, "U")) {
782         ilu = 0;
783     }
784
785 /*     set lda = (n+1)/2 when ifm = 0 */
786 /*     set lda = n when ifm = 1 and noe = 1 */
787 /*     set lda = n+1 when ifm = 1 and noe = 0 */
788
789     if (ifm == 1) {
790         if (noe == 1) {
791             lda = *n;
792         } else {
793 /*           noe=0 */
794             lda = *n + 1;
795         }
796     } else {
797 /*        ifm=0 */
798         lda = (*n + 1) / 2;
799     }
800
801     if (lsame_(norm, "M")) {
802
803 /*       Find f2cmax(abs(A(i,j))). */
804
805         k = (*n + 1) / 2;
806         value = 0.;
807         if (noe == 1) {
808 /*           n is odd */
809             if (ifm == 1) {
810 /*           A is n by k */
811                 i__1 = k - 1;
812                 for (j = 0; j <= i__1; ++j) {
813                     i__2 = *n - 1;
814                     for (i__ = 0; i__ <= i__2; ++i__) {
815                         temp = (d__1 = a[i__ + j * lda], abs(d__1));
816                         if (value < temp || disnan_(&temp)) {
817                             value = temp;
818                         }
819                     }
820                 }
821             } else {
822 /*              xpose case; A is k by n */
823                 i__1 = *n - 1;
824                 for (j = 0; j <= i__1; ++j) {
825                     i__2 = k - 1;
826                     for (i__ = 0; i__ <= i__2; ++i__) {
827                         temp = (d__1 = a[i__ + j * lda], abs(d__1));
828                         if (value < temp || disnan_(&temp)) {
829                             value = temp;
830                         }
831                     }
832                 }
833             }
834         } else {
835 /*           n is even */
836             if (ifm == 1) {
837 /*              A is n+1 by k */
838                 i__1 = k - 1;
839                 for (j = 0; j <= i__1; ++j) {
840                     i__2 = *n;
841                     for (i__ = 0; i__ <= i__2; ++i__) {
842                         temp = (d__1 = a[i__ + j * lda], abs(d__1));
843                         if (value < temp || disnan_(&temp)) {
844                             value = temp;
845                         }
846                     }
847                 }
848             } else {
849 /*              xpose case; A is k by n+1 */
850                 i__1 = *n;
851                 for (j = 0; j <= i__1; ++j) {
852                     i__2 = k - 1;
853                     for (i__ = 0; i__ <= i__2; ++i__) {
854                         temp = (d__1 = a[i__ + j * lda], abs(d__1));
855                         if (value < temp || disnan_(&temp)) {
856                             value = temp;
857                         }
858                     }
859                 }
860             }
861         }
862     } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') {
863
864 /*        Find normI(A) ( = norm1(A), since A is symmetric). */
865
866         if (ifm == 1) {
867             k = *n / 2;
868             if (noe == 1) {
869 /*              n is odd */
870                 if (ilu == 0) {
871                     i__1 = k - 1;
872                     for (i__ = 0; i__ <= i__1; ++i__) {
873                         work[i__] = 0.;
874                     }
875                     i__1 = k;
876                     for (j = 0; j <= i__1; ++j) {
877                         s = 0.;
878                         i__2 = k + j - 1;
879                         for (i__ = 0; i__ <= i__2; ++i__) {
880                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
881 /*                       -> A(i,j+k) */
882                             s += aa;
883                             work[i__] += aa;
884                         }
885                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
886 /*                    -> A(j+k,j+k) */
887                         work[j + k] = s + aa;
888                         if (i__ == k + k) {
889                             goto L10;
890                         }
891                         ++i__;
892                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
893 /*                    -> A(j,j) */
894                         work[j] += aa;
895                         s = 0.;
896                         i__2 = k - 1;
897                         for (l = j + 1; l <= i__2; ++l) {
898                             ++i__;
899                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
900 /*                       -> A(l,j) */
901                             s += aa;
902                             work[l] += aa;
903                         }
904                         work[j] += s;
905                     }
906 L10:
907                     value = work[0];
908                     i__1 = *n - 1;
909                     for (i__ = 1; i__ <= i__1; ++i__) {
910                         temp = work[i__];
911                         if (value < temp || disnan_(&temp)) {
912                             value = temp;
913                         }
914                     }
915                 } else {
916 /*                 ilu = 1 */
917                     ++k;
918 /*                 k=(n+1)/2 for n odd and ilu=1 */
919                     i__1 = *n - 1;
920                     for (i__ = k; i__ <= i__1; ++i__) {
921                         work[i__] = 0.;
922                     }
923                     for (j = k - 1; j >= 0; --j) {
924                         s = 0.;
925                         i__1 = j - 2;
926                         for (i__ = 0; i__ <= i__1; ++i__) {
927                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
928 /*                       -> A(j+k,i+k) */
929                             s += aa;
930                             work[i__ + k] += aa;
931                         }
932                         if (j > 0) {
933                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
934 /*                       -> A(j+k,j+k) */
935                             s += aa;
936                             work[i__ + k] += s;
937 /*                       i=j */
938                             ++i__;
939                         }
940                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
941 /*                    -> A(j,j) */
942                         work[j] = aa;
943                         s = 0.;
944                         i__1 = *n - 1;
945                         for (l = j + 1; l <= i__1; ++l) {
946                             ++i__;
947                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
948 /*                       -> A(l,j) */
949                             s += aa;
950                             work[l] += aa;
951                         }
952                         work[j] += s;
953                     }
954                     value = work[0];
955                     i__1 = *n - 1;
956                     for (i__ = 1; i__ <= i__1; ++i__) {
957                         temp = work[i__];
958                         if (value < temp || disnan_(&temp)) {
959                             value = temp;
960                         }
961                     }
962                 }
963             } else {
964 /*              n is even */
965                 if (ilu == 0) {
966                     i__1 = k - 1;
967                     for (i__ = 0; i__ <= i__1; ++i__) {
968                         work[i__] = 0.;
969                     }
970                     i__1 = k - 1;
971                     for (j = 0; j <= i__1; ++j) {
972                         s = 0.;
973                         i__2 = k + j - 1;
974                         for (i__ = 0; i__ <= i__2; ++i__) {
975                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
976 /*                       -> A(i,j+k) */
977                             s += aa;
978                             work[i__] += aa;
979                         }
980                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
981 /*                    -> A(j+k,j+k) */
982                         work[j + k] = s + aa;
983                         ++i__;
984                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
985 /*                    -> A(j,j) */
986                         work[j] += aa;
987                         s = 0.;
988                         i__2 = k - 1;
989                         for (l = j + 1; l <= i__2; ++l) {
990                             ++i__;
991                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
992 /*                       -> A(l,j) */
993                             s += aa;
994                             work[l] += aa;
995                         }
996                         work[j] += s;
997                     }
998                     value = work[0];
999                     i__1 = *n - 1;
1000                     for (i__ = 1; i__ <= i__1; ++i__) {
1001                         temp = work[i__];
1002                         if (value < temp || disnan_(&temp)) {
1003                             value = temp;
1004                         }
1005                     }
1006                 } else {
1007 /*                 ilu = 1 */
1008                     i__1 = *n - 1;
1009                     for (i__ = k; i__ <= i__1; ++i__) {
1010                         work[i__] = 0.;
1011                     }
1012                     for (j = k - 1; j >= 0; --j) {
1013                         s = 0.;
1014                         i__1 = j - 1;
1015                         for (i__ = 0; i__ <= i__1; ++i__) {
1016                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1017 /*                       -> A(j+k,i+k) */
1018                             s += aa;
1019                             work[i__ + k] += aa;
1020                         }
1021                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1022 /*                    -> A(j+k,j+k) */
1023                         s += aa;
1024                         work[i__ + k] += s;
1025 /*                    i=j */
1026                         ++i__;
1027                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1028 /*                    -> A(j,j) */
1029                         work[j] = aa;
1030                         s = 0.;
1031                         i__1 = *n - 1;
1032                         for (l = j + 1; l <= i__1; ++l) {
1033                             ++i__;
1034                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1035 /*                       -> A(l,j) */
1036                             s += aa;
1037                             work[l] += aa;
1038                         }
1039                         work[j] += s;
1040                     }
1041                     value = work[0];
1042                     i__1 = *n - 1;
1043                     for (i__ = 1; i__ <= i__1; ++i__) {
1044                         temp = work[i__];
1045                         if (value < temp || disnan_(&temp)) {
1046                             value = temp;
1047                         }
1048                     }
1049                 }
1050             }
1051         } else {
1052 /*           ifm=0 */
1053             k = *n / 2;
1054             if (noe == 1) {
1055 /*              n is odd */
1056                 if (ilu == 0) {
1057                     n1 = k;
1058 /*                 n/2 */
1059                     ++k;
1060 /*                 k is the row size and lda */
1061                     i__1 = *n - 1;
1062                     for (i__ = n1; i__ <= i__1; ++i__) {
1063                         work[i__] = 0.;
1064                     }
1065                     i__1 = n1 - 1;
1066                     for (j = 0; j <= i__1; ++j) {
1067                         s = 0.;
1068                         i__2 = k - 1;
1069                         for (i__ = 0; i__ <= i__2; ++i__) {
1070                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1071 /*                       A(j,n1+i) */
1072                             work[i__ + n1] += aa;
1073                             s += aa;
1074                         }
1075                         work[j] = s;
1076                     }
1077 /*                 j=n1=k-1 is special */
1078                     s = (d__1 = a[j * lda], abs(d__1));
1079 /*                 A(k-1,k-1) */
1080                     i__1 = k - 1;
1081                     for (i__ = 1; i__ <= i__1; ++i__) {
1082                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1083 /*                    A(k-1,i+n1) */
1084                         work[i__ + n1] += aa;
1085                         s += aa;
1086                     }
1087                     work[j] += s;
1088                     i__1 = *n - 1;
1089                     for (j = k; j <= i__1; ++j) {
1090                         s = 0.;
1091                         i__2 = j - k - 1;
1092                         for (i__ = 0; i__ <= i__2; ++i__) {
1093                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1094 /*                       A(i,j-k) */
1095                             work[i__] += aa;
1096                             s += aa;
1097                         }
1098 /*                    i=j-k */
1099                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1100 /*                    A(j-k,j-k) */
1101                         s += aa;
1102                         work[j - k] += s;
1103                         ++i__;
1104                         s = (d__1 = a[i__ + j * lda], abs(d__1));
1105 /*                    A(j,j) */
1106                         i__2 = *n - 1;
1107                         for (l = j + 1; l <= i__2; ++l) {
1108                             ++i__;
1109                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1110 /*                       A(j,l) */
1111                             work[l] += aa;
1112                             s += aa;
1113                         }
1114                         work[j] += s;
1115                     }
1116                     value = work[0];
1117                     i__1 = *n - 1;
1118                     for (i__ = 1; i__ <= i__1; ++i__) {
1119                         temp = work[i__];
1120                         if (value < temp || disnan_(&temp)) {
1121                             value = temp;
1122                         }
1123                     }
1124                 } else {
1125 /*                 ilu=1 */
1126                     ++k;
1127 /*                 k=(n+1)/2 for n odd and ilu=1 */
1128                     i__1 = *n - 1;
1129                     for (i__ = k; i__ <= i__1; ++i__) {
1130                         work[i__] = 0.;
1131                     }
1132                     i__1 = k - 2;
1133                     for (j = 0; j <= i__1; ++j) {
1134 /*                    process */
1135                         s = 0.;
1136                         i__2 = j - 1;
1137                         for (i__ = 0; i__ <= i__2; ++i__) {
1138                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1139 /*                       A(j,i) */
1140                             work[i__] += aa;
1141                             s += aa;
1142                         }
1143                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1144 /*                    i=j so process of A(j,j) */
1145                         s += aa;
1146                         work[j] = s;
1147 /*                    is initialised here */
1148                         ++i__;
1149 /*                    i=j process A(j+k,j+k) */
1150                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1151                         s = aa;
1152                         i__2 = *n - 1;
1153                         for (l = k + j + 1; l <= i__2; ++l) {
1154                             ++i__;
1155                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1156 /*                       A(l,k+j) */
1157                             s += aa;
1158                             work[l] += aa;
1159                         }
1160                         work[k + j] += s;
1161                     }
1162 /*                 j=k-1 is special :process col A(k-1,0:k-1) */
1163                     s = 0.;
1164                     i__1 = k - 2;
1165                     for (i__ = 0; i__ <= i__1; ++i__) {
1166                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1167 /*                    A(k,i) */
1168                         work[i__] += aa;
1169                         s += aa;
1170                     }
1171 /*                 i=k-1 */
1172                     aa = (d__1 = a[i__ + j * lda], abs(d__1));
1173 /*                 A(k-1,k-1) */
1174                     s += aa;
1175                     work[i__] = s;
1176 /*                 done with col j=k+1 */
1177                     i__1 = *n - 1;
1178                     for (j = k; j <= i__1; ++j) {
1179 /*                    process col j of A = A(j,0:k-1) */
1180                         s = 0.;
1181                         i__2 = k - 1;
1182                         for (i__ = 0; i__ <= i__2; ++i__) {
1183                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1184 /*                       A(j,i) */
1185                             work[i__] += aa;
1186                             s += aa;
1187                         }
1188                         work[j] += s;
1189                     }
1190                     value = work[0];
1191                     i__1 = *n - 1;
1192                     for (i__ = 1; i__ <= i__1; ++i__) {
1193                         temp = work[i__];
1194                         if (value < temp || disnan_(&temp)) {
1195                             value = temp;
1196                         }
1197                     }
1198                 }
1199             } else {
1200 /*              n is even */
1201                 if (ilu == 0) {
1202                     i__1 = *n - 1;
1203                     for (i__ = k; i__ <= i__1; ++i__) {
1204                         work[i__] = 0.;
1205                     }
1206                     i__1 = k - 1;
1207                     for (j = 0; j <= i__1; ++j) {
1208                         s = 0.;
1209                         i__2 = k - 1;
1210                         for (i__ = 0; i__ <= i__2; ++i__) {
1211                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1212 /*                       A(j,i+k) */
1213                             work[i__ + k] += aa;
1214                             s += aa;
1215                         }
1216                         work[j] = s;
1217                     }
1218 /*                 j=k */
1219                     aa = (d__1 = a[j * lda], abs(d__1));
1220 /*                 A(k,k) */
1221                     s = aa;
1222                     i__1 = k - 1;
1223                     for (i__ = 1; i__ <= i__1; ++i__) {
1224                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1225 /*                    A(k,k+i) */
1226                         work[i__ + k] += aa;
1227                         s += aa;
1228                     }
1229                     work[j] += s;
1230                     i__1 = *n - 1;
1231                     for (j = k + 1; j <= i__1; ++j) {
1232                         s = 0.;
1233                         i__2 = j - 2 - k;
1234                         for (i__ = 0; i__ <= i__2; ++i__) {
1235                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1236 /*                       A(i,j-k-1) */
1237                             work[i__] += aa;
1238                             s += aa;
1239                         }
1240 /*                     i=j-1-k */
1241                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1242 /*                    A(j-k-1,j-k-1) */
1243                         s += aa;
1244                         work[j - k - 1] += s;
1245                         ++i__;
1246                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1247 /*                    A(j,j) */
1248                         s = aa;
1249                         i__2 = *n - 1;
1250                         for (l = j + 1; l <= i__2; ++l) {
1251                             ++i__;
1252                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1253 /*                       A(j,l) */
1254                             work[l] += aa;
1255                             s += aa;
1256                         }
1257                         work[j] += s;
1258                     }
1259 /*                 j=n */
1260                     s = 0.;
1261                     i__1 = k - 2;
1262                     for (i__ = 0; i__ <= i__1; ++i__) {
1263                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1264 /*                    A(i,k-1) */
1265                         work[i__] += aa;
1266                         s += aa;
1267                     }
1268 /*                 i=k-1 */
1269                     aa = (d__1 = a[i__ + j * lda], abs(d__1));
1270 /*                 A(k-1,k-1) */
1271                     s += aa;
1272                     work[i__] += s;
1273                     value = work[0];
1274                     i__1 = *n - 1;
1275                     for (i__ = 1; i__ <= i__1; ++i__) {
1276                         temp = work[i__];
1277                         if (value < temp || disnan_(&temp)) {
1278                             value = temp;
1279                         }
1280                     }
1281                 } else {
1282 /*                 ilu=1 */
1283                     i__1 = *n - 1;
1284                     for (i__ = k; i__ <= i__1; ++i__) {
1285                         work[i__] = 0.;
1286                     }
1287 /*                 j=0 is special :process col A(k:n-1,k) */
1288                     s = abs(a[0]);
1289 /*                 A(k,k) */
1290                     i__1 = k - 1;
1291                     for (i__ = 1; i__ <= i__1; ++i__) {
1292                         aa = (d__1 = a[i__], abs(d__1));
1293 /*                    A(k+i,k) */
1294                         work[i__ + k] += aa;
1295                         s += aa;
1296                     }
1297                     work[k] += s;
1298                     i__1 = k - 1;
1299                     for (j = 1; j <= i__1; ++j) {
1300 /*                    process */
1301                         s = 0.;
1302                         i__2 = j - 2;
1303                         for (i__ = 0; i__ <= i__2; ++i__) {
1304                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1305 /*                       A(j-1,i) */
1306                             work[i__] += aa;
1307                             s += aa;
1308                         }
1309                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1310 /*                    i=j-1 so process of A(j-1,j-1) */
1311                         s += aa;
1312                         work[j - 1] = s;
1313 /*                    is initialised here */
1314                         ++i__;
1315 /*                    i=j process A(j+k,j+k) */
1316                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1317                         s = aa;
1318                         i__2 = *n - 1;
1319                         for (l = k + j + 1; l <= i__2; ++l) {
1320                             ++i__;
1321                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1322 /*                       A(l,k+j) */
1323                             s += aa;
1324                             work[l] += aa;
1325                         }
1326                         work[k + j] += s;
1327                     }
1328 /*                 j=k is special :process col A(k,0:k-1) */
1329                     s = 0.;
1330                     i__1 = k - 2;
1331                     for (i__ = 0; i__ <= i__1; ++i__) {
1332                         aa = (d__1 = a[i__ + j * lda], abs(d__1));
1333 /*                    A(k,i) */
1334                         work[i__] += aa;
1335                         s += aa;
1336                     }
1337 /*                 i=k-1 */
1338                     aa = (d__1 = a[i__ + j * lda], abs(d__1));
1339 /*                 A(k-1,k-1) */
1340                     s += aa;
1341                     work[i__] = s;
1342 /*                 done with col j=k+1 */
1343                     i__1 = *n;
1344                     for (j = k + 1; j <= i__1; ++j) {
1345 /*                    process col j-1 of A = A(j-1,0:k-1) */
1346                         s = 0.;
1347                         i__2 = k - 1;
1348                         for (i__ = 0; i__ <= i__2; ++i__) {
1349                             aa = (d__1 = a[i__ + j * lda], abs(d__1));
1350 /*                       A(j-1,i) */
1351                             work[i__] += aa;
1352                             s += aa;
1353                         }
1354                         work[j - 1] += s;
1355                     }
1356                     value = work[0];
1357                     i__1 = *n - 1;
1358                     for (i__ = 1; i__ <= i__1; ++i__) {
1359                         temp = work[i__];
1360                         if (value < temp || disnan_(&temp)) {
1361                             value = temp;
1362                         }
1363                     }
1364                 }
1365             }
1366         }
1367     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
1368
1369 /*       Find normF(A). */
1370
1371         k = (*n + 1) / 2;
1372         scale = 0.;
1373         s = 1.;
1374         if (noe == 1) {
1375 /*           n is odd */
1376             if (ifm == 1) {
1377 /*              A is normal */
1378                 if (ilu == 0) {
1379 /*                 A is upper */
1380                     i__1 = k - 3;
1381                     for (j = 0; j <= i__1; ++j) {
1382                         i__2 = k - j - 2;
1383                         dlassq_(&i__2, &a[k + j + 1 + j * lda], &c__1, &scale,
1384                                  &s);
1385 /*                    L at A(k,0) */
1386                     }
1387                     i__1 = k - 1;
1388                     for (j = 0; j <= i__1; ++j) {
1389                         i__2 = k + j - 1;
1390                         dlassq_(&i__2, &a[j * lda], &c__1, &scale, &s);
1391 /*                    trap U at A(0,0) */
1392                     }
1393                     s += s;
1394 /*                 double s for the off diagonal elements */
1395                     i__1 = k - 1;
1396                     i__2 = lda + 1;
1397                     dlassq_(&i__1, &a[k], &i__2, &scale, &s);
1398 /*                 tri L at A(k,0) */
1399                     i__1 = lda + 1;
1400                     dlassq_(&k, &a[k - 1], &i__1, &scale, &s);
1401 /*                 tri U at A(k-1,0) */
1402                 } else {
1403 /*                 ilu=1 & A is lower */
1404                     i__1 = k - 1;
1405                     for (j = 0; j <= i__1; ++j) {
1406                         i__2 = *n - j - 1;
1407                         dlassq_(&i__2, &a[j + 1 + j * lda], &c__1, &scale, &s)
1408                                 ;
1409 /*                    trap L at A(0,0) */
1410                     }
1411                     i__1 = k - 2;
1412                     for (j = 0; j <= i__1; ++j) {
1413                         dlassq_(&j, &a[(j + 1) * lda], &c__1, &scale, &s);
1414 /*                    U at A(0,1) */
1415                     }
1416                     s += s;
1417 /*                 double s for the off diagonal elements */
1418                     i__1 = lda + 1;
1419                     dlassq_(&k, a, &i__1, &scale, &s);
1420 /*                 tri L at A(0,0) */
1421                     i__1 = k - 1;
1422                     i__2 = lda + 1;
1423                     dlassq_(&i__1, &a[lda], &i__2, &scale, &s);
1424 /*                 tri U at A(0,1) */
1425                 }
1426             } else {
1427 /*              A is xpose */
1428                 if (ilu == 0) {
1429 /*                 A**T is upper */
1430                     i__1 = k - 2;
1431                     for (j = 1; j <= i__1; ++j) {
1432                         dlassq_(&j, &a[(k + j) * lda], &c__1, &scale, &s);
1433 /*                    U at A(0,k) */
1434                     }
1435                     i__1 = k - 2;
1436                     for (j = 0; j <= i__1; ++j) {
1437                         dlassq_(&k, &a[j * lda], &c__1, &scale, &s);
1438 /*                    k by k-1 rect. at A(0,0) */
1439                     }
1440                     i__1 = k - 2;
1441                     for (j = 0; j <= i__1; ++j) {
1442                         i__2 = k - j - 1;
1443                         dlassq_(&i__2, &a[j + 1 + (j + k - 1) * lda], &c__1, &
1444                                 scale, &s);
1445 /*                    L at A(0,k-1) */
1446                     }
1447                     s += s;
1448 /*                 double s for the off diagonal elements */
1449                     i__1 = k - 1;
1450                     i__2 = lda + 1;
1451                     dlassq_(&i__1, &a[k * lda], &i__2, &scale, &s);
1452 /*                 tri U at A(0,k) */
1453                     i__1 = lda + 1;
1454                     dlassq_(&k, &a[(k - 1) * lda], &i__1, &scale, &s);
1455 /*                 tri L at A(0,k-1) */
1456                 } else {
1457 /*                 A**T is lower */
1458                     i__1 = k - 1;
1459                     for (j = 1; j <= i__1; ++j) {
1460                         dlassq_(&j, &a[j * lda], &c__1, &scale, &s);
1461 /*                    U at A(0,0) */
1462                     }
1463                     i__1 = *n - 1;
1464                     for (j = k; j <= i__1; ++j) {
1465                         dlassq_(&k, &a[j * lda], &c__1, &scale, &s);
1466 /*                    k by k-1 rect. at A(0,k) */
1467                     }
1468                     i__1 = k - 3;
1469                     for (j = 0; j <= i__1; ++j) {
1470                         i__2 = k - j - 2;
1471                         dlassq_(&i__2, &a[j + 2 + j * lda], &c__1, &scale, &s)
1472                                 ;
1473 /*                    L at A(1,0) */
1474                     }
1475                     s += s;
1476 /*                 double s for the off diagonal elements */
1477                     i__1 = lda + 1;
1478                     dlassq_(&k, a, &i__1, &scale, &s);
1479 /*                 tri U at A(0,0) */
1480                     i__1 = k - 1;
1481                     i__2 = lda + 1;
1482                     dlassq_(&i__1, &a[1], &i__2, &scale, &s);
1483 /*                 tri L at A(1,0) */
1484                 }
1485             }
1486         } else {
1487 /*           n is even */
1488             if (ifm == 1) {
1489 /*              A is normal */
1490                 if (ilu == 0) {
1491 /*                 A is upper */
1492                     i__1 = k - 2;
1493                     for (j = 0; j <= i__1; ++j) {
1494                         i__2 = k - j - 1;
1495                         dlassq_(&i__2, &a[k + j + 2 + j * lda], &c__1, &scale,
1496                                  &s);
1497 /*                    L at A(k+1,0) */
1498                     }
1499                     i__1 = k - 1;
1500                     for (j = 0; j <= i__1; ++j) {
1501                         i__2 = k + j;
1502                         dlassq_(&i__2, &a[j * lda], &c__1, &scale, &s);
1503 /*                    trap U at A(0,0) */
1504                     }
1505                     s += s;
1506 /*                 double s for the off diagonal elements */
1507                     i__1 = lda + 1;
1508                     dlassq_(&k, &a[k + 1], &i__1, &scale, &s);
1509 /*                 tri L at A(k+1,0) */
1510                     i__1 = lda + 1;
1511                     dlassq_(&k, &a[k], &i__1, &scale, &s);
1512 /*                 tri U at A(k,0) */
1513                 } else {
1514 /*                 ilu=1 & A is lower */
1515                     i__1 = k - 1;
1516                     for (j = 0; j <= i__1; ++j) {
1517                         i__2 = *n - j - 1;
1518                         dlassq_(&i__2, &a[j + 2 + j * lda], &c__1, &scale, &s)
1519                                 ;
1520 /*                    trap L at A(1,0) */
1521                     }
1522                     i__1 = k - 1;
1523                     for (j = 1; j <= i__1; ++j) {
1524                         dlassq_(&j, &a[j * lda], &c__1, &scale, &s);
1525 /*                    U at A(0,0) */
1526                     }
1527                     s += s;
1528 /*                 double s for the off diagonal elements */
1529                     i__1 = lda + 1;
1530                     dlassq_(&k, &a[1], &i__1, &scale, &s);
1531 /*                 tri L at A(1,0) */
1532                     i__1 = lda + 1;
1533                     dlassq_(&k, a, &i__1, &scale, &s);
1534 /*                 tri U at A(0,0) */
1535                 }
1536             } else {
1537 /*              A is xpose */
1538                 if (ilu == 0) {
1539 /*                 A**T is upper */
1540                     i__1 = k - 1;
1541                     for (j = 1; j <= i__1; ++j) {
1542                         dlassq_(&j, &a[(k + 1 + j) * lda], &c__1, &scale, &s);
1543 /*                    U at A(0,k+1) */
1544                     }
1545                     i__1 = k - 1;
1546                     for (j = 0; j <= i__1; ++j) {
1547                         dlassq_(&k, &a[j * lda], &c__1, &scale, &s);
1548 /*                    k by k rect. at A(0,0) */
1549                     }
1550                     i__1 = k - 2;
1551                     for (j = 0; j <= i__1; ++j) {
1552                         i__2 = k - j - 1;
1553                         dlassq_(&i__2, &a[j + 1 + (j + k) * lda], &c__1, &
1554                                 scale, &s);
1555 /*                    L at A(0,k) */
1556                     }
1557                     s += s;
1558 /*                 double s for the off diagonal elements */
1559                     i__1 = lda + 1;
1560                     dlassq_(&k, &a[(k + 1) * lda], &i__1, &scale, &s);
1561 /*                 tri U at A(0,k+1) */
1562                     i__1 = lda + 1;
1563                     dlassq_(&k, &a[k * lda], &i__1, &scale, &s);
1564 /*                 tri L at A(0,k) */
1565                 } else {
1566 /*                 A**T is lower */
1567                     i__1 = k - 1;
1568                     for (j = 1; j <= i__1; ++j) {
1569                         dlassq_(&j, &a[(j + 1) * lda], &c__1, &scale, &s);
1570 /*                    U at A(0,1) */
1571                     }
1572                     i__1 = *n;
1573                     for (j = k + 1; j <= i__1; ++j) {
1574                         dlassq_(&k, &a[j * lda], &c__1, &scale, &s);
1575 /*                    k by k rect. at A(0,k+1) */
1576                     }
1577                     i__1 = k - 2;
1578                     for (j = 0; j <= i__1; ++j) {
1579                         i__2 = k - j - 1;
1580                         dlassq_(&i__2, &a[j + 1 + j * lda], &c__1, &scale, &s)
1581                                 ;
1582 /*                    L at A(0,0) */
1583                     }
1584                     s += s;
1585 /*                 double s for the off diagonal elements */
1586                     i__1 = lda + 1;
1587                     dlassq_(&k, &a[lda], &i__1, &scale, &s);
1588 /*                 tri L at A(0,1) */
1589                     i__1 = lda + 1;
1590                     dlassq_(&k, a, &i__1, &scale, &s);
1591 /*                 tri U at A(0,0) */
1592                 }
1593             }
1594         }
1595         value = scale * sqrt(s);
1596     }
1597
1598     ret_val = value;
1599     return ret_val;
1600
1601 /*     End of DLANSF */
1602
1603 } /* dlansf_ */
1604