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.

zlanhf.c 65 kB

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