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