You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

slansf.c 41 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500
  1. /* f2c.h -- Standard Fortran to C header file */
  2. /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
  3. - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
  4. #ifndef F2C_INCLUDE
  5. #define F2C_INCLUDE
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <complex.h>
  11. #ifdef complex
  12. #undef complex
  13. #endif
  14. #ifdef I
  15. #undef I
  16. #endif
  17. #if defined(OS_WINDOWS) && defined(__64BIT__)
  18. typedef long long BLASLONG;
  19. typedef unsigned long long BLASULONG;
  20. #else
  21. typedef long BLASLONG;
  22. typedef unsigned long BLASULONG;
  23. #endif
  24. #ifdef LAPACK_ILP64
  25. typedef BLASLONG blasint;
  26. #if defined(OS_WINDOWS) && defined(__64BIT__)
  27. #define blasabs(x) llabs(x)
  28. #else
  29. #define blasabs(x) labs(x)
  30. #endif
  31. #else
  32. typedef int blasint;
  33. #define blasabs(x) abs(x)
  34. #endif
  35. typedef blasint integer;
  36. typedef unsigned int uinteger;
  37. typedef char *address;
  38. typedef short int shortint;
  39. typedef float real;
  40. typedef double doublereal;
  41. typedef struct { real r, i; } complex;
  42. typedef struct { doublereal r, i; } doublecomplex;
  43. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  44. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  46. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  47. #define pCf(z) (*_pCf(z))
  48. #define pCd(z) (*_pCd(z))
  49. typedef int logical;
  50. typedef short int shortlogical;
  51. typedef char logical1;
  52. typedef char integer1;
  53. #define TRUE_ (1)
  54. #define FALSE_ (0)
  55. /* Extern is for use with -E */
  56. #ifndef Extern
  57. #define Extern extern
  58. #endif
  59. /* I/O stuff */
  60. typedef int flag;
  61. typedef int ftnlen;
  62. typedef int ftnint;
  63. /*external read, write*/
  64. typedef struct
  65. { flag cierr;
  66. ftnint ciunit;
  67. flag ciend;
  68. char *cifmt;
  69. ftnint cirec;
  70. } cilist;
  71. /*internal read, write*/
  72. typedef struct
  73. { flag icierr;
  74. char *iciunit;
  75. flag iciend;
  76. char *icifmt;
  77. ftnint icirlen;
  78. ftnint icirnum;
  79. } icilist;
  80. /*open*/
  81. typedef struct
  82. { flag oerr;
  83. ftnint ounit;
  84. char *ofnm;
  85. ftnlen ofnmlen;
  86. char *osta;
  87. char *oacc;
  88. char *ofm;
  89. ftnint orl;
  90. char *oblnk;
  91. } olist;
  92. /*close*/
  93. typedef struct
  94. { flag cerr;
  95. ftnint cunit;
  96. char *csta;
  97. } cllist;
  98. /*rewind, backspace, endfile*/
  99. typedef struct
  100. { flag aerr;
  101. ftnint aunit;
  102. } alist;
  103. /* inquire */
  104. typedef struct
  105. { flag inerr;
  106. ftnint inunit;
  107. char *infile;
  108. ftnlen infilen;
  109. ftnint *inex; /*parameters in standard's order*/
  110. ftnint *inopen;
  111. ftnint *innum;
  112. ftnint *innamed;
  113. char *inname;
  114. ftnlen innamlen;
  115. char *inacc;
  116. ftnlen inacclen;
  117. char *inseq;
  118. ftnlen inseqlen;
  119. char *indir;
  120. ftnlen indirlen;
  121. char *infmt;
  122. ftnlen infmtlen;
  123. char *inform;
  124. ftnint informlen;
  125. char *inunf;
  126. ftnlen inunflen;
  127. ftnint *inrecl;
  128. ftnint *innrec;
  129. char *inblank;
  130. ftnlen inblanklen;
  131. } inlist;
  132. #define VOID void
  133. union Multitype { /* for multiple entry points */
  134. integer1 g;
  135. shortint h;
  136. integer i;
  137. /* longint j; */
  138. real r;
  139. doublereal d;
  140. complex c;
  141. doublecomplex z;
  142. };
  143. typedef union Multitype Multitype;
  144. struct Vardesc { /* for Namelist */
  145. char *name;
  146. char *addr;
  147. ftnlen *dims;
  148. int type;
  149. };
  150. typedef struct Vardesc Vardesc;
  151. struct Namelist {
  152. char *name;
  153. Vardesc **vars;
  154. int nvars;
  155. };
  156. typedef struct Namelist Namelist;
  157. #define abs(x) ((x) >= 0 ? (x) : -(x))
  158. #define dabs(x) (fabs(x))
  159. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  160. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  161. #define dmin(a,b) (f2cmin(a,b))
  162. #define dmax(a,b) (f2cmax(a,b))
  163. #define bit_test(a,b) ((a) >> (b) & 1)
  164. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  165. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  166. #define abort_() { sig_die("Fortran abort routine called", 1); }
  167. #define c_abs(z) (cabsf(Cf(z)))
  168. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  169. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  170. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  171. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  172. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  173. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  174. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  175. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  176. #define d_abs(x) (fabs(*(x)))
  177. #define d_acos(x) (acos(*(x)))
  178. #define d_asin(x) (asin(*(x)))
  179. #define d_atan(x) (atan(*(x)))
  180. #define d_atn2(x, y) (atan2(*(x),*(y)))
  181. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  182. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  183. #define d_cos(x) (cos(*(x)))
  184. #define d_cosh(x) (cosh(*(x)))
  185. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  186. #define d_exp(x) (exp(*(x)))
  187. #define d_imag(z) (cimag(Cd(z)))
  188. #define r_imag(z) (cimag(Cf(z)))
  189. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  190. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  191. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  192. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  193. #define d_log(x) (log(*(x)))
  194. #define d_mod(x, y) (fmod(*(x), *(y)))
  195. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  196. #define d_nint(x) u_nint(*(x))
  197. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  198. #define d_sign(a,b) u_sign(*(a),*(b))
  199. #define r_sign(a,b) u_sign(*(a),*(b))
  200. #define d_sin(x) (sin(*(x)))
  201. #define d_sinh(x) (sinh(*(x)))
  202. #define d_sqrt(x) (sqrt(*(x)))
  203. #define d_tan(x) (tan(*(x)))
  204. #define d_tanh(x) (tanh(*(x)))
  205. #define i_abs(x) abs(*(x))
  206. #define i_dnnt(x) ((integer)u_nint(*(x)))
  207. #define i_len(s, n) (n)
  208. #define i_nint(x) ((integer)u_nint(*(x)))
  209. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  210. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  211. #define pow_si(B,E) spow_ui(*(B),*(E))
  212. #define pow_ri(B,E) spow_ui(*(B),*(E))
  213. #define pow_di(B,E) dpow_ui(*(B),*(E))
  214. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  215. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  216. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  217. #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++ = ' '; }
  218. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  219. #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]; }
  220. #define sig_die(s, kill) { exit(1); }
  221. #define s_stop(s, n) {exit(0);}
  222. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  223. #define z_abs(z) (cabs(Cd(z)))
  224. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  225. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  226. #define myexit_() break;
  227. #define mycycle() continue;
  228. #define myceiling(w) {ceil(w)}
  229. #define myhuge(w) {HUGE_VAL}
  230. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  231. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  232. /* procedure parameter types for -A and -C++ */
  233. #define F2C_proc_par_types 1
  234. #ifdef __cplusplus
  235. typedef logical (*L_fp)(...);
  236. #else
  237. typedef logical (*L_fp)();
  238. #endif
  239. static float spow_ui(float x, integer n) {
  240. float pow=1.0; unsigned long int u;
  241. if(n != 0) {
  242. if(n < 0) n = -n, x = 1/x;
  243. for(u = n; ; ) {
  244. if(u & 01) pow *= x;
  245. if(u >>= 1) x *= x;
  246. else break;
  247. }
  248. }
  249. return pow;
  250. }
  251. static double dpow_ui(double x, integer n) {
  252. double pow=1.0; unsigned long int u;
  253. if(n != 0) {
  254. if(n < 0) n = -n, x = 1/x;
  255. for(u = n; ; ) {
  256. if(u & 01) pow *= x;
  257. if(u >>= 1) x *= x;
  258. else break;
  259. }
  260. }
  261. return pow;
  262. }
  263. static _Complex float cpow_ui(_Complex float x, integer n) {
  264. _Complex float pow=1.0; unsigned long int u;
  265. if(n != 0) {
  266. if(n < 0) n = -n, x = 1/x;
  267. for(u = n; ; ) {
  268. if(u & 01) pow *= x;
  269. if(u >>= 1) x *= x;
  270. else break;
  271. }
  272. }
  273. return pow;
  274. }
  275. static _Complex double zpow_ui(_Complex double x, integer n) {
  276. _Complex double pow=1.0; unsigned long int u;
  277. if(n != 0) {
  278. if(n < 0) n = -n, x = 1/x;
  279. for(u = n; ; ) {
  280. if(u & 01) pow *= x;
  281. if(u >>= 1) x *= x;
  282. else break;
  283. }
  284. }
  285. return pow;
  286. }
  287. static integer pow_ii(integer x, integer n) {
  288. integer pow; unsigned long int u;
  289. if (n <= 0) {
  290. if (n == 0 || x == 1) pow = 1;
  291. else if (x != -1) pow = x == 0 ? 1/x : 0;
  292. else n = -n;
  293. }
  294. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  295. u = n;
  296. for(pow = 1; ; ) {
  297. if(u & 01) pow *= x;
  298. if(u >>= 1) x *= x;
  299. else break;
  300. }
  301. }
  302. return pow;
  303. }
  304. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  305. {
  306. double m; integer i, mi;
  307. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  308. if (w[i-1]>m) mi=i ,m=w[i-1];
  309. return mi-s+1;
  310. }
  311. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  312. {
  313. float m; integer i, mi;
  314. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  315. if (w[i-1]>m) mi=i ,m=w[i-1];
  316. return mi-s+1;
  317. }
  318. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  319. integer n = *n_, incx = *incx_, incy = *incy_, i;
  320. _Complex float zdotc = 0.0;
  321. if (incx == 1 && incy == 1) {
  322. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  323. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  324. }
  325. } else {
  326. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  327. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  328. }
  329. }
  330. pCf(z) = zdotc;
  331. }
  332. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  333. integer n = *n_, incx = *incx_, incy = *incy_, i;
  334. _Complex double zdotc = 0.0;
  335. if (incx == 1 && incy == 1) {
  336. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  337. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  338. }
  339. } else {
  340. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  341. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  342. }
  343. }
  344. pCd(z) = zdotc;
  345. }
  346. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  347. integer n = *n_, incx = *incx_, incy = *incy_, i;
  348. _Complex float zdotc = 0.0;
  349. if (incx == 1 && incy == 1) {
  350. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  351. zdotc += Cf(&x[i]) * Cf(&y[i]);
  352. }
  353. } else {
  354. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  355. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  356. }
  357. }
  358. pCf(z) = zdotc;
  359. }
  360. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  361. integer n = *n_, incx = *incx_, incy = *incy_, i;
  362. _Complex double zdotc = 0.0;
  363. if (incx == 1 && incy == 1) {
  364. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  365. zdotc += Cd(&x[i]) * Cd(&y[i]);
  366. }
  367. } else {
  368. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  369. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  370. }
  371. }
  372. pCd(z) = zdotc;
  373. }
  374. #endif
  375. /* -- translated by f2c (version 20000121).
  376. You must link the resulting object file with the libraries:
  377. -lf2c -lm (in that order)
  378. */
  379. /* Table of constant values */
  380. static integer c__1 = 1;
  381. /* > \brief \b SLANSF */
  382. /* =========== DOCUMENTATION =========== */
  383. /* Online html documentation available at */
  384. /* http://www.netlib.org/lapack/explore-html/ */
  385. /* > \htmlonly */
  386. /* > Download SLANSF + dependencies */
  387. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slansf.
  388. f"> */
  389. /* > [TGZ]</a> */
  390. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slansf.
  391. f"> */
  392. /* > [ZIP]</a> */
  393. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slansf.
  394. f"> */
  395. /* > [TXT]</a> */
  396. /* > \endhtmlonly */
  397. /* Definition: */
  398. /* =========== */
  399. /* REAL FUNCTION SLANSF( NORM, TRANSR, UPLO, N, A, WORK ) */
  400. /* CHARACTER NORM, TRANSR, UPLO */
  401. /* INTEGER N */
  402. /* REAL A( 0: * ), WORK( 0: * ) */
  403. /* > \par Purpose: */
  404. /* ============= */
  405. /* > */
  406. /* > \verbatim */
  407. /* > */
  408. /* > SLANSF returns the value of the one norm, or the Frobenius norm, or */
  409. /* > the infinity norm, or the element of largest absolute value of a */
  410. /* > real symmetric matrix A in RFP format. */
  411. /* > \endverbatim */
  412. /* > */
  413. /* > \return SLANSF */
  414. /* > \verbatim */
  415. /* > */
  416. /* > SLANSF = ( f2cmax(abs(A(i,j))), NORM = 'M' or 'm' */
  417. /* > ( */
  418. /* > ( norm1(A), NORM = '1', 'O' or 'o' */
  419. /* > ( */
  420. /* > ( normI(A), NORM = 'I' or 'i' */
  421. /* > ( */
  422. /* > ( normF(A), NORM = 'F', 'f', 'E' or 'e' */
  423. /* > */
  424. /* > where norm1 denotes the one norm of a matrix (maximum column sum), */
  425. /* > normI denotes the infinity norm of a matrix (maximum row sum) and */
  426. /* > normF denotes the Frobenius norm of a matrix (square root of sum of */
  427. /* > squares). Note that f2cmax(abs(A(i,j))) is not a matrix norm. */
  428. /* > \endverbatim */
  429. /* Arguments: */
  430. /* ========== */
  431. /* > \param[in] NORM */
  432. /* > \verbatim */
  433. /* > NORM is CHARACTER*1 */
  434. /* > Specifies the value to be returned in SLANSF as described */
  435. /* > above. */
  436. /* > \endverbatim */
  437. /* > */
  438. /* > \param[in] TRANSR */
  439. /* > \verbatim */
  440. /* > TRANSR is CHARACTER*1 */
  441. /* > Specifies whether the RFP format of A is normal or */
  442. /* > transposed format. */
  443. /* > = 'N': RFP format is Normal; */
  444. /* > = 'T': RFP format is Transpose. */
  445. /* > \endverbatim */
  446. /* > */
  447. /* > \param[in] UPLO */
  448. /* > \verbatim */
  449. /* > UPLO is CHARACTER*1 */
  450. /* > On entry, UPLO specifies whether the RFP matrix A came from */
  451. /* > an upper or lower triangular matrix as follows: */
  452. /* > = 'U': RFP A came from an upper triangular matrix; */
  453. /* > = 'L': RFP A came from a lower triangular matrix. */
  454. /* > \endverbatim */
  455. /* > */
  456. /* > \param[in] N */
  457. /* > \verbatim */
  458. /* > N is INTEGER */
  459. /* > The order of the matrix A. N >= 0. When N = 0, SLANSF is */
  460. /* > set to zero. */
  461. /* > \endverbatim */
  462. /* > */
  463. /* > \param[in] A */
  464. /* > \verbatim */
  465. /* > A is REAL array, dimension ( N*(N+1)/2 ); */
  466. /* > On entry, the upper (if UPLO = 'U') or lower (if UPLO = 'L') */
  467. /* > part of the symmetric matrix A stored in RFP format. See the */
  468. /* > "Notes" below for more details. */
  469. /* > Unchanged on exit. */
  470. /* > \endverbatim */
  471. /* > */
  472. /* > \param[out] WORK */
  473. /* > \verbatim */
  474. /* > WORK is REAL array, dimension (MAX(1,LWORK)), */
  475. /* > where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */
  476. /* > WORK is not referenced. */
  477. /* > \endverbatim */
  478. /* Authors: */
  479. /* ======== */
  480. /* > \author Univ. of Tennessee */
  481. /* > \author Univ. of California Berkeley */
  482. /* > \author Univ. of Colorado Denver */
  483. /* > \author NAG Ltd. */
  484. /* > \date December 2016 */
  485. /* > \ingroup realOTHERcomputational */
  486. /* > \par Further Details: */
  487. /* ===================== */
  488. /* > */
  489. /* > \verbatim */
  490. /* > */
  491. /* > We first consider Rectangular Full Packed (RFP) Format when N is */
  492. /* > even. We give an example where N = 6. */
  493. /* > */
  494. /* > AP is Upper AP is Lower */
  495. /* > */
  496. /* > 00 01 02 03 04 05 00 */
  497. /* > 11 12 13 14 15 10 11 */
  498. /* > 22 23 24 25 20 21 22 */
  499. /* > 33 34 35 30 31 32 33 */
  500. /* > 44 45 40 41 42 43 44 */
  501. /* > 55 50 51 52 53 54 55 */
  502. /* > */
  503. /* > */
  504. /* > Let TRANSR = 'N'. RFP holds AP as follows: */
  505. /* > For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */
  506. /* > three columns of AP upper. The lower triangle A(4:6,0:2) consists of */
  507. /* > the transpose of the first three columns of AP upper. */
  508. /* > For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */
  509. /* > three columns of AP lower. The upper triangle A(0:2,0:2) consists of */
  510. /* > the transpose of the last three columns of AP lower. */
  511. /* > This covers the case N even and TRANSR = 'N'. */
  512. /* > */
  513. /* > RFP A RFP A */
  514. /* > */
  515. /* > 03 04 05 33 43 53 */
  516. /* > 13 14 15 00 44 54 */
  517. /* > 23 24 25 10 11 55 */
  518. /* > 33 34 35 20 21 22 */
  519. /* > 00 44 45 30 31 32 */
  520. /* > 01 11 55 40 41 42 */
  521. /* > 02 12 22 50 51 52 */
  522. /* > */
  523. /* > Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */
  524. /* > transpose of RFP A above. One therefore gets: */
  525. /* > */
  526. /* > */
  527. /* > RFP A RFP A */
  528. /* > */
  529. /* > 03 13 23 33 00 01 02 33 00 10 20 30 40 50 */
  530. /* > 04 14 24 34 44 11 12 43 44 11 21 31 41 51 */
  531. /* > 05 15 25 35 45 55 22 53 54 55 22 32 42 52 */
  532. /* > */
  533. /* > */
  534. /* > We then consider Rectangular Full Packed (RFP) Format when N is */
  535. /* > odd. We give an example where N = 5. */
  536. /* > */
  537. /* > AP is Upper AP is Lower */
  538. /* > */
  539. /* > 00 01 02 03 04 00 */
  540. /* > 11 12 13 14 10 11 */
  541. /* > 22 23 24 20 21 22 */
  542. /* > 33 34 30 31 32 33 */
  543. /* > 44 40 41 42 43 44 */
  544. /* > */
  545. /* > */
  546. /* > Let TRANSR = 'N'. RFP holds AP as follows: */
  547. /* > For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */
  548. /* > three columns of AP upper. The lower triangle A(3:4,0:1) consists of */
  549. /* > the transpose of the first two columns of AP upper. */
  550. /* > For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */
  551. /* > three columns of AP lower. The upper triangle A(0:1,1:2) consists of */
  552. /* > the transpose of the last two columns of AP lower. */
  553. /* > This covers the case N odd and TRANSR = 'N'. */
  554. /* > */
  555. /* > RFP A RFP A */
  556. /* > */
  557. /* > 02 03 04 00 33 43 */
  558. /* > 12 13 14 10 11 44 */
  559. /* > 22 23 24 20 21 22 */
  560. /* > 00 33 34 30 31 32 */
  561. /* > 01 11 44 40 41 42 */
  562. /* > */
  563. /* > Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */
  564. /* > transpose of RFP A above. One therefore gets: */
  565. /* > */
  566. /* > RFP A RFP A */
  567. /* > */
  568. /* > 02 12 22 00 01 00 10 20 30 40 50 */
  569. /* > 03 13 23 33 11 33 11 21 31 41 51 */
  570. /* > 04 14 24 34 44 43 44 22 32 42 52 */
  571. /* > \endverbatim */
  572. /* ===================================================================== */
  573. real slansf_(char *norm, char *transr, char *uplo, integer *n, real *a, real *
  574. work)
  575. {
  576. /* System generated locals */
  577. integer i__1, i__2;
  578. real ret_val, r__1;
  579. /* Local variables */
  580. real temp;
  581. integer i__, j, k, l;
  582. real s, scale;
  583. extern logical lsame_(char *, char *);
  584. real value;
  585. integer n1;
  586. real aa;
  587. extern logical sisnan_(real *);
  588. extern /* Subroutine */ int slassq_(integer *, real *, integer *, real *,
  589. real *);
  590. integer lda, ifm, noe, ilu;
  591. /* -- LAPACK computational routine (version 3.7.0) -- */
  592. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  593. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  594. /* December 2016 */
  595. /* ===================================================================== */
  596. if (*n == 0) {
  597. ret_val = 0.f;
  598. return ret_val;
  599. } else if (*n == 1) {
  600. ret_val = abs(a[0]);
  601. return ret_val;
  602. }
  603. /* set noe = 1 if n is odd. if n is even set noe=0 */
  604. noe = 1;
  605. if (*n % 2 == 0) {
  606. noe = 0;
  607. }
  608. /* set ifm = 0 when form='T or 't' and 1 otherwise */
  609. ifm = 1;
  610. if (lsame_(transr, "T")) {
  611. ifm = 0;
  612. }
  613. /* set ilu = 0 when uplo='U or 'u' and 1 otherwise */
  614. ilu = 1;
  615. if (lsame_(uplo, "U")) {
  616. ilu = 0;
  617. }
  618. /* set lda = (n+1)/2 when ifm = 0 */
  619. /* set lda = n when ifm = 1 and noe = 1 */
  620. /* set lda = n+1 when ifm = 1 and noe = 0 */
  621. if (ifm == 1) {
  622. if (noe == 1) {
  623. lda = *n;
  624. } else {
  625. /* noe=0 */
  626. lda = *n + 1;
  627. }
  628. } else {
  629. /* ifm=0 */
  630. lda = (*n + 1) / 2;
  631. }
  632. if (lsame_(norm, "M")) {
  633. /* Find f2cmax(abs(A(i,j))). */
  634. k = (*n + 1) / 2;
  635. value = 0.f;
  636. if (noe == 1) {
  637. /* n is odd */
  638. if (ifm == 1) {
  639. /* A is n by k */
  640. i__1 = k - 1;
  641. for (j = 0; j <= i__1; ++j) {
  642. i__2 = *n - 1;
  643. for (i__ = 0; i__ <= i__2; ++i__) {
  644. temp = (r__1 = a[i__ + j * lda], abs(r__1));
  645. if (value < temp || sisnan_(&temp)) {
  646. value = temp;
  647. }
  648. }
  649. }
  650. } else {
  651. /* xpose case; A is k by n */
  652. i__1 = *n - 1;
  653. for (j = 0; j <= i__1; ++j) {
  654. i__2 = k - 1;
  655. for (i__ = 0; i__ <= i__2; ++i__) {
  656. temp = (r__1 = a[i__ + j * lda], abs(r__1));
  657. if (value < temp || sisnan_(&temp)) {
  658. value = temp;
  659. }
  660. }
  661. }
  662. }
  663. } else {
  664. /* n is even */
  665. if (ifm == 1) {
  666. /* A is n+1 by k */
  667. i__1 = k - 1;
  668. for (j = 0; j <= i__1; ++j) {
  669. i__2 = *n;
  670. for (i__ = 0; i__ <= i__2; ++i__) {
  671. temp = (r__1 = a[i__ + j * lda], abs(r__1));
  672. if (value < temp || sisnan_(&temp)) {
  673. value = temp;
  674. }
  675. }
  676. }
  677. } else {
  678. /* xpose case; A is k by n+1 */
  679. i__1 = *n;
  680. for (j = 0; j <= i__1; ++j) {
  681. i__2 = k - 1;
  682. for (i__ = 0; i__ <= i__2; ++i__) {
  683. temp = (r__1 = a[i__ + j * lda], abs(r__1));
  684. if (value < temp || sisnan_(&temp)) {
  685. value = temp;
  686. }
  687. }
  688. }
  689. }
  690. }
  691. } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') {
  692. /* Find normI(A) ( = norm1(A), since A is symmetric). */
  693. if (ifm == 1) {
  694. k = *n / 2;
  695. if (noe == 1) {
  696. /* n is odd */
  697. if (ilu == 0) {
  698. i__1 = k - 1;
  699. for (i__ = 0; i__ <= i__1; ++i__) {
  700. work[i__] = 0.f;
  701. }
  702. i__1 = k;
  703. for (j = 0; j <= i__1; ++j) {
  704. s = 0.f;
  705. i__2 = k + j - 1;
  706. for (i__ = 0; i__ <= i__2; ++i__) {
  707. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  708. /* -> A(i,j+k) */
  709. s += aa;
  710. work[i__] += aa;
  711. }
  712. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  713. /* -> A(j+k,j+k) */
  714. work[j + k] = s + aa;
  715. if (i__ == k + k) {
  716. goto L10;
  717. }
  718. ++i__;
  719. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  720. /* -> A(j,j) */
  721. work[j] += aa;
  722. s = 0.f;
  723. i__2 = k - 1;
  724. for (l = j + 1; l <= i__2; ++l) {
  725. ++i__;
  726. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  727. /* -> A(l,j) */
  728. s += aa;
  729. work[l] += aa;
  730. }
  731. work[j] += s;
  732. }
  733. L10:
  734. value = work[0];
  735. i__1 = *n - 1;
  736. for (i__ = 1; i__ <= i__1; ++i__) {
  737. temp = work[i__];
  738. if (value < temp || sisnan_(&temp)) {
  739. value = temp;
  740. }
  741. }
  742. } else {
  743. /* ilu = 1 */
  744. ++k;
  745. /* k=(n+1)/2 for n odd and ilu=1 */
  746. i__1 = *n - 1;
  747. for (i__ = k; i__ <= i__1; ++i__) {
  748. work[i__] = 0.f;
  749. }
  750. for (j = k - 1; j >= 0; --j) {
  751. s = 0.f;
  752. i__1 = j - 2;
  753. for (i__ = 0; i__ <= i__1; ++i__) {
  754. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  755. /* -> A(j+k,i+k) */
  756. s += aa;
  757. work[i__ + k] += aa;
  758. }
  759. if (j > 0) {
  760. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  761. /* -> A(j+k,j+k) */
  762. s += aa;
  763. work[i__ + k] += s;
  764. /* i=j */
  765. ++i__;
  766. }
  767. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  768. /* -> A(j,j) */
  769. work[j] = aa;
  770. s = 0.f;
  771. i__1 = *n - 1;
  772. for (l = j + 1; l <= i__1; ++l) {
  773. ++i__;
  774. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  775. /* -> A(l,j) */
  776. s += aa;
  777. work[l] += aa;
  778. }
  779. work[j] += s;
  780. }
  781. value = work[0];
  782. i__1 = *n - 1;
  783. for (i__ = 1; i__ <= i__1; ++i__) {
  784. temp = work[i__];
  785. if (value < temp || sisnan_(&temp)) {
  786. value = temp;
  787. }
  788. }
  789. }
  790. } else {
  791. /* n is even */
  792. if (ilu == 0) {
  793. i__1 = k - 1;
  794. for (i__ = 0; i__ <= i__1; ++i__) {
  795. work[i__] = 0.f;
  796. }
  797. i__1 = k - 1;
  798. for (j = 0; j <= i__1; ++j) {
  799. s = 0.f;
  800. i__2 = k + j - 1;
  801. for (i__ = 0; i__ <= i__2; ++i__) {
  802. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  803. /* -> A(i,j+k) */
  804. s += aa;
  805. work[i__] += aa;
  806. }
  807. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  808. /* -> A(j+k,j+k) */
  809. work[j + k] = s + aa;
  810. ++i__;
  811. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  812. /* -> A(j,j) */
  813. work[j] += aa;
  814. s = 0.f;
  815. i__2 = k - 1;
  816. for (l = j + 1; l <= i__2; ++l) {
  817. ++i__;
  818. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  819. /* -> A(l,j) */
  820. s += aa;
  821. work[l] += aa;
  822. }
  823. work[j] += s;
  824. }
  825. value = work[0];
  826. i__1 = *n - 1;
  827. for (i__ = 1; i__ <= i__1; ++i__) {
  828. temp = work[i__];
  829. if (value < temp || sisnan_(&temp)) {
  830. value = temp;
  831. }
  832. }
  833. } else {
  834. /* ilu = 1 */
  835. i__1 = *n - 1;
  836. for (i__ = k; i__ <= i__1; ++i__) {
  837. work[i__] = 0.f;
  838. }
  839. for (j = k - 1; j >= 0; --j) {
  840. s = 0.f;
  841. i__1 = j - 1;
  842. for (i__ = 0; i__ <= i__1; ++i__) {
  843. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  844. /* -> A(j+k,i+k) */
  845. s += aa;
  846. work[i__ + k] += aa;
  847. }
  848. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  849. /* -> A(j+k,j+k) */
  850. s += aa;
  851. work[i__ + k] += s;
  852. /* i=j */
  853. ++i__;
  854. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  855. /* -> A(j,j) */
  856. work[j] = aa;
  857. s = 0.f;
  858. i__1 = *n - 1;
  859. for (l = j + 1; l <= i__1; ++l) {
  860. ++i__;
  861. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  862. /* -> A(l,j) */
  863. s += aa;
  864. work[l] += aa;
  865. }
  866. work[j] += s;
  867. }
  868. value = work[0];
  869. i__1 = *n - 1;
  870. for (i__ = 1; i__ <= i__1; ++i__) {
  871. temp = work[i__];
  872. if (value < temp || sisnan_(&temp)) {
  873. value = temp;
  874. }
  875. }
  876. }
  877. }
  878. } else {
  879. /* ifm=0 */
  880. k = *n / 2;
  881. if (noe == 1) {
  882. /* n is odd */
  883. if (ilu == 0) {
  884. n1 = k;
  885. /* n/2 */
  886. ++k;
  887. /* k is the row size and lda */
  888. i__1 = *n - 1;
  889. for (i__ = n1; i__ <= i__1; ++i__) {
  890. work[i__] = 0.f;
  891. }
  892. i__1 = n1 - 1;
  893. for (j = 0; j <= i__1; ++j) {
  894. s = 0.f;
  895. i__2 = k - 1;
  896. for (i__ = 0; i__ <= i__2; ++i__) {
  897. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  898. /* A(j,n1+i) */
  899. work[i__ + n1] += aa;
  900. s += aa;
  901. }
  902. work[j] = s;
  903. }
  904. /* j=n1=k-1 is special */
  905. s = (r__1 = a[j * lda], abs(r__1));
  906. /* A(k-1,k-1) */
  907. i__1 = k - 1;
  908. for (i__ = 1; i__ <= i__1; ++i__) {
  909. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  910. /* A(k-1,i+n1) */
  911. work[i__ + n1] += aa;
  912. s += aa;
  913. }
  914. work[j] += s;
  915. i__1 = *n - 1;
  916. for (j = k; j <= i__1; ++j) {
  917. s = 0.f;
  918. i__2 = j - k - 1;
  919. for (i__ = 0; i__ <= i__2; ++i__) {
  920. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  921. /* A(i,j-k) */
  922. work[i__] += aa;
  923. s += aa;
  924. }
  925. /* i=j-k */
  926. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  927. /* A(j-k,j-k) */
  928. s += aa;
  929. work[j - k] += s;
  930. ++i__;
  931. s = (r__1 = a[i__ + j * lda], abs(r__1));
  932. /* A(j,j) */
  933. i__2 = *n - 1;
  934. for (l = j + 1; l <= i__2; ++l) {
  935. ++i__;
  936. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  937. /* A(j,l) */
  938. work[l] += aa;
  939. s += aa;
  940. }
  941. work[j] += s;
  942. }
  943. value = work[0];
  944. i__1 = *n - 1;
  945. for (i__ = 1; i__ <= i__1; ++i__) {
  946. temp = work[i__];
  947. if (value < temp || sisnan_(&temp)) {
  948. value = temp;
  949. }
  950. }
  951. } else {
  952. /* ilu=1 */
  953. ++k;
  954. /* k=(n+1)/2 for n odd and ilu=1 */
  955. i__1 = *n - 1;
  956. for (i__ = k; i__ <= i__1; ++i__) {
  957. work[i__] = 0.f;
  958. }
  959. i__1 = k - 2;
  960. for (j = 0; j <= i__1; ++j) {
  961. /* process */
  962. s = 0.f;
  963. i__2 = j - 1;
  964. for (i__ = 0; i__ <= i__2; ++i__) {
  965. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  966. /* A(j,i) */
  967. work[i__] += aa;
  968. s += aa;
  969. }
  970. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  971. /* i=j so process of A(j,j) */
  972. s += aa;
  973. work[j] = s;
  974. /* is initialised here */
  975. ++i__;
  976. /* i=j process A(j+k,j+k) */
  977. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  978. s = aa;
  979. i__2 = *n - 1;
  980. for (l = k + j + 1; l <= i__2; ++l) {
  981. ++i__;
  982. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  983. /* A(l,k+j) */
  984. s += aa;
  985. work[l] += aa;
  986. }
  987. work[k + j] += s;
  988. }
  989. /* j=k-1 is special :process col A(k-1,0:k-1) */
  990. s = 0.f;
  991. i__1 = k - 2;
  992. for (i__ = 0; i__ <= i__1; ++i__) {
  993. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  994. /* A(k,i) */
  995. work[i__] += aa;
  996. s += aa;
  997. }
  998. /* i=k-1 */
  999. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1000. /* A(k-1,k-1) */
  1001. s += aa;
  1002. work[i__] = s;
  1003. /* done with col j=k+1 */
  1004. i__1 = *n - 1;
  1005. for (j = k; j <= i__1; ++j) {
  1006. /* process col j of A = A(j,0:k-1) */
  1007. s = 0.f;
  1008. i__2 = k - 1;
  1009. for (i__ = 0; i__ <= i__2; ++i__) {
  1010. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1011. /* A(j,i) */
  1012. work[i__] += aa;
  1013. s += aa;
  1014. }
  1015. work[j] += s;
  1016. }
  1017. value = work[0];
  1018. i__1 = *n - 1;
  1019. for (i__ = 1; i__ <= i__1; ++i__) {
  1020. temp = work[i__];
  1021. if (value < temp || sisnan_(&temp)) {
  1022. value = temp;
  1023. }
  1024. }
  1025. }
  1026. } else {
  1027. /* n is even */
  1028. if (ilu == 0) {
  1029. i__1 = *n - 1;
  1030. for (i__ = k; i__ <= i__1; ++i__) {
  1031. work[i__] = 0.f;
  1032. }
  1033. i__1 = k - 1;
  1034. for (j = 0; j <= i__1; ++j) {
  1035. s = 0.f;
  1036. i__2 = k - 1;
  1037. for (i__ = 0; i__ <= i__2; ++i__) {
  1038. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1039. /* A(j,i+k) */
  1040. work[i__ + k] += aa;
  1041. s += aa;
  1042. }
  1043. work[j] = s;
  1044. }
  1045. /* j=k */
  1046. aa = (r__1 = a[j * lda], abs(r__1));
  1047. /* A(k,k) */
  1048. s = aa;
  1049. i__1 = k - 1;
  1050. for (i__ = 1; i__ <= i__1; ++i__) {
  1051. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1052. /* A(k,k+i) */
  1053. work[i__ + k] += aa;
  1054. s += aa;
  1055. }
  1056. work[j] += s;
  1057. i__1 = *n - 1;
  1058. for (j = k + 1; j <= i__1; ++j) {
  1059. s = 0.f;
  1060. i__2 = j - 2 - k;
  1061. for (i__ = 0; i__ <= i__2; ++i__) {
  1062. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1063. /* A(i,j-k-1) */
  1064. work[i__] += aa;
  1065. s += aa;
  1066. }
  1067. /* i=j-1-k */
  1068. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1069. /* A(j-k-1,j-k-1) */
  1070. s += aa;
  1071. work[j - k - 1] += s;
  1072. ++i__;
  1073. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1074. /* A(j,j) */
  1075. s = aa;
  1076. i__2 = *n - 1;
  1077. for (l = j + 1; l <= i__2; ++l) {
  1078. ++i__;
  1079. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1080. /* A(j,l) */
  1081. work[l] += aa;
  1082. s += aa;
  1083. }
  1084. work[j] += s;
  1085. }
  1086. /* j=n */
  1087. s = 0.f;
  1088. i__1 = k - 2;
  1089. for (i__ = 0; i__ <= i__1; ++i__) {
  1090. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1091. /* A(i,k-1) */
  1092. work[i__] += aa;
  1093. s += aa;
  1094. }
  1095. /* i=k-1 */
  1096. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1097. /* A(k-1,k-1) */
  1098. s += aa;
  1099. work[i__] += s;
  1100. value = work[0];
  1101. i__1 = *n - 1;
  1102. for (i__ = 1; i__ <= i__1; ++i__) {
  1103. temp = work[i__];
  1104. if (value < temp || sisnan_(&temp)) {
  1105. value = temp;
  1106. }
  1107. }
  1108. } else {
  1109. /* ilu=1 */
  1110. i__1 = *n - 1;
  1111. for (i__ = k; i__ <= i__1; ++i__) {
  1112. work[i__] = 0.f;
  1113. }
  1114. /* j=0 is special :process col A(k:n-1,k) */
  1115. s = abs(a[0]);
  1116. /* A(k,k) */
  1117. i__1 = k - 1;
  1118. for (i__ = 1; i__ <= i__1; ++i__) {
  1119. aa = (r__1 = a[i__], abs(r__1));
  1120. /* A(k+i,k) */
  1121. work[i__ + k] += aa;
  1122. s += aa;
  1123. }
  1124. work[k] += s;
  1125. i__1 = k - 1;
  1126. for (j = 1; j <= i__1; ++j) {
  1127. /* process */
  1128. s = 0.f;
  1129. i__2 = j - 2;
  1130. for (i__ = 0; i__ <= i__2; ++i__) {
  1131. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1132. /* A(j-1,i) */
  1133. work[i__] += aa;
  1134. s += aa;
  1135. }
  1136. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1137. /* i=j-1 so process of A(j-1,j-1) */
  1138. s += aa;
  1139. work[j - 1] = s;
  1140. /* is initialised here */
  1141. ++i__;
  1142. /* i=j process A(j+k,j+k) */
  1143. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1144. s = aa;
  1145. i__2 = *n - 1;
  1146. for (l = k + j + 1; l <= i__2; ++l) {
  1147. ++i__;
  1148. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1149. /* A(l,k+j) */
  1150. s += aa;
  1151. work[l] += aa;
  1152. }
  1153. work[k + j] += s;
  1154. }
  1155. /* j=k is special :process col A(k,0:k-1) */
  1156. s = 0.f;
  1157. i__1 = k - 2;
  1158. for (i__ = 0; i__ <= i__1; ++i__) {
  1159. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1160. /* A(k,i) */
  1161. work[i__] += aa;
  1162. s += aa;
  1163. }
  1164. /* i=k-1 */
  1165. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1166. /* A(k-1,k-1) */
  1167. s += aa;
  1168. work[i__] = s;
  1169. /* done with col j=k+1 */
  1170. i__1 = *n;
  1171. for (j = k + 1; j <= i__1; ++j) {
  1172. /* process col j-1 of A = A(j-1,0:k-1) */
  1173. s = 0.f;
  1174. i__2 = k - 1;
  1175. for (i__ = 0; i__ <= i__2; ++i__) {
  1176. aa = (r__1 = a[i__ + j * lda], abs(r__1));
  1177. /* A(j-1,i) */
  1178. work[i__] += aa;
  1179. s += aa;
  1180. }
  1181. work[j - 1] += s;
  1182. }
  1183. value = work[0];
  1184. i__1 = *n - 1;
  1185. for (i__ = 1; i__ <= i__1; ++i__) {
  1186. temp = work[i__];
  1187. if (value < temp || sisnan_(&temp)) {
  1188. value = temp;
  1189. }
  1190. }
  1191. }
  1192. }
  1193. }
  1194. } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
  1195. /* Find normF(A). */
  1196. k = (*n + 1) / 2;
  1197. scale = 0.f;
  1198. s = 1.f;
  1199. if (noe == 1) {
  1200. /* n is odd */
  1201. if (ifm == 1) {
  1202. /* A is normal */
  1203. if (ilu == 0) {
  1204. /* A is upper */
  1205. i__1 = k - 3;
  1206. for (j = 0; j <= i__1; ++j) {
  1207. i__2 = k - j - 2;
  1208. slassq_(&i__2, &a[k + j + 1 + j * lda], &c__1, &scale,
  1209. &s);
  1210. /* L at A(k,0) */
  1211. }
  1212. i__1 = k - 1;
  1213. for (j = 0; j <= i__1; ++j) {
  1214. i__2 = k + j - 1;
  1215. slassq_(&i__2, &a[j * lda], &c__1, &scale, &s);
  1216. /* trap U at A(0,0) */
  1217. }
  1218. s += s;
  1219. /* double s for the off diagonal elements */
  1220. i__1 = k - 1;
  1221. i__2 = lda + 1;
  1222. slassq_(&i__1, &a[k], &i__2, &scale, &s);
  1223. /* tri L at A(k,0) */
  1224. i__1 = lda + 1;
  1225. slassq_(&k, &a[k - 1], &i__1, &scale, &s);
  1226. /* tri U at A(k-1,0) */
  1227. } else {
  1228. /* ilu=1 & A is lower */
  1229. i__1 = k - 1;
  1230. for (j = 0; j <= i__1; ++j) {
  1231. i__2 = *n - j - 1;
  1232. slassq_(&i__2, &a[j + 1 + j * lda], &c__1, &scale, &s)
  1233. ;
  1234. /* trap L at A(0,0) */
  1235. }
  1236. i__1 = k - 2;
  1237. for (j = 0; j <= i__1; ++j) {
  1238. slassq_(&j, &a[(j + 1) * lda], &c__1, &scale, &s);
  1239. /* U at A(0,1) */
  1240. }
  1241. s += s;
  1242. /* double s for the off diagonal elements */
  1243. i__1 = lda + 1;
  1244. slassq_(&k, a, &i__1, &scale, &s);
  1245. /* tri L at A(0,0) */
  1246. i__1 = k - 1;
  1247. i__2 = lda + 1;
  1248. slassq_(&i__1, &a[lda], &i__2, &scale, &s);
  1249. /* tri U at A(0,1) */
  1250. }
  1251. } else {
  1252. /* A is xpose */
  1253. if (ilu == 0) {
  1254. /* A**T is upper */
  1255. i__1 = k - 2;
  1256. for (j = 1; j <= i__1; ++j) {
  1257. slassq_(&j, &a[(k + j) * lda], &c__1, &scale, &s);
  1258. /* U at A(0,k) */
  1259. }
  1260. i__1 = k - 2;
  1261. for (j = 0; j <= i__1; ++j) {
  1262. slassq_(&k, &a[j * lda], &c__1, &scale, &s);
  1263. /* k by k-1 rect. at A(0,0) */
  1264. }
  1265. i__1 = k - 2;
  1266. for (j = 0; j <= i__1; ++j) {
  1267. i__2 = k - j - 1;
  1268. slassq_(&i__2, &a[j + 1 + (j + k - 1) * lda], &c__1, &
  1269. scale, &s);
  1270. /* L at A(0,k-1) */
  1271. }
  1272. s += s;
  1273. /* double s for the off diagonal elements */
  1274. i__1 = k - 1;
  1275. i__2 = lda + 1;
  1276. slassq_(&i__1, &a[k * lda], &i__2, &scale, &s);
  1277. /* tri U at A(0,k) */
  1278. i__1 = lda + 1;
  1279. slassq_(&k, &a[(k - 1) * lda], &i__1, &scale, &s);
  1280. /* tri L at A(0,k-1) */
  1281. } else {
  1282. /* A**T is lower */
  1283. i__1 = k - 1;
  1284. for (j = 1; j <= i__1; ++j) {
  1285. slassq_(&j, &a[j * lda], &c__1, &scale, &s);
  1286. /* U at A(0,0) */
  1287. }
  1288. i__1 = *n - 1;
  1289. for (j = k; j <= i__1; ++j) {
  1290. slassq_(&k, &a[j * lda], &c__1, &scale, &s);
  1291. /* k by k-1 rect. at A(0,k) */
  1292. }
  1293. i__1 = k - 3;
  1294. for (j = 0; j <= i__1; ++j) {
  1295. i__2 = k - j - 2;
  1296. slassq_(&i__2, &a[j + 2 + j * lda], &c__1, &scale, &s)
  1297. ;
  1298. /* L at A(1,0) */
  1299. }
  1300. s += s;
  1301. /* double s for the off diagonal elements */
  1302. i__1 = lda + 1;
  1303. slassq_(&k, a, &i__1, &scale, &s);
  1304. /* tri U at A(0,0) */
  1305. i__1 = k - 1;
  1306. i__2 = lda + 1;
  1307. slassq_(&i__1, &a[1], &i__2, &scale, &s);
  1308. /* tri L at A(1,0) */
  1309. }
  1310. }
  1311. } else {
  1312. /* n is even */
  1313. if (ifm == 1) {
  1314. /* A is normal */
  1315. if (ilu == 0) {
  1316. /* A is upper */
  1317. i__1 = k - 2;
  1318. for (j = 0; j <= i__1; ++j) {
  1319. i__2 = k - j - 1;
  1320. slassq_(&i__2, &a[k + j + 2 + j * lda], &c__1, &scale,
  1321. &s);
  1322. /* L at A(k+1,0) */
  1323. }
  1324. i__1 = k - 1;
  1325. for (j = 0; j <= i__1; ++j) {
  1326. i__2 = k + j;
  1327. slassq_(&i__2, &a[j * lda], &c__1, &scale, &s);
  1328. /* trap U at A(0,0) */
  1329. }
  1330. s += s;
  1331. /* double s for the off diagonal elements */
  1332. i__1 = lda + 1;
  1333. slassq_(&k, &a[k + 1], &i__1, &scale, &s);
  1334. /* tri L at A(k+1,0) */
  1335. i__1 = lda + 1;
  1336. slassq_(&k, &a[k], &i__1, &scale, &s);
  1337. /* tri U at A(k,0) */
  1338. } else {
  1339. /* ilu=1 & A is lower */
  1340. i__1 = k - 1;
  1341. for (j = 0; j <= i__1; ++j) {
  1342. i__2 = *n - j - 1;
  1343. slassq_(&i__2, &a[j + 2 + j * lda], &c__1, &scale, &s)
  1344. ;
  1345. /* trap L at A(1,0) */
  1346. }
  1347. i__1 = k - 1;
  1348. for (j = 1; j <= i__1; ++j) {
  1349. slassq_(&j, &a[j * lda], &c__1, &scale, &s);
  1350. /* U at A(0,0) */
  1351. }
  1352. s += s;
  1353. /* double s for the off diagonal elements */
  1354. i__1 = lda + 1;
  1355. slassq_(&k, &a[1], &i__1, &scale, &s);
  1356. /* tri L at A(1,0) */
  1357. i__1 = lda + 1;
  1358. slassq_(&k, a, &i__1, &scale, &s);
  1359. /* tri U at A(0,0) */
  1360. }
  1361. } else {
  1362. /* A is xpose */
  1363. if (ilu == 0) {
  1364. /* A**T is upper */
  1365. i__1 = k - 1;
  1366. for (j = 1; j <= i__1; ++j) {
  1367. slassq_(&j, &a[(k + 1 + j) * lda], &c__1, &scale, &s);
  1368. /* U at A(0,k+1) */
  1369. }
  1370. i__1 = k - 1;
  1371. for (j = 0; j <= i__1; ++j) {
  1372. slassq_(&k, &a[j * lda], &c__1, &scale, &s);
  1373. /* k by k rect. at A(0,0) */
  1374. }
  1375. i__1 = k - 2;
  1376. for (j = 0; j <= i__1; ++j) {
  1377. i__2 = k - j - 1;
  1378. slassq_(&i__2, &a[j + 1 + (j + k) * lda], &c__1, &
  1379. scale, &s);
  1380. /* L at A(0,k) */
  1381. }
  1382. s += s;
  1383. /* double s for the off diagonal elements */
  1384. i__1 = lda + 1;
  1385. slassq_(&k, &a[(k + 1) * lda], &i__1, &scale, &s);
  1386. /* tri U at A(0,k+1) */
  1387. i__1 = lda + 1;
  1388. slassq_(&k, &a[k * lda], &i__1, &scale, &s);
  1389. /* tri L at A(0,k) */
  1390. } else {
  1391. /* A**T is lower */
  1392. i__1 = k - 1;
  1393. for (j = 1; j <= i__1; ++j) {
  1394. slassq_(&j, &a[(j + 1) * lda], &c__1, &scale, &s);
  1395. /* U at A(0,1) */
  1396. }
  1397. i__1 = *n;
  1398. for (j = k + 1; j <= i__1; ++j) {
  1399. slassq_(&k, &a[j * lda], &c__1, &scale, &s);
  1400. /* k by k rect. at A(0,k+1) */
  1401. }
  1402. i__1 = k - 2;
  1403. for (j = 0; j <= i__1; ++j) {
  1404. i__2 = k - j - 1;
  1405. slassq_(&i__2, &a[j + 1 + j * lda], &c__1, &scale, &s)
  1406. ;
  1407. /* L at A(0,0) */
  1408. }
  1409. s += s;
  1410. /* double s for the off diagonal elements */
  1411. i__1 = lda + 1;
  1412. slassq_(&k, &a[lda], &i__1, &scale, &s);
  1413. /* tri L at A(0,1) */
  1414. i__1 = lda + 1;
  1415. slassq_(&k, a, &i__1, &scale, &s);
  1416. /* tri U at A(0,0) */
  1417. }
  1418. }
  1419. }
  1420. value = scale * sqrt(s);
  1421. }
  1422. ret_val = value;
  1423. return ret_val;
  1424. /* End of SLANSF */
  1425. } /* slansf_ */