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.

dlamch.c 41 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503
  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. static doublereal c_b32 = 0.;
  488. /* > \brief \b DLAMCHF77 deprecated */
  489. /* =========== DOCUMENTATION =========== */
  490. /* Online html documentation available at */
  491. /* http://www.netlib.org/lapack/explore-html/ */
  492. /* Definition: */
  493. /* =========== */
  494. /* DOUBLE PRECISION FUNCTION DLAMCH( CMACH ) */
  495. /* CHARACTER CMACH */
  496. /* > \par Purpose: */
  497. /* ============= */
  498. /* > */
  499. /* > \verbatim */
  500. /* > */
  501. /* > DLAMCHF77 determines double precision machine parameters. */
  502. /* > \endverbatim */
  503. /* Arguments: */
  504. /* ========== */
  505. /* > \param[in] CMACH */
  506. /* > \verbatim */
  507. /* > Specifies the value to be returned by DLAMCH: */
  508. /* > = 'E' or 'e', DLAMCH := eps */
  509. /* > = 'S' or 's , DLAMCH := sfmin */
  510. /* > = 'B' or 'b', DLAMCH := base */
  511. /* > = 'P' or 'p', DLAMCH := eps*base */
  512. /* > = 'N' or 'n', DLAMCH := t */
  513. /* > = 'R' or 'r', DLAMCH := rnd */
  514. /* > = 'M' or 'm', DLAMCH := emin */
  515. /* > = 'U' or 'u', DLAMCH := rmin */
  516. /* > = 'L' or 'l', DLAMCH := emax */
  517. /* > = 'O' or 'o', DLAMCH := rmax */
  518. /* > where */
  519. /* > eps = relative machine precision */
  520. /* > sfmin = safe minimum, such that 1/sfmin does not overflow */
  521. /* > base = base of the machine */
  522. /* > prec = eps*base */
  523. /* > t = number of (base) digits in the mantissa */
  524. /* > rnd = 1.0 when rounding occurs in addition, 0.0 otherwise */
  525. /* > emin = minimum exponent before (gradual) underflow */
  526. /* > rmin = underflow threshold - base**(emin-1) */
  527. /* > emax = largest exponent before overflow */
  528. /* > rmax = overflow threshold - (base**emax)*(1-eps) */
  529. /* > \endverbatim */
  530. /* Authors: */
  531. /* ======== */
  532. /* > \author Univ. of Tennessee */
  533. /* > \author Univ. of California Berkeley */
  534. /* > \author Univ. of Colorado Denver */
  535. /* > \author NAG Ltd. */
  536. /* > \date April 2012 */
  537. /* > \ingroup auxOTHERauxiliary */
  538. /* ===================================================================== */
  539. doublereal dlamch_(char *cmach)
  540. {
  541. /* Initialized data */
  542. static logical first = TRUE_;
  543. /* System generated locals */
  544. integer i__1;
  545. doublereal ret_val;
  546. /* Local variables */
  547. static doublereal base;
  548. integer beta;
  549. static doublereal emin, prec, emax;
  550. integer imin, imax;
  551. logical lrnd;
  552. static doublereal rmin, rmax, t;
  553. doublereal rmach;
  554. extern logical lsame_(char *, char *);
  555. doublereal small;
  556. static doublereal sfmin;
  557. extern /* Subroutine */ int dlamc2_(integer *, integer *, logical *,
  558. doublereal *, integer *, doublereal *, integer *, doublereal *);
  559. integer it;
  560. static doublereal rnd, eps;
  561. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  562. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  563. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  564. /* April 2012 */
  565. if (first) {
  566. dlamc2_(&beta, &it, &lrnd, &eps, &imin, &rmin, &imax, &rmax);
  567. base = (doublereal) beta;
  568. t = (doublereal) it;
  569. if (lrnd) {
  570. rnd = 1.;
  571. i__1 = 1 - it;
  572. eps = pow_di(&base, &i__1) / 2;
  573. } else {
  574. rnd = 0.;
  575. i__1 = 1 - it;
  576. eps = pow_di(&base, &i__1);
  577. }
  578. prec = eps * base;
  579. emin = (doublereal) imin;
  580. emax = (doublereal) imax;
  581. sfmin = rmin;
  582. small = 1. / rmax;
  583. if (small >= sfmin) {
  584. /* Use SMALL plus a bit, to avoid the possibility of rounding */
  585. /* causing overflow when computing 1/sfmin. */
  586. sfmin = small * (eps + 1.);
  587. }
  588. }
  589. if (lsame_(cmach, "E")) {
  590. rmach = eps;
  591. } else if (lsame_(cmach, "S")) {
  592. rmach = sfmin;
  593. } else if (lsame_(cmach, "B")) {
  594. rmach = base;
  595. } else if (lsame_(cmach, "P")) {
  596. rmach = prec;
  597. } else if (lsame_(cmach, "N")) {
  598. rmach = t;
  599. } else if (lsame_(cmach, "R")) {
  600. rmach = rnd;
  601. } else if (lsame_(cmach, "M")) {
  602. rmach = emin;
  603. } else if (lsame_(cmach, "U")) {
  604. rmach = rmin;
  605. } else if (lsame_(cmach, "L")) {
  606. rmach = emax;
  607. } else if (lsame_(cmach, "O")) {
  608. rmach = rmax;
  609. }
  610. ret_val = rmach;
  611. first = FALSE_;
  612. return ret_val;
  613. /* End of DLAMCH */
  614. } /* dlamch_ */
  615. /* *********************************************************************** */
  616. /* > \brief \b DLAMC1 */
  617. /* > \details */
  618. /* > \b Purpose: */
  619. /* > \verbatim */
  620. /* > DLAMC1 determines the machine parameters given by BETA, T, RND, and */
  621. /* > IEEE1. */
  622. /* > \endverbatim */
  623. /* > */
  624. /* > \param[out] BETA */
  625. /* > \verbatim */
  626. /* > The base of the machine. */
  627. /* > \endverbatim */
  628. /* > */
  629. /* > \param[out] T */
  630. /* > \verbatim */
  631. /* > The number of ( BETA ) digits in the mantissa. */
  632. /* > \endverbatim */
  633. /* > */
  634. /* > \param[out] RND */
  635. /* > \verbatim */
  636. /* > Specifies whether proper rounding ( RND = .TRUE. ) or */
  637. /* > chopping ( RND = .FALSE. ) occurs in addition. This may not */
  638. /* > be a reliable guide to the way in which the machine performs */
  639. /* > its arithmetic. */
  640. /* > \endverbatim */
  641. /* > */
  642. /* > \param[out] IEEE1 */
  643. /* > \verbatim */
  644. /* > Specifies whether rounding appears to be done in the IEEE */
  645. /* > 'round to nearest' style. */
  646. /* > \endverbatim */
  647. /* > \author LAPACK is a software package provided by Univ. of Tennessee, Univ. of California Berkeley, Univ.
  648. of Colorado Denver and NAG Ltd.. */
  649. /* > \date April 2012 */
  650. /* > \ingroup auxOTHERauxiliary */
  651. /* > */
  652. /* > \details \b Further \b Details */
  653. /* > \verbatim */
  654. /* > */
  655. /* > The routine is based on the routine ENVRON by Malcolm and */
  656. /* > incorporates suggestions by Gentleman and Marovich. See */
  657. /* > */
  658. /* > Malcolm M. A. (1972) Algorithms to reveal properties of */
  659. /* > floating-point arithmetic. Comms. of the ACM, 15, 949-951. */
  660. /* > */
  661. /* > Gentleman W. M. and Marovich S. B. (1974) More on algorithms */
  662. /* > that reveal properties of floating point arithmetic units. */
  663. /* > Comms. of the ACM, 17, 276-277. */
  664. /* > \endverbatim */
  665. /* > */
  666. /* Subroutine */ int dlamc1_(integer *beta, integer *t, logical *rnd, logical
  667. *ieee1)
  668. {
  669. /* Initialized data */
  670. static logical first = TRUE_;
  671. /* System generated locals */
  672. doublereal d__1, d__2;
  673. /* Local variables */
  674. static logical lrnd;
  675. doublereal a, b, c__, f;
  676. static integer lbeta;
  677. doublereal savec;
  678. extern doublereal dlamc3_(doublereal *, doublereal *);
  679. static logical lieee1;
  680. doublereal t1, t2;
  681. static integer lt;
  682. doublereal one, qtr;
  683. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  684. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  685. /* November 2010 */
  686. /* ===================================================================== */
  687. if (first) {
  688. one = 1.;
  689. /* LBETA, LIEEE1, LT and LRND are the local values of BETA, */
  690. /* IEEE1, T and RND. */
  691. /* Throughout this routine we use the function DLAMC3 to ensure */
  692. /* that relevant values are stored and not held in registers, or */
  693. /* are not affected by optimizers. */
  694. /* Compute a = 2.0**m with the smallest positive integer m such */
  695. /* that */
  696. /* fl( a + 1.0 ) = a. */
  697. a = 1.;
  698. c__ = 1.;
  699. /* + WHILE( C.EQ.ONE )LOOP */
  700. L10:
  701. if (c__ == one) {
  702. a *= 2;
  703. c__ = dlamc3_(&a, &one);
  704. d__1 = -a;
  705. c__ = dlamc3_(&c__, &d__1);
  706. goto L10;
  707. }
  708. /* + END WHILE */
  709. /* Now compute b = 2.0**m with the smallest positive integer m */
  710. /* such that */
  711. /* fl( a + b ) .gt. a. */
  712. b = 1.;
  713. c__ = dlamc3_(&a, &b);
  714. /* + WHILE( C.EQ.A )LOOP */
  715. L20:
  716. if (c__ == a) {
  717. b *= 2;
  718. c__ = dlamc3_(&a, &b);
  719. goto L20;
  720. }
  721. /* + END WHILE */
  722. /* Now compute the base. a and c are neighbouring floating point */
  723. /* numbers in the interval ( beta**t, beta**( t + 1 ) ) and so */
  724. /* their difference is beta. Adding 0.25 to c is to ensure that it */
  725. /* is truncated to beta and not ( beta - 1 ). */
  726. qtr = one / 4;
  727. savec = c__;
  728. d__1 = -a;
  729. c__ = dlamc3_(&c__, &d__1);
  730. lbeta = (integer) (c__ + qtr);
  731. /* Now determine whether rounding or chopping occurs, by adding a */
  732. /* bit less than beta/2 and a bit more than beta/2 to a. */
  733. b = (doublereal) lbeta;
  734. d__1 = b / 2;
  735. d__2 = -b / 100;
  736. f = dlamc3_(&d__1, &d__2);
  737. c__ = dlamc3_(&f, &a);
  738. if (c__ == a) {
  739. lrnd = TRUE_;
  740. } else {
  741. lrnd = FALSE_;
  742. }
  743. d__1 = b / 2;
  744. d__2 = b / 100;
  745. f = dlamc3_(&d__1, &d__2);
  746. c__ = dlamc3_(&f, &a);
  747. if (lrnd && c__ == a) {
  748. lrnd = FALSE_;
  749. }
  750. /* Try and decide whether rounding is done in the IEEE 'round to */
  751. /* nearest' style. B/2 is half a unit in the last place of the two */
  752. /* numbers A and SAVEC. Furthermore, A is even, i.e. has last bit */
  753. /* zero, and SAVEC is odd. Thus adding B/2 to A should not change */
  754. /* A, but adding B/2 to SAVEC should change SAVEC. */
  755. d__1 = b / 2;
  756. t1 = dlamc3_(&d__1, &a);
  757. d__1 = b / 2;
  758. t2 = dlamc3_(&d__1, &savec);
  759. lieee1 = t1 == a && t2 > savec && lrnd;
  760. /* Now find the mantissa, t. It should be the integer part of */
  761. /* log to the base beta of a, however it is safer to determine t */
  762. /* by powering. So we find t as the smallest positive integer for */
  763. /* which */
  764. /* fl( beta**t + 1.0 ) = 1.0. */
  765. lt = 0;
  766. a = 1.;
  767. c__ = 1.;
  768. /* + WHILE( C.EQ.ONE )LOOP */
  769. L30:
  770. if (c__ == one) {
  771. ++lt;
  772. a *= lbeta;
  773. c__ = dlamc3_(&a, &one);
  774. d__1 = -a;
  775. c__ = dlamc3_(&c__, &d__1);
  776. goto L30;
  777. }
  778. /* + END WHILE */
  779. }
  780. *beta = lbeta;
  781. *t = lt;
  782. *rnd = lrnd;
  783. *ieee1 = lieee1;
  784. first = FALSE_;
  785. return 0;
  786. /* End of DLAMC1 */
  787. } /* dlamc1_ */
  788. /* *********************************************************************** */
  789. /* > \brief \b DLAMC2 */
  790. /* > \details */
  791. /* > \b Purpose: */
  792. /* > \verbatim */
  793. /* > DLAMC2 determines the machine parameters specified in its argument */
  794. /* > list. */
  795. /* > \endverbatim */
  796. /* > \author LAPACK is a software package provided by Univ. of Tennessee, Univ. of California Berkeley, Univ.
  797. of Colorado Denver and NAG Ltd.. */
  798. /* > \date April 2012 */
  799. /* > \ingroup auxOTHERauxiliary */
  800. /* > */
  801. /* > \param[out] BETA */
  802. /* > \verbatim */
  803. /* > The base of the machine. */
  804. /* > \endverbatim */
  805. /* > */
  806. /* > \param[out] T */
  807. /* > \verbatim */
  808. /* > The number of ( BETA ) digits in the mantissa. */
  809. /* > \endverbatim */
  810. /* > */
  811. /* > \param[out] RND */
  812. /* > \verbatim */
  813. /* > Specifies whether proper rounding ( RND = .TRUE. ) or */
  814. /* > chopping ( RND = .FALSE. ) occurs in addition. This may not */
  815. /* > be a reliable guide to the way in which the machine performs */
  816. /* > its arithmetic. */
  817. /* > \endverbatim */
  818. /* > */
  819. /* > \param[out] EPS */
  820. /* > \verbatim */
  821. /* > The smallest positive number such that */
  822. /* > fl( 1.0 - EPS ) .LT. 1.0, */
  823. /* > where fl denotes the computed value. */
  824. /* > \endverbatim */
  825. /* > */
  826. /* > \param[out] EMIN */
  827. /* > \verbatim */
  828. /* > The minimum exponent before (gradual) underflow occurs. */
  829. /* > \endverbatim */
  830. /* > */
  831. /* > \param[out] RMIN */
  832. /* > \verbatim */
  833. /* > The smallest normalized number for the machine, given by */
  834. /* > BASE**( EMIN - 1 ), where BASE is the floating point value */
  835. /* > of BETA. */
  836. /* > \endverbatim */
  837. /* > */
  838. /* > \param[out] EMAX */
  839. /* > \verbatim */
  840. /* > The maximum exponent before overflow occurs. */
  841. /* > \endverbatim */
  842. /* > */
  843. /* > \param[out] RMAX */
  844. /* > \verbatim */
  845. /* > The largest positive number for the machine, given by */
  846. /* > BASE**EMAX * ( 1 - EPS ), where BASE is the floating point */
  847. /* > value of BETA. */
  848. /* > \endverbatim */
  849. /* > */
  850. /* > \details \b Further \b Details */
  851. /* > \verbatim */
  852. /* > */
  853. /* > The computation of EPS is based on a routine PARANOIA by */
  854. /* > W. Kahan of the University of California at Berkeley. */
  855. /* > \endverbatim */
  856. /* Subroutine */ int dlamc2_(integer *beta, integer *t, logical *rnd,
  857. doublereal *eps, integer *emin, doublereal *rmin, integer *emax,
  858. doublereal *rmax)
  859. {
  860. /* Initialized data */
  861. static logical first = TRUE_;
  862. static logical iwarn = FALSE_;
  863. /* Format strings */
  864. static char fmt_9999[] = "(//\002 WARNING. The value EMIN may be incorre"
  865. "ct:-\002,\002 EMIN = \002,i8,/\002 If, after inspection, the va"
  866. "lue EMIN looks\002,\002 acceptable please comment out \002,/\002"
  867. " the IF block as marked within the code of routine\002,\002 DLAM"
  868. "C2,\002,/\002 otherwise supply EMIN explicitly.\002,/)";
  869. /* System generated locals */
  870. integer i__1;
  871. doublereal d__1, d__2, d__3, d__4, d__5;
  872. /* Local variables */
  873. logical ieee;
  874. doublereal half;
  875. logical lrnd;
  876. static doublereal leps;
  877. doublereal zero, a, b, c__;
  878. integer i__;
  879. static integer lbeta;
  880. doublereal rbase;
  881. static integer lemin, lemax;
  882. integer gnmin;
  883. doublereal small;
  884. integer gpmin;
  885. doublereal third;
  886. static doublereal lrmin, lrmax;
  887. doublereal sixth;
  888. extern /* Subroutine */ int dlamc1_(integer *, integer *, logical *,
  889. logical *);
  890. extern doublereal dlamc3_(doublereal *, doublereal *);
  891. logical lieee1;
  892. extern /* Subroutine */ int dlamc4_(integer *, doublereal *, integer *),
  893. dlamc5_(integer *, integer *, integer *, logical *, integer *,
  894. doublereal *);
  895. static integer lt;
  896. integer ngnmin, ngpmin;
  897. doublereal one, two;
  898. /* Fortran I/O blocks */
  899. static cilist io___58 = { 0, 6, 0, fmt_9999, 0 };
  900. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  901. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  902. /* November 2010 */
  903. /* ===================================================================== */
  904. if (first) {
  905. zero = 0.;
  906. one = 1.;
  907. two = 2.;
  908. /* LBETA, LT, LRND, LEPS, LEMIN and LRMIN are the local values of */
  909. /* BETA, T, RND, EPS, EMIN and RMIN. */
  910. /* Throughout this routine we use the function DLAMC3 to ensure */
  911. /* that relevant values are stored and not held in registers, or */
  912. /* are not affected by optimizers. */
  913. /* DLAMC1 returns the parameters LBETA, LT, LRND and LIEEE1. */
  914. dlamc1_(&lbeta, &lt, &lrnd, &lieee1);
  915. /* Start to find EPS. */
  916. b = (doublereal) lbeta;
  917. i__1 = -lt;
  918. a = pow_di(&b, &i__1);
  919. leps = a;
  920. /* Try some tricks to see whether or not this is the correct EPS. */
  921. b = two / 3;
  922. half = one / 2;
  923. d__1 = -half;
  924. sixth = dlamc3_(&b, &d__1);
  925. third = dlamc3_(&sixth, &sixth);
  926. d__1 = -half;
  927. b = dlamc3_(&third, &d__1);
  928. b = dlamc3_(&b, &sixth);
  929. b = abs(b);
  930. if (b < leps) {
  931. b = leps;
  932. }
  933. leps = 1.;
  934. /* + WHILE( ( LEPS.GT.B ).AND.( B.GT.ZERO ) )LOOP */
  935. L10:
  936. if (leps > b && b > zero) {
  937. leps = b;
  938. d__1 = half * leps;
  939. /* Computing 5th power */
  940. d__3 = two, d__4 = d__3, d__3 *= d__3;
  941. /* Computing 2nd power */
  942. d__5 = leps;
  943. d__2 = d__4 * (d__3 * d__3) * (d__5 * d__5);
  944. c__ = dlamc3_(&d__1, &d__2);
  945. d__1 = -c__;
  946. c__ = dlamc3_(&half, &d__1);
  947. b = dlamc3_(&half, &c__);
  948. d__1 = -b;
  949. c__ = dlamc3_(&half, &d__1);
  950. b = dlamc3_(&half, &c__);
  951. goto L10;
  952. }
  953. /* + END WHILE */
  954. if (a < leps) {
  955. leps = a;
  956. }
  957. /* Computation of EPS complete. */
  958. /* Now find EMIN. Let A = + or - 1, and + or - (1 + BASE**(-3)). */
  959. /* Keep dividing A by BETA until (gradual) underflow occurs. This */
  960. /* is detected when we cannot recover the previous A. */
  961. rbase = one / lbeta;
  962. small = one;
  963. for (i__ = 1; i__ <= 3; ++i__) {
  964. d__1 = small * rbase;
  965. small = dlamc3_(&d__1, &zero);
  966. /* L20: */
  967. }
  968. a = dlamc3_(&one, &small);
  969. dlamc4_(&ngpmin, &one, &lbeta);
  970. d__1 = -one;
  971. dlamc4_(&ngnmin, &d__1, &lbeta);
  972. dlamc4_(&gpmin, &a, &lbeta);
  973. d__1 = -a;
  974. dlamc4_(&gnmin, &d__1, &lbeta);
  975. ieee = FALSE_;
  976. if (ngpmin == ngnmin && gpmin == gnmin) {
  977. if (ngpmin == gpmin) {
  978. lemin = ngpmin;
  979. /* ( Non twos-complement machines, no gradual underflow; */
  980. /* e.g., VAX ) */
  981. } else if (gpmin - ngpmin == 3) {
  982. lemin = ngpmin - 1 + lt;
  983. ieee = TRUE_;
  984. /* ( Non twos-complement machines, with gradual underflow; */
  985. /* e.g., IEEE standard followers ) */
  986. } else {
  987. lemin = f2cmin(ngpmin,gpmin);
  988. /* ( A guess; no known machine ) */
  989. iwarn = TRUE_;
  990. }
  991. } else if (ngpmin == gpmin && ngnmin == gnmin) {
  992. if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1) {
  993. lemin = f2cmax(ngpmin,ngnmin);
  994. /* ( Twos-complement machines, no gradual underflow; */
  995. /* e.g., CYBER 205 ) */
  996. } else {
  997. lemin = f2cmin(ngpmin,ngnmin);
  998. /* ( A guess; no known machine ) */
  999. iwarn = TRUE_;
  1000. }
  1001. } else if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1 && gpmin == gnmin)
  1002. {
  1003. if (gpmin - f2cmin(ngpmin,ngnmin) == 3) {
  1004. lemin = f2cmax(ngpmin,ngnmin) - 1 + lt;
  1005. /* ( Twos-complement machines with gradual underflow; */
  1006. /* no known machine ) */
  1007. } else {
  1008. lemin = f2cmin(ngpmin,ngnmin);
  1009. /* ( A guess; no known machine ) */
  1010. iwarn = TRUE_;
  1011. }
  1012. } else {
  1013. /* Computing MIN */
  1014. i__1 = f2cmin(ngpmin,ngnmin), i__1 = f2cmin(i__1,gpmin);
  1015. lemin = f2cmin(i__1,gnmin);
  1016. /* ( A guess; no known machine ) */
  1017. iwarn = TRUE_;
  1018. }
  1019. first = FALSE_;
  1020. /* ** */
  1021. /* Comment out this if block if EMIN is ok */
  1022. /*
  1023. if (iwarn) {
  1024. first = TRUE_;
  1025. s_wsfe(&io___58);
  1026. do_fio(&c__1, (char *)&lemin, (ftnlen)sizeof(integer));
  1027. e_wsfe();
  1028. }
  1029. */
  1030. /* ** */
  1031. /* Assume IEEE arithmetic if we found denormalised numbers above, */
  1032. /* or if arithmetic seems to round in the IEEE style, determined */
  1033. /* in routine DLAMC1. A true IEEE machine should have both things */
  1034. /* true; however, faulty machines may have one or the other. */
  1035. ieee = ieee || lieee1;
  1036. /* Compute RMIN by successive division by BETA. We could compute */
  1037. /* RMIN as BASE**( EMIN - 1 ), but some machines underflow during */
  1038. /* this computation. */
  1039. lrmin = 1.;
  1040. i__1 = 1 - lemin;
  1041. for (i__ = 1; i__ <= i__1; ++i__) {
  1042. d__1 = lrmin * rbase;
  1043. lrmin = dlamc3_(&d__1, &zero);
  1044. /* L30: */
  1045. }
  1046. /* Finally, call DLAMC5 to compute EMAX and RMAX. */
  1047. dlamc5_(&lbeta, &lt, &lemin, &ieee, &lemax, &lrmax);
  1048. }
  1049. *beta = lbeta;
  1050. *t = lt;
  1051. *rnd = lrnd;
  1052. *eps = leps;
  1053. *emin = lemin;
  1054. *rmin = lrmin;
  1055. *emax = lemax;
  1056. *rmax = lrmax;
  1057. return 0;
  1058. /* End of DLAMC2 */
  1059. } /* dlamc2_ */
  1060. /* *********************************************************************** */
  1061. /* > \brief \b DLAMC3 */
  1062. /* > \details */
  1063. /* > \b Purpose: */
  1064. /* > \verbatim */
  1065. /* > DLAMC3 is intended to force A and B to be stored prior to doing */
  1066. /* > the addition of A and B , for use in situations where optimizers */
  1067. /* > might hold one of these in a register. */
  1068. /* > \endverbatim */
  1069. /* > */
  1070. /* > \param[in] A */
  1071. /* > */
  1072. /* > \param[in] B */
  1073. /* > \verbatim */
  1074. /* > The values A and B. */
  1075. /* > \endverbatim */
  1076. doublereal dlamc3_(doublereal *a, doublereal *b)
  1077. {
  1078. /* System generated locals */
  1079. doublereal ret_val;
  1080. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  1081. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  1082. /* November 2010 */
  1083. /* ===================================================================== */
  1084. ret_val = *a + *b;
  1085. return ret_val;
  1086. /* End of DLAMC3 */
  1087. } /* dlamc3_ */
  1088. /* *********************************************************************** */
  1089. /* > \brief \b DLAMC4 */
  1090. /* > \details */
  1091. /* > \b Purpose: */
  1092. /* > \verbatim */
  1093. /* > DLAMC4 is a service routine for DLAMC2. */
  1094. /* > \endverbatim */
  1095. /* > */
  1096. /* > \param[out] EMIN */
  1097. /* > \verbatim */
  1098. /* > The minimum exponent before (gradual) underflow, computed by */
  1099. /* > setting A = START and dividing by BASE until the previous A */
  1100. /* > can not be recovered. */
  1101. /* > \endverbatim */
  1102. /* > */
  1103. /* > \param[in] START */
  1104. /* > \verbatim */
  1105. /* > The starting point for determining EMIN. */
  1106. /* > \endverbatim */
  1107. /* > */
  1108. /* > \param[in] BASE */
  1109. /* > \verbatim */
  1110. /* > The base of the machine. */
  1111. /* > \endverbatim */
  1112. /* > */
  1113. /* Subroutine */ int dlamc4_(integer *emin, doublereal *start, integer *base)
  1114. {
  1115. /* System generated locals */
  1116. integer i__1;
  1117. doublereal d__1;
  1118. /* Local variables */
  1119. doublereal zero, a;
  1120. integer i__;
  1121. doublereal rbase, b1, b2, c1, c2, d1, d2;
  1122. extern doublereal dlamc3_(doublereal *, doublereal *);
  1123. doublereal one;
  1124. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  1125. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  1126. /* November 2010 */
  1127. /* ===================================================================== */
  1128. a = *start;
  1129. one = 1.;
  1130. rbase = one / *base;
  1131. zero = 0.;
  1132. *emin = 1;
  1133. d__1 = a * rbase;
  1134. b1 = dlamc3_(&d__1, &zero);
  1135. c1 = a;
  1136. c2 = a;
  1137. d1 = a;
  1138. d2 = a;
  1139. /* + WHILE( ( C1.EQ.A ).AND.( C2.EQ.A ).AND. */
  1140. /* $ ( D1.EQ.A ).AND.( D2.EQ.A ) )LOOP */
  1141. L10:
  1142. if (c1 == a && c2 == a && d1 == a && d2 == a) {
  1143. --(*emin);
  1144. a = b1;
  1145. d__1 = a / *base;
  1146. b1 = dlamc3_(&d__1, &zero);
  1147. d__1 = b1 * *base;
  1148. c1 = dlamc3_(&d__1, &zero);
  1149. d1 = zero;
  1150. i__1 = *base;
  1151. for (i__ = 1; i__ <= i__1; ++i__) {
  1152. d1 += b1;
  1153. /* L20: */
  1154. }
  1155. d__1 = a * rbase;
  1156. b2 = dlamc3_(&d__1, &zero);
  1157. d__1 = b2 / rbase;
  1158. c2 = dlamc3_(&d__1, &zero);
  1159. d2 = zero;
  1160. i__1 = *base;
  1161. for (i__ = 1; i__ <= i__1; ++i__) {
  1162. d2 += b2;
  1163. /* L30: */
  1164. }
  1165. goto L10;
  1166. }
  1167. /* + END WHILE */
  1168. return 0;
  1169. /* End of DLAMC4 */
  1170. } /* dlamc4_ */
  1171. /* *********************************************************************** */
  1172. /* > \brief \b DLAMC5 */
  1173. /* > \details */
  1174. /* > \b Purpose: */
  1175. /* > \verbatim */
  1176. /* > DLAMC5 attempts to compute RMAX, the largest machine floating-point */
  1177. /* > number, without overflow. It assumes that EMAX + abs(EMIN) sum */
  1178. /* > approximately to a power of 2. It will fail on machines where this */
  1179. /* > assumption does not hold, for example, the Cyber 205 (EMIN = -28625, */
  1180. /* > EMAX = 28718). It will also fail if the value supplied for EMIN is */
  1181. /* > too large (i.e. too close to zero), probably with overflow. */
  1182. /* > \endverbatim */
  1183. /* > */
  1184. /* > \param[in] BETA */
  1185. /* > \verbatim */
  1186. /* > The base of floating-point arithmetic. */
  1187. /* > \endverbatim */
  1188. /* > */
  1189. /* > \param[in] P */
  1190. /* > \verbatim */
  1191. /* > The number of base BETA digits in the mantissa of a */
  1192. /* > floating-point value. */
  1193. /* > \endverbatim */
  1194. /* > */
  1195. /* > \param[in] EMIN */
  1196. /* > \verbatim */
  1197. /* > The minimum exponent before (gradual) underflow. */
  1198. /* > \endverbatim */
  1199. /* > */
  1200. /* > \param[in] IEEE */
  1201. /* > \verbatim */
  1202. /* > A logical flag specifying whether or not the arithmetic */
  1203. /* > system is thought to comply with the IEEE standard. */
  1204. /* > \endverbatim */
  1205. /* > */
  1206. /* > \param[out] EMAX */
  1207. /* > \verbatim */
  1208. /* > The largest exponent before overflow */
  1209. /* > \endverbatim */
  1210. /* > */
  1211. /* > \param[out] RMAX */
  1212. /* > \verbatim */
  1213. /* > The largest machine floating-point number. */
  1214. /* > \endverbatim */
  1215. /* > */
  1216. /* Subroutine */ int dlamc5_(integer *beta, integer *p, integer *emin,
  1217. logical *ieee, integer *emax, doublereal *rmax)
  1218. {
  1219. /* System generated locals */
  1220. integer i__1;
  1221. doublereal d__1;
  1222. /* Local variables */
  1223. integer lexp;
  1224. doublereal oldy;
  1225. integer uexp, i__;
  1226. doublereal y, z__;
  1227. integer nbits;
  1228. extern doublereal dlamc3_(doublereal *, doublereal *);
  1229. doublereal recbas;
  1230. integer exbits, expsum, try__;
  1231. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  1232. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  1233. /* November 2010 */
  1234. /* ===================================================================== */
  1235. /* First compute LEXP and UEXP, two powers of 2 that bound */
  1236. /* abs(EMIN). We then assume that EMAX + abs(EMIN) will sum */
  1237. /* approximately to the bound that is closest to abs(EMIN). */
  1238. /* (EMAX is the exponent of the required number RMAX). */
  1239. lexp = 1;
  1240. exbits = 1;
  1241. L10:
  1242. try__ = lexp << 1;
  1243. if (try__ <= -(*emin)) {
  1244. lexp = try__;
  1245. ++exbits;
  1246. goto L10;
  1247. }
  1248. if (lexp == -(*emin)) {
  1249. uexp = lexp;
  1250. } else {
  1251. uexp = try__;
  1252. ++exbits;
  1253. }
  1254. /* Now -LEXP is less than or equal to EMIN, and -UEXP is greater */
  1255. /* than or equal to EMIN. EXBITS is the number of bits needed to */
  1256. /* store the exponent. */
  1257. if (uexp + *emin > -lexp - *emin) {
  1258. expsum = lexp << 1;
  1259. } else {
  1260. expsum = uexp << 1;
  1261. }
  1262. /* EXPSUM is the exponent range, approximately equal to */
  1263. /* EMAX - EMIN + 1 . */
  1264. *emax = expsum + *emin - 1;
  1265. nbits = exbits + 1 + *p;
  1266. /* NBITS is the total number of bits needed to store a */
  1267. /* floating-point number. */
  1268. if (nbits % 2 == 1 && *beta == 2) {
  1269. /* Either there are an odd number of bits used to store a */
  1270. /* floating-point number, which is unlikely, or some bits are */
  1271. /* not used in the representation of numbers, which is possible, */
  1272. /* (e.g. Cray machines) or the mantissa has an implicit bit, */
  1273. /* (e.g. IEEE machines, Dec Vax machines), which is perhaps the */
  1274. /* most likely. We have to assume the last alternative. */
  1275. /* If this is true, then we need to reduce EMAX by one because */
  1276. /* there must be some way of representing zero in an implicit-bit */
  1277. /* system. On machines like Cray, we are reducing EMAX by one */
  1278. /* unnecessarily. */
  1279. --(*emax);
  1280. }
  1281. if (*ieee) {
  1282. /* Assume we are on an IEEE machine which reserves one exponent */
  1283. /* for infinity and NaN. */
  1284. --(*emax);
  1285. }
  1286. /* Now create RMAX, the largest machine number, which should */
  1287. /* be equal to (1.0 - BETA**(-P)) * BETA**EMAX . */
  1288. /* First compute 1.0 - BETA**(-P), being careful that the */
  1289. /* result is less than 1.0 . */
  1290. recbas = 1. / *beta;
  1291. z__ = *beta - 1.;
  1292. y = 0.;
  1293. i__1 = *p;
  1294. for (i__ = 1; i__ <= i__1; ++i__) {
  1295. z__ *= recbas;
  1296. if (y < 1.) {
  1297. oldy = y;
  1298. }
  1299. y = dlamc3_(&y, &z__);
  1300. /* L20: */
  1301. }
  1302. if (y >= 1.) {
  1303. y = oldy;
  1304. }
  1305. /* Now multiply by BETA**EMAX to get RMAX. */
  1306. i__1 = *emax;
  1307. for (i__ = 1; i__ <= i__1; ++i__) {
  1308. d__1 = y * *beta;
  1309. y = dlamc3_(&d__1, &c_b32);
  1310. /* L30: */
  1311. }
  1312. *rmax = y;
  1313. return 0;
  1314. /* End of DLAMC5 */
  1315. } /* dlamc5_ */