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.

dlaqz0.c 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /* f2c.h -- Standard Fortran to C header file */
  2. /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
  3. - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
  4. #ifndef F2C_INCLUDE
  5. #define F2C_INCLUDE
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <complex.h>
  11. #ifdef complex
  12. #undef complex
  13. #endif
  14. #ifdef I
  15. #undef I
  16. #endif
  17. #if defined(_WIN64)
  18. typedef long long BLASLONG;
  19. typedef unsigned long long BLASULONG;
  20. #else
  21. typedef long BLASLONG;
  22. typedef unsigned long BLASULONG;
  23. #endif
  24. #ifdef LAPACK_ILP64
  25. typedef BLASLONG blasint;
  26. #if defined(_WIN64)
  27. #define blasabs(x) llabs(x)
  28. #else
  29. #define blasabs(x) labs(x)
  30. #endif
  31. #else
  32. typedef int blasint;
  33. #define blasabs(x) abs(x)
  34. #endif
  35. typedef blasint integer;
  36. typedef unsigned int uinteger;
  37. typedef char *address;
  38. typedef short int shortint;
  39. typedef float real;
  40. typedef double doublereal;
  41. typedef struct { real r, i; } complex;
  42. typedef struct { doublereal r, i; } doublecomplex;
  43. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  44. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  46. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  47. #define pCf(z) (*_pCf(z))
  48. #define pCd(z) (*_pCd(z))
  49. typedef blasint logical;
  50. typedef char logical1;
  51. typedef char integer1;
  52. #define TRUE_ (1)
  53. #define FALSE_ (0)
  54. /* Extern is for use with -E */
  55. #ifndef Extern
  56. #define Extern extern
  57. #endif
  58. /* I/O stuff */
  59. typedef int flag;
  60. typedef int ftnlen;
  61. typedef int ftnint;
  62. /*external read, write*/
  63. typedef struct
  64. { flag cierr;
  65. ftnint ciunit;
  66. flag ciend;
  67. char *cifmt;
  68. ftnint cirec;
  69. } cilist;
  70. /*internal read, write*/
  71. typedef struct
  72. { flag icierr;
  73. char *iciunit;
  74. flag iciend;
  75. char *icifmt;
  76. ftnint icirlen;
  77. ftnint icirnum;
  78. } icilist;
  79. /*open*/
  80. typedef struct
  81. { flag oerr;
  82. ftnint ounit;
  83. char *ofnm;
  84. ftnlen ofnmlen;
  85. char *osta;
  86. char *oacc;
  87. char *ofm;
  88. ftnint orl;
  89. char *oblnk;
  90. } olist;
  91. /*close*/
  92. typedef struct
  93. { flag cerr;
  94. ftnint cunit;
  95. char *csta;
  96. } cllist;
  97. /*rewind, backspace, endfile*/
  98. typedef struct
  99. { flag aerr;
  100. ftnint aunit;
  101. } alist;
  102. /* inquire */
  103. typedef struct
  104. { flag inerr;
  105. ftnint inunit;
  106. char *infile;
  107. ftnlen infilen;
  108. ftnint *inex; /*parameters in standard's order*/
  109. ftnint *inopen;
  110. ftnint *innum;
  111. ftnint *innamed;
  112. char *inname;
  113. ftnlen innamlen;
  114. char *inacc;
  115. ftnlen inacclen;
  116. char *inseq;
  117. ftnlen inseqlen;
  118. char *indir;
  119. ftnlen indirlen;
  120. char *infmt;
  121. ftnlen infmtlen;
  122. char *inform;
  123. ftnint informlen;
  124. char *inunf;
  125. ftnlen inunflen;
  126. ftnint *inrecl;
  127. ftnint *innrec;
  128. char *inblank;
  129. ftnlen inblanklen;
  130. } inlist;
  131. #define VOID void
  132. union Multitype { /* for multiple entry points */
  133. integer1 g;
  134. shortint h;
  135. integer i;
  136. /* longint j; */
  137. real r;
  138. doublereal d;
  139. complex c;
  140. doublecomplex z;
  141. };
  142. typedef union Multitype Multitype;
  143. struct Vardesc { /* for Namelist */
  144. char *name;
  145. char *addr;
  146. ftnlen *dims;
  147. int type;
  148. };
  149. typedef struct Vardesc Vardesc;
  150. struct Namelist {
  151. char *name;
  152. Vardesc **vars;
  153. int nvars;
  154. };
  155. typedef struct Namelist Namelist;
  156. #define abs(x) ((x) >= 0 ? (x) : -(x))
  157. #define dabs(x) (fabs(x))
  158. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  159. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  160. #define dmin(a,b) (f2cmin(a,b))
  161. #define dmax(a,b) (f2cmax(a,b))
  162. #define bit_test(a,b) ((a) >> (b) & 1)
  163. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  164. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  165. #define abort_() { sig_die("Fortran abort routine called", 1); }
  166. #define c_abs(z) (cabsf(Cf(z)))
  167. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  168. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  169. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  170. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  171. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  172. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  173. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  174. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  175. #define d_abs(x) (fabs(*(x)))
  176. #define d_acos(x) (acos(*(x)))
  177. #define d_asin(x) (asin(*(x)))
  178. #define d_atan(x) (atan(*(x)))
  179. #define d_atn2(x, y) (atan2(*(x),*(y)))
  180. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  181. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  182. #define d_cos(x) (cos(*(x)))
  183. #define d_cosh(x) (cosh(*(x)))
  184. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  185. #define d_exp(x) (exp(*(x)))
  186. #define d_imag(z) (cimag(Cd(z)))
  187. #define r_imag(z) (cimag(Cf(z)))
  188. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  189. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  190. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  191. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  192. #define d_log(x) (log(*(x)))
  193. #define d_mod(x, y) (fmod(*(x), *(y)))
  194. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  195. #define d_nint(x) u_nint(*(x))
  196. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  197. #define d_sign(a,b) u_sign(*(a),*(b))
  198. #define r_sign(a,b) u_sign(*(a),*(b))
  199. #define d_sin(x) (sin(*(x)))
  200. #define d_sinh(x) (sinh(*(x)))
  201. #define d_sqrt(x) (sqrt(*(x)))
  202. #define d_tan(x) (tan(*(x)))
  203. #define d_tanh(x) (tanh(*(x)))
  204. #define i_abs(x) abs(*(x))
  205. #define i_dnnt(x) ((integer)u_nint(*(x)))
  206. #define i_len(s, n) (n)
  207. #define i_nint(x) ((integer)u_nint(*(x)))
  208. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  209. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  210. #define pow_si(B,E) spow_ui(*(B),*(E))
  211. #define pow_ri(B,E) spow_ui(*(B),*(E))
  212. #define pow_di(B,E) dpow_ui(*(B),*(E))
  213. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  214. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  215. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  216. #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++ = ' '; }
  217. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  218. #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]; }
  219. #define sig_die(s, kill) { exit(1); }
  220. #define s_stop(s, n) {exit(0);}
  221. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  222. #define z_abs(z) (cabs(Cd(z)))
  223. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  224. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  225. #define myexit_() break;
  226. #define mycycle_() continue;
  227. #define myceiling_(w) ceil(w)
  228. #define myhuge_(w) HUGE_VAL
  229. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  230. #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n)
  231. /* procedure parameter types for -A and -C++ */
  232. #ifdef __cplusplus
  233. typedef logical (*L_fp)(...);
  234. #else
  235. typedef logical (*L_fp)();
  236. #endif
  237. static float spow_ui(float x, integer n) {
  238. float pow=1.0; unsigned long int u;
  239. if(n != 0) {
  240. if(n < 0) n = -n, x = 1/x;
  241. for(u = n; ; ) {
  242. if(u & 01) pow *= x;
  243. if(u >>= 1) x *= x;
  244. else break;
  245. }
  246. }
  247. return pow;
  248. }
  249. static double dpow_ui(double x, integer n) {
  250. double pow=1.0; unsigned long int u;
  251. if(n != 0) {
  252. if(n < 0) n = -n, x = 1/x;
  253. for(u = n; ; ) {
  254. if(u & 01) pow *= x;
  255. if(u >>= 1) x *= x;
  256. else break;
  257. }
  258. }
  259. return pow;
  260. }
  261. static _Complex float cpow_ui(_Complex float x, integer n) {
  262. _Complex float pow=1.0; unsigned long int u;
  263. if(n != 0) {
  264. if(n < 0) n = -n, x = 1/x;
  265. for(u = n; ; ) {
  266. if(u & 01) pow *= x;
  267. if(u >>= 1) x *= x;
  268. else break;
  269. }
  270. }
  271. return pow;
  272. }
  273. static _Complex double zpow_ui(_Complex double x, integer n) {
  274. _Complex double pow=1.0; unsigned long int u;
  275. if(n != 0) {
  276. if(n < 0) n = -n, x = 1/x;
  277. for(u = n; ; ) {
  278. if(u & 01) pow *= x;
  279. if(u >>= 1) x *= x;
  280. else break;
  281. }
  282. }
  283. return pow;
  284. }
  285. static integer pow_ii(integer x, integer n) {
  286. integer pow; unsigned long int u;
  287. if (n <= 0) {
  288. if (n == 0 || x == 1) pow = 1;
  289. else if (x != -1) pow = x == 0 ? 1/x : 0;
  290. else n = -n;
  291. }
  292. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  293. u = n;
  294. for(pow = 1; ; ) {
  295. if(u & 01) pow *= x;
  296. if(u >>= 1) x *= x;
  297. else break;
  298. }
  299. }
  300. return pow;
  301. }
  302. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  303. {
  304. double m; integer i, mi;
  305. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  306. if (w[i-1]>m) mi=i ,m=w[i-1];
  307. return mi-s+1;
  308. }
  309. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  310. {
  311. float m; integer i, mi;
  312. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  313. if (w[i-1]>m) mi=i ,m=w[i-1];
  314. return mi-s+1;
  315. }
  316. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  317. integer n = *n_, incx = *incx_, incy = *incy_, i;
  318. _Complex float zdotc = 0.0;
  319. if (incx == 1 && incy == 1) {
  320. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  321. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  322. }
  323. } else {
  324. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  325. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  326. }
  327. }
  328. pCf(z) = zdotc;
  329. }
  330. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  331. integer n = *n_, incx = *incx_, incy = *incy_, i;
  332. _Complex double zdotc = 0.0;
  333. if (incx == 1 && incy == 1) {
  334. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  335. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  336. }
  337. } else {
  338. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  339. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  340. }
  341. }
  342. pCd(z) = zdotc;
  343. }
  344. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  345. integer n = *n_, incx = *incx_, incy = *incy_, i;
  346. _Complex float zdotc = 0.0;
  347. if (incx == 1 && incy == 1) {
  348. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  349. zdotc += Cf(&x[i]) * Cf(&y[i]);
  350. }
  351. } else {
  352. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  353. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  354. }
  355. }
  356. pCf(z) = zdotc;
  357. }
  358. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  359. integer n = *n_, incx = *incx_, incy = *incy_, i;
  360. _Complex double zdotc = 0.0;
  361. if (incx == 1 && incy == 1) {
  362. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  363. zdotc += Cd(&x[i]) * Cd(&y[i]);
  364. }
  365. } else {
  366. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  367. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  368. }
  369. }
  370. pCd(z) = zdotc;
  371. }
  372. #endif