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.

c_zblat1c.c 36 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  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. #include "common.h"
  13. typedef blasint integer;
  14. typedef unsigned int uinteger;
  15. typedef char *address;
  16. typedef short int shortint;
  17. typedef float real;
  18. typedef double doublereal;
  19. typedef struct { real r, i; } complex;
  20. typedef struct { doublereal r, i; } doublecomplex;
  21. #ifdef _MSC_VER
  22. static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
  23. static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
  24. static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
  25. static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
  26. #else
  27. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  28. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  29. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  30. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  31. #endif
  32. #define pCf(z) (*_pCf(z))
  33. #define pCd(z) (*_pCd(z))
  34. typedef int logical;
  35. typedef short int shortlogical;
  36. typedef char logical1;
  37. typedef char integer1;
  38. #define TRUE_ (1)
  39. #define FALSE_ (0)
  40. /* Extern is for use with -E */
  41. #ifndef Extern
  42. #define Extern extern
  43. #endif
  44. /* I/O stuff */
  45. typedef int flag;
  46. typedef int ftnlen;
  47. typedef int ftnint;
  48. /*external read, write*/
  49. typedef struct
  50. { flag cierr;
  51. ftnint ciunit;
  52. flag ciend;
  53. char *cifmt;
  54. ftnint cirec;
  55. } cilist;
  56. /*internal read, write*/
  57. typedef struct
  58. { flag icierr;
  59. char *iciunit;
  60. flag iciend;
  61. char *icifmt;
  62. ftnint icirlen;
  63. ftnint icirnum;
  64. } icilist;
  65. /*open*/
  66. typedef struct
  67. { flag oerr;
  68. ftnint ounit;
  69. char *ofnm;
  70. ftnlen ofnmlen;
  71. char *osta;
  72. char *oacc;
  73. char *ofm;
  74. ftnint orl;
  75. char *oblnk;
  76. } olist;
  77. /*close*/
  78. typedef struct
  79. { flag cerr;
  80. ftnint cunit;
  81. char *csta;
  82. } cllist;
  83. /*rewind, backspace, endfile*/
  84. typedef struct
  85. { flag aerr;
  86. ftnint aunit;
  87. } alist;
  88. /* inquire */
  89. typedef struct
  90. { flag inerr;
  91. ftnint inunit;
  92. char *infile;
  93. ftnlen infilen;
  94. ftnint *inex; /*parameters in standard's order*/
  95. ftnint *inopen;
  96. ftnint *innum;
  97. ftnint *innamed;
  98. char *inname;
  99. ftnlen innamlen;
  100. char *inacc;
  101. ftnlen inacclen;
  102. char *inseq;
  103. ftnlen inseqlen;
  104. char *indir;
  105. ftnlen indirlen;
  106. char *infmt;
  107. ftnlen infmtlen;
  108. char *inform;
  109. ftnint informlen;
  110. char *inunf;
  111. ftnlen inunflen;
  112. ftnint *inrecl;
  113. ftnint *innrec;
  114. char *inblank;
  115. ftnlen inblanklen;
  116. } inlist;
  117. #define VOID void
  118. union Multitype { /* for multiple entry points */
  119. integer1 g;
  120. shortint h;
  121. integer i;
  122. /* longint j; */
  123. real r;
  124. doublereal d;
  125. complex c;
  126. doublecomplex z;
  127. };
  128. typedef union Multitype Multitype;
  129. struct Vardesc { /* for Namelist */
  130. char *name;
  131. char *addr;
  132. ftnlen *dims;
  133. int type;
  134. };
  135. typedef struct Vardesc Vardesc;
  136. struct Namelist {
  137. char *name;
  138. Vardesc **vars;
  139. int nvars;
  140. };
  141. typedef struct Namelist Namelist;
  142. #define abs(x) ((x) >= 0 ? (x) : -(x))
  143. #define dabs(x) (fabs(x))
  144. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  145. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  146. #define dmin(a,b) (f2cmin(a,b))
  147. #define dmax(a,b) (f2cmax(a,b))
  148. #define bit_test(a,b) ((a) >> (b) & 1)
  149. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  150. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  151. #define abort_() { sig_die("Fortran abort routine called", 1); }
  152. #define c_abs(z) (cabsf(Cf(z)))
  153. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  154. #ifdef _MSC_VER
  155. #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]);}
  156. #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);}
  157. #else
  158. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  159. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  160. #endif
  161. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  162. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  163. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  164. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  165. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  166. #define d_abs(x) (fabs(*(x)))
  167. #define d_acos(x) (acos(*(x)))
  168. #define d_asin(x) (asin(*(x)))
  169. #define d_atan(x) (atan(*(x)))
  170. #define d_atn2(x, y) (atan2(*(x),*(y)))
  171. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  172. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  173. #define d_cos(x) (cos(*(x)))
  174. #define d_cosh(x) (cosh(*(x)))
  175. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  176. #define d_exp(x) (exp(*(x)))
  177. #define d_imag(z) (cimag(Cd(z)))
  178. #define r_imag(z) (cimagf(Cf(z)))
  179. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  180. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  181. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  182. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  183. #define d_log(x) (log(*(x)))
  184. #define d_mod(x, y) (fmod(*(x), *(y)))
  185. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  186. #define d_nint(x) u_nint(*(x))
  187. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  188. #define d_sign(a,b) u_sign(*(a),*(b))
  189. #define r_sign(a,b) u_sign(*(a),*(b))
  190. #define d_sin(x) (sin(*(x)))
  191. #define d_sinh(x) (sinh(*(x)))
  192. #define d_sqrt(x) (sqrt(*(x)))
  193. #define d_tan(x) (tan(*(x)))
  194. #define d_tanh(x) (tanh(*(x)))
  195. #define i_abs(x) abs(*(x))
  196. #define i_dnnt(x) ((integer)u_nint(*(x)))
  197. #define i_len(s, n) (n)
  198. #define i_nint(x) ((integer)u_nint(*(x)))
  199. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  200. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  201. #define pow_si(B,E) spow_ui(*(B),*(E))
  202. #define pow_ri(B,E) spow_ui(*(B),*(E))
  203. #define pow_di(B,E) dpow_ui(*(B),*(E))
  204. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  205. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  206. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  207. #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++ = ' '; }
  208. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  209. #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]; }
  210. #define sig_die(s, kill) { exit(1); }
  211. #define s_stop(s, n) {exit(0);}
  212. #define z_abs(z) (cabs(Cd(z)))
  213. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  214. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  215. #define myexit_() break;
  216. #define mycycle_() continue;
  217. #define myceiling_(w) {ceil(w)}
  218. #define myhuge_(w) {HUGE_VAL}
  219. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  220. #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n)
  221. /* procedure parameter types for -A and -C++ */
  222. #define F2C_proc_par_types 1
  223. #ifdef __cplusplus
  224. typedef logical (*L_fp)(...);
  225. #else
  226. typedef logical (*L_fp)();
  227. #endif
  228. #if 0
  229. static float spow_ui(float x, integer n) {
  230. float pow=1.0; unsigned long int u;
  231. if(n != 0) {
  232. if(n < 0) n = -n, x = 1/x;
  233. for(u = n; ; ) {
  234. if(u & 01) pow *= x;
  235. if(u >>= 1) x *= x;
  236. else break;
  237. }
  238. }
  239. return pow;
  240. }
  241. static double dpow_ui(double x, integer n) {
  242. double pow=1.0; unsigned long int u;
  243. if(n != 0) {
  244. if(n < 0) n = -n, x = 1/x;
  245. for(u = n; ; ) {
  246. if(u & 01) pow *= x;
  247. if(u >>= 1) x *= x;
  248. else break;
  249. }
  250. }
  251. return pow;
  252. }
  253. #ifdef _MSC_VER
  254. static _Fcomplex cpow_ui(complex x, integer n) {
  255. complex pow={1.0,0.0}; unsigned long int u;
  256. if(n != 0) {
  257. if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
  258. for(u = n; ; ) {
  259. if(u & 01) pow.r *= x.r, pow.i *= x.i;
  260. if(u >>= 1) x.r *= x.r, x.i *= x.i;
  261. else break;
  262. }
  263. }
  264. _Fcomplex p={pow.r, pow.i};
  265. return p;
  266. }
  267. #else
  268. static _Complex float cpow_ui(_Complex float x, integer n) {
  269. _Complex float pow=1.0; unsigned long int u;
  270. if(n != 0) {
  271. if(n < 0) n = -n, x = 1/x;
  272. for(u = n; ; ) {
  273. if(u & 01) pow *= x;
  274. if(u >>= 1) x *= x;
  275. else break;
  276. }
  277. }
  278. return pow;
  279. }
  280. #endif
  281. #ifdef _MSC_VER
  282. static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
  283. _Dcomplex pow={1.0,0.0}; unsigned long int u;
  284. if(n != 0) {
  285. if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
  286. for(u = n; ; ) {
  287. if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
  288. if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
  289. else break;
  290. }
  291. }
  292. _Dcomplex p = {pow._Val[0], pow._Val[1]};
  293. return p;
  294. }
  295. #else
  296. static _Complex double zpow_ui(_Complex double x, integer n) {
  297. _Complex double pow=1.0; unsigned long int u;
  298. if(n != 0) {
  299. if(n < 0) n = -n, x = 1/x;
  300. for(u = n; ; ) {
  301. if(u & 01) pow *= x;
  302. if(u >>= 1) x *= x;
  303. else break;
  304. }
  305. }
  306. return pow;
  307. }
  308. #endif
  309. static integer pow_ii(integer x, integer n) {
  310. integer pow; unsigned long int u;
  311. if (n <= 0) {
  312. if (n == 0 || x == 1) pow = 1;
  313. else if (x != -1) pow = x == 0 ? 1/x : 0;
  314. else n = -n;
  315. }
  316. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  317. u = n;
  318. for(pow = 1; ; ) {
  319. if(u & 01) pow *= x;
  320. if(u >>= 1) x *= x;
  321. else break;
  322. }
  323. }
  324. return pow;
  325. }
  326. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  327. {
  328. double m; integer i, mi;
  329. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  330. if (w[i-1]>m) mi=i ,m=w[i-1];
  331. return mi-s+1;
  332. }
  333. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  334. {
  335. float m; integer i, mi;
  336. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  337. if (w[i-1]>m) mi=i ,m=w[i-1];
  338. return mi-s+1;
  339. }
  340. #endif
  341. #if 0
  342. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  343. integer n = *n_, incx = *incx_, incy = *incy_, i;
  344. #ifdef _MSC_VER
  345. _Fcomplex zdotc = {0.0, 0.0};
  346. if (incx == 1 && incy == 1) {
  347. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  348. zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
  349. zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
  350. }
  351. } else {
  352. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  353. zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
  354. zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
  355. }
  356. }
  357. pCf(z) = zdotc;
  358. }
  359. #else
  360. _Complex float 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 += conjf(Cf(&x[i])) * Cf(&y[i]);
  364. }
  365. } else {
  366. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  367. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  368. }
  369. }
  370. pCf(z) = zdotc;
  371. }
  372. #endif
  373. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  374. integer n = *n_, incx = *incx_, incy = *incy_, i;
  375. #ifdef _MSC_VER
  376. _Dcomplex zdotc = {0.0, 0.0};
  377. if (incx == 1 && incy == 1) {
  378. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  379. zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
  380. zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
  381. }
  382. } else {
  383. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  384. zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
  385. zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
  386. }
  387. }
  388. pCd(z) = zdotc;
  389. }
  390. #else
  391. _Complex double zdotc = 0.0;
  392. if (incx == 1 && incy == 1) {
  393. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  394. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  395. }
  396. } else {
  397. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  398. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  399. }
  400. }
  401. pCd(z) = zdotc;
  402. }
  403. #endif
  404. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  405. integer n = *n_, incx = *incx_, incy = *incy_, i;
  406. #ifdef _MSC_VER
  407. _Fcomplex zdotc = {0.0, 0.0};
  408. if (incx == 1 && incy == 1) {
  409. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  410. zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
  411. zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
  412. }
  413. } else {
  414. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  415. zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
  416. zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
  417. }
  418. }
  419. pCf(z) = zdotc;
  420. }
  421. #else
  422. _Complex float zdotc = 0.0;
  423. if (incx == 1 && incy == 1) {
  424. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  425. zdotc += Cf(&x[i]) * Cf(&y[i]);
  426. }
  427. } else {
  428. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  429. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  430. }
  431. }
  432. pCf(z) = zdotc;
  433. }
  434. #endif
  435. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  436. integer n = *n_, incx = *incx_, incy = *incy_, i;
  437. #ifdef _MSC_VER
  438. _Dcomplex zdotc = {0.0, 0.0};
  439. if (incx == 1 && incy == 1) {
  440. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  441. zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
  442. zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
  443. }
  444. } else {
  445. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  446. zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
  447. zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
  448. }
  449. }
  450. pCd(z) = zdotc;
  451. }
  452. #else
  453. _Complex double zdotc = 0.0;
  454. if (incx == 1 && incy == 1) {
  455. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  456. zdotc += Cd(&x[i]) * Cd(&y[i]);
  457. }
  458. } else {
  459. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  460. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  461. }
  462. }
  463. pCd(z) = zdotc;
  464. }
  465. #endif
  466. #endif
  467. /* Common Block Declarations */
  468. struct {
  469. integer icase, n, incx, incy, mode;
  470. logical pass;
  471. } combla_;
  472. #define combla_1 combla_
  473. /* Table of constant values */
  474. static integer c__1 = 1;
  475. static integer c__5 = 5;
  476. static doublereal c_b43 = 1.;
  477. /* Main program */ int main()
  478. {
  479. /* Initialized data */
  480. static doublereal sfac = 9.765625e-4;
  481. /* Local variables */
  482. extern /* Subroutine */ int check1_(), check2_();
  483. static integer ic;
  484. extern /* Subroutine */ int header_();
  485. /* Test program for the COMPLEX*16 Level 1 CBLAS. */
  486. /* Based upon the original CBLAS test routine together with: */
  487. /* F06GAF Example Program Text */
  488. /* .. Parameters .. */
  489. /* .. Scalars in Common .. */
  490. /* .. Local Scalars .. */
  491. /* .. External Subroutines .. */
  492. /* .. Common blocks .. */
  493. /* .. Data statements .. */
  494. /* .. Executable Statements .. */
  495. printf("Complex CBLAS Test Program Results\n");
  496. for (ic = 1; ic <= 10; ++ic) {
  497. combla_1.icase = ic;
  498. header_();
  499. /* Initialize PASS, INCX, INCY, and MODE for a new case. */
  500. /* The value 9999 for INCX, INCY or MODE will appear in the */
  501. /* detailed output, if any, for cases that do not involve */
  502. /* these parameters. */
  503. combla_1.pass = TRUE_;
  504. combla_1.incx = 9999;
  505. combla_1.incy = 9999;
  506. combla_1.mode = 9999;
  507. if (combla_1.icase <= 5) {
  508. check2_(&sfac);
  509. } else if (combla_1.icase >= 6) {
  510. check1_(&sfac);
  511. }
  512. /* -- Print */
  513. if (combla_1.pass) {
  514. printf(" ----- PASS -----\n");
  515. }
  516. /* L20: */
  517. }
  518. exit(0);
  519. } /* MAIN__ */
  520. /* Subroutine */ int header_()
  521. {
  522. /* Initialized data */
  523. static char l[15][13] = { "CBLAS_ZDOTC " , "CBLAS_ZDOTU " , "CBLAS_ZAXPY " ,
  524. "CBLAS_ZCOPY " , "CBLAS_ZSWAP " , "CBLAS_DZNRM2" , "CBLAS_DZASUM" ,
  525. "CBLAS_ZSCAL " , "CBLAS_ZDSCAL" , "CBLAS_IZAMAX" };
  526. /* .. Parameters .. */
  527. /* .. Scalars in Common .. */
  528. /* .. Local Arrays .. */
  529. /* .. Common blocks .. */
  530. /* .. Data statements .. */
  531. /* .. Executable Statements .. */
  532. printf("Test of subprogram number %3d %15s", combla_1.icase, l[combla_1.icase-1]);
  533. return 0;
  534. } /* header_ */
  535. /* Subroutine */ int check1_(sfac)
  536. doublereal *sfac;
  537. {
  538. /* Initialized data */
  539. static doublereal strue2[5] = { 0.,.5,.6,.7,.7 };
  540. static doublereal strue4[5] = { 0.,.7,1.,1.3,1.7 };
  541. static doublecomplex ctrue5[80] /* was [8][5][2] */ = { {.1,.1},{1.,
  542. 2.},{1.,2.},{1.,2.},{1.,2.},{1.,2.},{1.,2.},{1.,2.},{-.16,-.37},{
  543. 3.,4.},{3.,4.},{3.,4.},{3.,4.},{3.,4.},{3.,4.},{3.,4.},{-.17,-.19}
  544. ,{.13,-.39},{5.,6.},{5.,6.},{5.,6.},{5.,6.},{5.,6.},{5.,6.},{.11,
  545. -.03},{-.17,.46},{-.17,-.19},{7.,8.},{7.,8.},{7.,8.},{7.,8.},{7.,
  546. 8.},{.19,-.17},{.32,.09},{.23,-.24},{.18,.01},{2.,3.},{2.,3.},{2.,
  547. 3.},{2.,3.},{.1,.1},{4.,5.},{4.,5.},{4.,5.},{4.,5.},{4.,5.},{4.,
  548. 5.},{4.,5.},{-.16,-.37},{6.,7.},{6.,7.},{6.,7.},{6.,7.},{6.,7.},{
  549. 6.,7.},{6.,7.},{-.17,-.19},{8.,9.},{.13,-.39},{2.,5.},{2.,5.},{2.,
  550. 5.},{2.,5.},{2.,5.},{.11,-.03},{3.,6.},{-.17,.46},{4.,7.},{-.17,
  551. -.19},{7.,2.},{7.,2.},{7.,2.},{.19,-.17},{5.,8.},{.32,.09},{6.,9.}
  552. ,{.23,-.24},{8.,3.},{.18,.01},{9.,4.} };
  553. static doublecomplex ctrue6[80] /* was [8][5][2] */ = { {.1,.1},{1.,
  554. 2.},{1.,2.},{1.,2.},{1.,2.},{1.,2.},{1.,2.},{1.,2.},{.09,-.12},{
  555. 3.,4.},{3.,4.},{3.,4.},{3.,4.},{3.,4.},{3.,4.},{3.,4.},{.03,-.09},
  556. {.15,-.03},{5.,6.},{5.,6.},{5.,6.},{5.,6.},{5.,6.},{5.,6.},{.03,
  557. .03},{-.18,.03},{.03,-.09},{7.,8.},{7.,8.},{7.,8.},{7.,8.},{7.,8.}
  558. ,{.09,.03},{.03,.12},{.12,.03},{.03,.06},{2.,3.},{2.,3.},{2.,3.},{
  559. 2.,3.},{.1,.1},{4.,5.},{4.,5.},{4.,5.},{4.,5.},{4.,5.},{4.,5.},{
  560. 4.,5.},{.09,-.12},{6.,7.},{6.,7.},{6.,7.},{6.,7.},{6.,7.},{6.,7.},
  561. {6.,7.},{.03,-.09},{8.,9.},{.15,-.03},{2.,5.},{2.,5.},{2.,5.},{2.,
  562. 5.},{2.,5.},{.03,.03},{3.,6.},{-.18,.03},{4.,7.},{.03,-.09},{7.,
  563. 2.},{7.,2.},{7.,2.},{.09,.03},{5.,8.},{.03,.12},{6.,9.},{.12,.03},
  564. {8.,3.},{.03,.06},{9.,4.} };
  565. static integer itrue3[5] = { 0,1,2,2,2 };
  566. static doublereal sa = .3;
  567. static doublecomplex ca = {.4,-.7};
  568. static doublecomplex cv[80] /* was [8][5][2] */ = { {.1,.1},{1.,2.},{1.,
  569. 2.},{1.,2.},{1.,2.},{1.,2.},{1.,2.},{1.,2.},{.3,-.4},{3.,4.},{3.,
  570. 4.},{3.,4.},{3.,4.},{3.,4.},{3.,4.},{3.,4.},{.1,-.3},{.5,-.1},{5.,
  571. 6.},{5.,6.},{5.,6.},{5.,6.},{5.,6.},{5.,6.},{.1,.1},{-.6,.1},{.1,
  572. -.3},{7.,8.},{7.,8.},{7.,8.},{7.,8.},{7.,8.},{.3,.1},{.1,.4},{.4,
  573. .1},{.1,.2},{2.,3.},{2.,3.},{2.,3.},{2.,3.},{.1,.1},{4.,5.},{4.,
  574. 5.},{4.,5.},{4.,5.},{4.,5.},{4.,5.},{4.,5.},{.3,-.4},{6.,7.},{6.,
  575. 7.},{6.,7.},{6.,7.},{6.,7.},{6.,7.},{6.,7.},{.1,-.3},{8.,9.},{.5,
  576. -.1},{2.,5.},{2.,5.},{2.,5.},{2.,5.},{2.,5.},{.1,.1},{3.,6.},{-.6,
  577. .1},{4.,7.},{.1,-.3},{7.,2.},{7.,2.},{7.,2.},{.3,.1},{5.,8.},{.1,
  578. .4},{6.,9.},{.4,.1},{8.,3.},{.1,.2},{9.,4.} };
  579. /* System generated locals */
  580. integer i__1, i__2, i__3;
  581. doublereal d__1;
  582. doublecomplex z__1;
  583. /* Local variables */
  584. static integer i__;
  585. extern /* Subroutine */ int ctest_();
  586. static doublecomplex mwpcs[5], mwpct[5];
  587. extern /* Subroutine */ int zscaltest_(), itest1_(), stest1_();
  588. static doublecomplex cx[8];
  589. extern doublereal dznrm2test_();
  590. static integer np1;
  591. extern /* Subroutine */ int zdscaltest_();
  592. extern integer izamaxtest_();
  593. extern doublereal dzasumtest_();
  594. static integer len;
  595. /* .. Parameters .. */
  596. /* .. Scalar Arguments .. */
  597. /* .. Scalars in Common .. */
  598. /* .. Local Scalars .. */
  599. /* .. Local Arrays .. */
  600. /* .. External Functions .. */
  601. /* .. External Subroutines .. */
  602. /* .. Intrinsic Functions .. */
  603. /* .. Common blocks .. */
  604. /* .. Data statements .. */
  605. /* .. Executable Statements .. */
  606. for (combla_1.incx = 1; combla_1.incx <= 2; ++combla_1.incx) {
  607. for (np1 = 1; np1 <= 5; ++np1) {
  608. combla_1.n = np1 - 1;
  609. len = f2cmax(combla_1.n,1) << 1;
  610. /* .. Set vector arguments .. */
  611. i__1 = len;
  612. for (i__ = 1; i__ <= i__1; ++i__) {
  613. i__2 = i__ - 1;
  614. i__3 = i__ + (np1 + combla_1.incx * 5 << 3) - 49;
  615. cx[i__2].r = cv[i__3].r, cx[i__2].i = cv[i__3].i;
  616. /* L20: */
  617. }
  618. if (combla_1.icase == 6) {
  619. /* .. DZNRM2TEST .. */
  620. d__1 = dznrm2test_(&combla_1.n, cx, &combla_1.incx);
  621. stest1_(&d__1, &strue2[np1 - 1], &strue2[np1 - 1], sfac);
  622. } else if (combla_1.icase == 7) {
  623. /* .. DZASUMTEST .. */
  624. d__1 = dzasumtest_(&combla_1.n, cx, &combla_1.incx);
  625. stest1_(&d__1, &strue4[np1 - 1], &strue4[np1 - 1], sfac);
  626. } else if (combla_1.icase == 8) {
  627. /* .. ZSCALTEST .. */
  628. zscaltest_(&combla_1.n, &ca, cx, &combla_1.incx);
  629. ctest_(&len, cx, &ctrue5[(np1 + combla_1.incx * 5 << 3) - 48],
  630. &ctrue5[(np1 + combla_1.incx * 5 << 3) - 48], sfac);
  631. } else if (combla_1.icase == 9) {
  632. /* .. ZDSCALTEST .. */
  633. zdscaltest_(&combla_1.n, &sa, cx, &combla_1.incx);
  634. ctest_(&len, cx, &ctrue6[(np1 + combla_1.incx * 5 << 3) - 48],
  635. &ctrue6[(np1 + combla_1.incx * 5 << 3) - 48], sfac);
  636. } else if (combla_1.icase == 10) {
  637. /* .. IZAMAXTEST .. */
  638. i__1 = izamaxtest_(&combla_1.n, cx, &combla_1.incx);
  639. itest1_(&i__1, &itrue3[np1 - 1]);
  640. } else {
  641. fprintf(stderr,"Shouldn't be here in CHECK1\n");
  642. exit(0);
  643. }
  644. /* L40: */
  645. }
  646. /* L60: */
  647. }
  648. combla_1.incx = 1;
  649. if (combla_1.icase == 8) {
  650. /* ZSCALTEST */
  651. /* Add a test for alpha equal to zero. */
  652. ca.r = 0., ca.i = 0.;
  653. for (i__ = 1; i__ <= 5; ++i__) {
  654. i__1 = i__ - 1;
  655. mwpct[i__1].r = 0., mwpct[i__1].i = 0.;
  656. i__1 = i__ - 1;
  657. mwpcs[i__1].r = 1., mwpcs[i__1].i = 1.;
  658. /* L80: */
  659. }
  660. zscaltest_(&c__5, &ca, cx, &combla_1.incx);
  661. ctest_(&c__5, cx, mwpct, mwpcs, sfac);
  662. } else if (combla_1.icase == 9) {
  663. /* ZDSCALTEST */
  664. /* Add a test for alpha equal to zero. */
  665. sa = 0.;
  666. for (i__ = 1; i__ <= 5; ++i__) {
  667. i__1 = i__ - 1;
  668. mwpct[i__1].r = 0., mwpct[i__1].i = 0.;
  669. i__1 = i__ - 1;
  670. mwpcs[i__1].r = 1., mwpcs[i__1].i = 1.;
  671. /* L100: */
  672. }
  673. zdscaltest_(&c__5, &sa, cx, &combla_1.incx);
  674. ctest_(&c__5, cx, mwpct, mwpcs, sfac);
  675. /* Add a test for alpha equal to one. */
  676. sa = 1.;
  677. for (i__ = 1; i__ <= 5; ++i__) {
  678. i__1 = i__ - 1;
  679. i__2 = i__ - 1;
  680. mwpct[i__1].r = cx[i__2].r, mwpct[i__1].i = cx[i__2].i;
  681. i__1 = i__ - 1;
  682. i__2 = i__ - 1;
  683. mwpcs[i__1].r = cx[i__2].r, mwpcs[i__1].i = cx[i__2].i;
  684. /* L120: */
  685. }
  686. zdscaltest_(&c__5, &sa, cx, &combla_1.incx);
  687. ctest_(&c__5, cx, mwpct, mwpcs, sfac);
  688. /* Add a test for alpha equal to minus one. */
  689. sa = -1.;
  690. for (i__ = 1; i__ <= 5; ++i__) {
  691. i__1 = i__ - 1;
  692. i__2 = i__ - 1;
  693. z__1.r = -cx[i__2].r, z__1.i = -cx[i__2].i;
  694. mwpct[i__1].r = z__1.r, mwpct[i__1].i = z__1.i;
  695. i__1 = i__ - 1;
  696. i__2 = i__ - 1;
  697. z__1.r = -cx[i__2].r, z__1.i = -cx[i__2].i;
  698. mwpcs[i__1].r = z__1.r, mwpcs[i__1].i = z__1.i;
  699. /* L140: */
  700. }
  701. zdscaltest_(&c__5, &sa, cx, &combla_1.incx);
  702. ctest_(&c__5, cx, mwpct, mwpcs, sfac);
  703. }
  704. return 0;
  705. } /* check1_ */
  706. /* Subroutine */ int check2_(sfac)
  707. doublereal *sfac;
  708. {
  709. /* Initialized data */
  710. static doublecomplex ca = {.4,-.7};
  711. static integer incxs[4] = { 1,2,-2,-1 };
  712. static integer incys[4] = { 1,-2,1,-2 };
  713. static integer lens[8] /* was [4][2] */ = { 1,1,2,4,1,1,3,7 };
  714. static integer ns[4] = { 0,1,2,4 };
  715. static doublecomplex cx1[7] = { {.7,-.8},{-.4,-.7},{-.1,-.9},{.2,-.8},{
  716. -.9,-.4},{.1,.4},{-.6,.6} };
  717. static doublecomplex cy1[7] = { {.6,-.6},{-.9,.5},{.7,-.6},{.1,-.5},{-.1,
  718. -.2},{-.5,-.3},{.8,-.7} };
  719. static doublecomplex ct8[112] /* was [7][4][4] */ = { {.6,-.6},{0.,
  720. 0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.32,-1.41},{0.,0.},{
  721. 0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.32,-1.41},{-1.55,.5},{0.,
  722. 0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.32,-1.41},{-1.55,.5},{.03,
  723. -.89},{-.38,-.96},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{0.,0.},{0.,0.}
  724. ,{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.32,-1.41},{0.,0.},{0.,0.},{0.,
  725. 0.},{0.,0.},{0.,0.},{0.,0.},{-.07,-.89},{-.9,.5},{.42,-1.41},{0.,
  726. 0.},{0.,0.},{0.,0.},{0.,0.},{.78,.06},{-.9,.5},{.06,-.13},{.1,-.5}
  727. ,{-.77,-.49},{-.5,-.3},{.52,-1.51},{.6,-.6},{0.,0.},{0.,0.},{0.,
  728. 0.},{0.,0.},{0.,0.},{0.,0.},{.32,-1.41},{0.,0.},{0.,0.},{0.,0.},{
  729. 0.,0.},{0.,0.},{0.,0.},{-.07,-.89},{-1.18,-.31},{0.,0.},{0.,0.},{
  730. 0.,0.},{0.,0.},{0.,0.},{.78,.06},{-1.54,.97},{.03,-.89},{-.18,
  731. -1.31},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{0.,0.},{0.,0.},{0.,0.},{
  732. 0.,0.},{0.,0.},{0.,0.},{.32,-1.41},{0.,0.},{0.,0.},{0.,0.},{0.,0.}
  733. ,{0.,0.},{0.,0.},{.32,-1.41},{-.9,.5},{.05,-.6},{0.,0.},{0.,0.},{
  734. 0.,0.},{0.,0.},{.32,-1.41},{-.9,.5},{.05,-.6},{.1,-.5},{-.77,-.49}
  735. ,{-.5,-.3},{.32,-1.16} };
  736. static doublecomplex ct7[16] /* was [4][4] */ = { {0.,0.},{-.06,
  737. -.9},{.65,-.47},{-.34,-1.22},{0.,0.},{-.06,-.9},{-.59,-1.46},{
  738. -1.04,-.04},{0.,0.},{-.06,-.9},{-.83,.59},{.07,-.37},{0.,0.},{
  739. -.06,-.9},{-.76,-1.15},{-1.33,-1.82} };
  740. static doublecomplex ct6[16] /* was [4][4] */ = { {0.,0.},{.9,.06},
  741. {.91,-.77},{1.8,-.1},{0.,0.},{.9,.06},{1.45,.74},{.2,.9},{0.,0.},{
  742. .9,.06},{-.55,.23},{.83,-.39},{0.,0.},{.9,.06},{1.04,.79},{1.95,
  743. 1.22} };
  744. static doublecomplex ct10x[112] /* was [7][4][4] */ = { {.7,-.8},{0.,
  745. 0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{0.,0.},{0.,
  746. 0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{-.9,.5},{0.,0.},{0.,
  747. 0.},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{-.9,.5},{.7,-.6},{.1,-.5},{
  748. 0.,0.},{0.,0.},{0.,0.},{.7,-.8},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{
  749. 0.,0.},{0.,0.},{.6,-.6},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{
  750. 0.,0.},{.7,-.6},{-.4,-.7},{.6,-.6},{0.,0.},{0.,0.},{0.,0.},{0.,0.}
  751. ,{.8,-.7},{-.4,-.7},{-.1,-.2},{.2,-.8},{.7,-.6},{.1,.4},{.6,-.6},{
  752. .7,-.8},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{
  753. 0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{-.9,.5},{-.4,-.7},
  754. {.6,-.6},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.1,-.5},{-.4,-.7},{.7,
  755. -.6},{.2,-.8},{-.9,.5},{.1,.4},{.6,-.6},{.7,-.8},{0.,0.},{0.,0.},{
  756. 0.,0.},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{0.,0.},{0.,0.},{0.,0.},{
  757. 0.,0.},{0.,0.},{0.,0.},{.6,-.6},{.7,-.6},{0.,0.},{0.,0.},{0.,0.},{
  758. 0.,0.},{0.,0.},{.6,-.6},{.7,-.6},{-.1,-.2},{.8,-.7},{0.,0.},{0.,
  759. 0.},{0.,0.} };
  760. static doublecomplex ct10y[112] /* was [7][4][4] */ = { {.6,-.6},{0.,
  761. 0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.7,-.8},{0.,0.},{0.,
  762. 0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.7,-.8},{-.4,-.7},{0.,0.},{
  763. 0.,0.},{0.,0.},{0.,0.},{0.,0.},{.7,-.8},{-.4,-.7},{-.1,-.9},{.2,
  764. -.8},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{0.,0.},{0.,0.},{0.,0.},{0.,
  765. 0.},{0.,0.},{0.,0.},{.7,-.8},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,
  766. 0.},{0.,0.},{-.1,-.9},{-.9,.5},{.7,-.8},{0.,0.},{0.,0.},{0.,0.},{
  767. 0.,0.},{-.6,.6},{-.9,.5},{-.9,-.4},{.1,-.5},{-.1,-.9},{-.5,-.3},{
  768. .7,-.8},{.6,-.6},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{
  769. .7,-.8},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{-.1,-.9},
  770. {.7,-.8},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{-.6,.6},{-.9,
  771. -.4},{-.1,-.9},{.7,-.8},{0.,0.},{0.,0.},{0.,0.},{.6,-.6},{0.,0.},{
  772. 0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{.7,-.8},{0.,0.},{0.,0.},{
  773. 0.,0.},{0.,0.},{0.,0.},{0.,0.},{.7,-.8},{-.9,.5},{-.4,-.7},{0.,0.}
  774. ,{0.,0.},{0.,0.},{0.,0.},{.7,-.8},{-.9,.5},{-.4,-.7},{.1,-.5},{
  775. -.1,-.9},{-.5,-.3},{.2,-.8} };
  776. static doublecomplex csize1[4] = { {0.,0.},{.9,.9},{1.63,1.73},{2.9,2.78}
  777. };
  778. static doublecomplex csize3[14] = { {0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,
  779. 0.},{0.,0.},{0.,0.},{1.17,1.17},{1.17,1.17},{1.17,1.17},{1.17,
  780. 1.17},{1.17,1.17},{1.17,1.17},{1.17,1.17} };
  781. static doublecomplex csize2[14] /* was [7][2] */ = { {0.,0.},{0.,0.},{
  782. 0.,0.},{0.,0.},{0.,0.},{0.,0.},{0.,0.},{1.54,1.54},{1.54,1.54},{
  783. 1.54,1.54},{1.54,1.54},{1.54,1.54},{1.54,1.54},{1.54,1.54} };
  784. /* System generated locals */
  785. integer i__1, i__2;
  786. /* Local variables */
  787. static doublecomplex cdot[1];
  788. static integer lenx, leny, i__;
  789. extern /* Subroutine */ int ctest_();
  790. static integer ksize;
  791. static doublecomplex ztemp;
  792. extern /* Subroutine */ int zdotctest_(), zcopytest_();
  793. static integer ki;
  794. extern /* Subroutine */ int zdotutest_(), zswaptest_();
  795. static integer kn;
  796. extern /* Subroutine */ int zaxpytest_();
  797. static doublecomplex cx[7], cy[7];
  798. static integer mx, my;
  799. /* .. Parameters .. */
  800. /* .. Scalar Arguments .. */
  801. /* .. Scalars in Common .. */
  802. /* .. Local Scalars .. */
  803. /* .. Local Arrays .. */
  804. /* .. External Functions .. */
  805. /* .. External Subroutines .. */
  806. /* .. Intrinsic Functions .. */
  807. /* .. Common blocks .. */
  808. /* .. Data statements .. */
  809. /* .. Executable Statements .. */
  810. for (ki = 1; ki <= 4; ++ki) {
  811. combla_1.incx = incxs[ki - 1];
  812. combla_1.incy = incys[ki - 1];
  813. mx = abs(combla_1.incx);
  814. my = abs(combla_1.incy);
  815. for (kn = 1; kn <= 4; ++kn) {
  816. combla_1.n = ns[kn - 1];
  817. ksize = f2cmin(2,kn);
  818. lenx = lens[kn + (mx << 2) - 5];
  819. leny = lens[kn + (my << 2) - 5];
  820. /* .. initialize all argument arrays .. */
  821. for (i__ = 1; i__ <= 7; ++i__) {
  822. i__1 = i__ - 1;
  823. i__2 = i__ - 1;
  824. cx[i__1].r = cx1[i__2].r, cx[i__1].i = cx1[i__2].i;
  825. i__1 = i__ - 1;
  826. i__2 = i__ - 1;
  827. cy[i__1].r = cy1[i__2].r, cy[i__1].i = cy1[i__2].i;
  828. /* L20: */
  829. }
  830. if (combla_1.icase == 1) {
  831. /* .. ZDOTCTEST .. */
  832. zdotctest_(&combla_1.n, cx, &combla_1.incx, cy, &
  833. combla_1.incy, &ztemp);
  834. cdot[0].r = ztemp.r, cdot[0].i = ztemp.i;
  835. ctest_(&c__1, cdot, &ct6[kn + (ki << 2) - 5], &csize1[kn - 1],
  836. sfac);
  837. } else if (combla_1.icase == 2) {
  838. /* .. ZDOTUTEST .. */
  839. zdotutest_(&combla_1.n, cx, &combla_1.incx, cy, &
  840. combla_1.incy, &ztemp);
  841. cdot[0].r = ztemp.r, cdot[0].i = ztemp.i;
  842. ctest_(&c__1, cdot, &ct7[kn + (ki << 2) - 5], &csize1[kn - 1],
  843. sfac);
  844. } else if (combla_1.icase == 3) {
  845. /* .. ZAXPYTEST .. */
  846. zaxpytest_(&combla_1.n, &ca, cx, &combla_1.incx, cy, &
  847. combla_1.incy);
  848. ctest_(&leny, cy, &ct8[(kn + (ki << 2)) * 7 - 35], &csize2[
  849. ksize * 7 - 7], sfac);
  850. } else if (combla_1.icase == 4) {
  851. /* .. ZCOPYTEST .. */
  852. zcopytest_(&combla_1.n, cx, &combla_1.incx, cy, &
  853. combla_1.incy);
  854. ctest_(&leny, cy, &ct10y[(kn + (ki << 2)) * 7 - 35], csize3, &
  855. c_b43);
  856. } else if (combla_1.icase == 5) {
  857. /* .. ZSWAPTEST .. */
  858. zswaptest_(&combla_1.n, cx, &combla_1.incx, cy, &
  859. combla_1.incy);
  860. ctest_(&lenx, cx, &ct10x[(kn + (ki << 2)) * 7 - 35], csize3, &
  861. c_b43);
  862. ctest_(&leny, cy, &ct10y[(kn + (ki << 2)) * 7 - 35], csize3, &
  863. c_b43);
  864. } else {
  865. fprintf(stderr,"Shouldn't be here in CHECK2\n");
  866. exit(0);
  867. }
  868. /* L40: */
  869. }
  870. /* L60: */
  871. }
  872. return 0;
  873. } /* check2_ */
  874. /* Subroutine */ int stest_(len, scomp, strue, ssize, sfac)
  875. integer *len;
  876. doublereal *scomp, *strue, *ssize, *sfac;
  877. {
  878. /* System generated locals */
  879. integer i__1;
  880. doublereal d__1, d__2, d__3, d__4, d__5;
  881. /* Builtin functions */
  882. integer s_wsfe(), e_wsfe(), do_fio();
  883. /* Local variables */
  884. static integer i__;
  885. extern doublereal sdiff_();
  886. static doublereal sd;
  887. /* ********************************* STEST ************************** */
  888. /* THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO */
  889. /* SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE */
  890. /* NEGLIGIBLE. */
  891. /* C. L. LAWSON, JPL, 1974 DEC 10 */
  892. /* .. Parameters .. */
  893. /* .. Scalar Arguments .. */
  894. /* .. Array Arguments .. */
  895. /* .. Scalars in Common .. */
  896. /* .. Local Scalars .. */
  897. /* .. External Functions .. */
  898. /* .. Intrinsic Functions .. */
  899. /* .. Common blocks .. */
  900. /* .. Executable Statements .. */
  901. /* Parameter adjustments */
  902. --ssize;
  903. --strue;
  904. --scomp;
  905. /* Function Body */
  906. i__1 = *len;
  907. for (i__ = 1; i__ <= i__1; ++i__) {
  908. sd = scomp[i__] - strue[i__];
  909. d__4 = (d__1 = ssize[i__], abs(d__1)) + (d__2 = *sfac * sd, abs(d__2))
  910. ;
  911. d__5 = (d__3 = ssize[i__], abs(d__3));
  912. if (sdiff_(&d__4, &d__5) == 0.) {
  913. goto L40;
  914. }
  915. /* HERE SCOMP(I) IS NOT CLOSE TO STRUE(I). */
  916. if (! combla_1.pass) {
  917. goto L20;
  918. }
  919. /* PRINT FAIL MESSAGE AND HEADER. */
  920. combla_1.pass = FALSE_;
  921. printf(" FAIL\n");
  922. printf("CASE N INCX INCY MODE I COMP(I) TRUE(I) DIFFERENCE SIZE(I)\n");
  923. L20:
  924. printf("%4d %3d %5d %5d %5d %3d %36.8f %36.8f %12.4f %12.4f\n",combla_1.icase, combla_1.n, combla_1.incx, combla_1.incy,
  925. combla_1.mode, i__, scomp[i__], strue[i__], sd, ssize[i__]);
  926. L40:
  927. ;
  928. }
  929. return 0;
  930. } /* stest_ */
  931. /* Subroutine */ int stest1_(scomp1, strue1, ssize, sfac)
  932. doublereal *scomp1, *strue1, *ssize, *sfac;
  933. {
  934. static doublereal scomp[1], strue[1];
  935. extern /* Subroutine */ int stest_();
  936. /* ************************* STEST1 ***************************** */
  937. /* THIS IS AN INTERFACE SUBROUTINE TO ACCOMMODATE THE FORTRAN */
  938. /* REQUIREMENT THAT WHEN A DUMMY ARGUMENT IS AN ARRAY, THE */
  939. /* ACTUAL ARGUMENT MUST ALSO BE AN ARRAY OR AN ARRAY ELEMENT. */
  940. /* C.L. LAWSON, JPL, 1978 DEC 6 */
  941. /* .. Scalar Arguments .. */
  942. /* .. Array Arguments .. */
  943. /* .. Local Arrays .. */
  944. /* .. External Subroutines .. */
  945. /* .. Executable Statements .. */
  946. /* Parameter adjustments */
  947. --ssize;
  948. /* Function Body */
  949. scomp[0] = *scomp1;
  950. strue[0] = *strue1;
  951. stest_(&c__1, scomp, strue, &ssize[1], sfac);
  952. return 0;
  953. } /* stest1_ */
  954. doublereal sdiff_(sa, sb)
  955. doublereal *sa, *sb;
  956. {
  957. /* System generated locals */
  958. doublereal ret_val;
  959. /* ********************************* SDIFF ************************** */
  960. /* COMPUTES DIFFERENCE OF TWO NUMBERS. C. L. LAWSON, JPL 1974 FEB 15 */
  961. /* .. Scalar Arguments .. */
  962. /* .. Executable Statements .. */
  963. ret_val = *sa - *sb;
  964. return ret_val;
  965. } /* sdiff_ */
  966. /* Subroutine */ int ctest_(len, ccomp, ctrue, csize, sfac)
  967. integer *len;
  968. doublecomplex *ccomp, *ctrue, *csize;
  969. doublereal *sfac;
  970. {
  971. /* System generated locals */
  972. integer i__1, i__2;
  973. /* Local variables */
  974. static integer i__;
  975. static doublereal scomp[20], ssize[20], strue[20];
  976. extern /* Subroutine */ int stest_();
  977. /* **************************** CTEST ***************************** */
  978. /* C.L. LAWSON, JPL, 1978 DEC 6 */
  979. /* .. Scalar Arguments .. */
  980. /* .. Array Arguments .. */
  981. /* .. Local Scalars .. */
  982. /* .. Local Arrays .. */
  983. /* .. External Subroutines .. */
  984. /* .. Intrinsic Functions .. */
  985. /* .. Executable Statements .. */
  986. /* Parameter adjustments */
  987. --csize;
  988. --ctrue;
  989. --ccomp;
  990. /* Function Body */
  991. i__1 = *len;
  992. for (i__ = 1; i__ <= i__1; ++i__) {
  993. i__2 = i__;
  994. scomp[(i__ << 1) - 2] = ccomp[i__2].r;
  995. scomp[(i__ << 1) - 1] = d_imag(&ccomp[i__]);
  996. i__2 = i__;
  997. strue[(i__ << 1) - 2] = ctrue[i__2].r;
  998. strue[(i__ << 1) - 1] = d_imag(&ctrue[i__]);
  999. i__2 = i__;
  1000. ssize[(i__ << 1) - 2] = csize[i__2].r;
  1001. ssize[(i__ << 1) - 1] = d_imag(&csize[i__]);
  1002. /* L20: */
  1003. }
  1004. i__1 = *len << 1;
  1005. stest_(&i__1, scomp, strue, ssize, sfac);
  1006. return 0;
  1007. } /* ctest_ */
  1008. /* Subroutine */ int itest1_(icomp, itrue)
  1009. integer *icomp, *itrue;
  1010. {
  1011. static integer id;
  1012. /* ********************************* ITEST1 ************************* */
  1013. /* THIS SUBROUTINE COMPARES THE VARIABLES ICOMP AND ITRUE FOR */
  1014. /* EQUALITY. */
  1015. /* C. L. LAWSON, JPL, 1974 DEC 10 */
  1016. /* .. Parameters .. */
  1017. /* .. Scalar Arguments .. */
  1018. /* .. Scalars in Common .. */
  1019. /* .. Local Scalars .. */
  1020. /* .. Common blocks .. */
  1021. /* .. Executable Statements .. */
  1022. if (*icomp == *itrue) {
  1023. goto L40;
  1024. }
  1025. /* HERE ICOMP IS NOT EQUAL TO ITRUE. */
  1026. if (! combla_1.pass) {
  1027. goto L20;
  1028. }
  1029. /* PRINT FAIL MESSAGE AND HEADER. */
  1030. combla_1.pass = FALSE_;
  1031. printf(" FAIL\n");
  1032. printf("CASE N INCX INCY MODE COMP TRUE DIFFERENCE\n");
  1033. L20:
  1034. id = *icomp - *itrue;
  1035. printf("%4d %3d %5d %5d %5d %36d %36d %12d\n",combla_1.icase, combla_1.n, combla_1.incx, combla_1.incy,
  1036. combla_1.mode, *icomp, *itrue, id);
  1037. L40:
  1038. return 0;
  1039. } /* itest1_ */