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.

dlansf.c 44 kB

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