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_cblat1c.c 46 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  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 real c_b43 = (float)1.;
  477. /* Main program */ int main()
  478. {
  479. /* Initialized data */
  480. static real sfac = (float)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 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_CDOTC " , "CBLAS_CDOTU " , "CBLAS_CAXPY " ,
  524. "CBLAS_CCOPY " , "CBLAS_CSWAP " , "CBLAS_SCNRM2" , "CBLAS_SCASUM" , "CBLAS_CSCAL " ,
  525. "CBLAS_CSSCAL" , "CBLAS_ICAMAX" };
  526. /* Format strings */
  527. /* Builtin functions */
  528. integer s_wsfe(), do_fio(), e_wsfe();
  529. /* .. Parameters .. */
  530. /* .. Scalars in Common .. */
  531. /* .. Local Arrays .. */
  532. /* .. Common blocks .. */
  533. /* .. Data statements .. */
  534. /* .. Executable Statements .. */
  535. printf("Test of subprogram number %3d %15s", combla_1.icase, l[combla_1.icase - 1]);
  536. return 0;
  537. } /* header_ */
  538. /* Subroutine */ int check1_(sfac)
  539. real *sfac;
  540. {
  541. /* Initialized data */
  542. static real strue2[5] = { (float)0.,(float).5,(float).6,(float).7,(float)
  543. .7 };
  544. static real strue4[5] = { (float)0.,(float).7,(float)1.,(float)1.3,(float)
  545. 1.7 };
  546. static complex ctrue5[80] /* was [8][5][2] */ = { {(float).1,(float).1},
  547. {(float)1.,(float)2.},{(float)1.,(float)2.},{(float)1.,(float)2.},
  548. {(float)1.,(float)2.},{(float)1.,(float)2.},{(float)1.,(float)2.},
  549. {(float)1.,(float)2.},{(float)-.16,(float)-.37},{(float)3.,(float)
  550. 4.},{(float)3.,(float)4.},{(float)3.,(float)4.},{(float)3.,(float)
  551. 4.},{(float)3.,(float)4.},{(float)3.,(float)4.},{(float)3.,(float)
  552. 4.},{(float)-.17,(float)-.19},{(float).13,(float)-.39},{(float)5.,
  553. (float)6.},{(float)5.,(float)6.},{(float)5.,(float)6.},{(float)5.,
  554. (float)6.},{(float)5.,(float)6.},{(float)5.,(float)6.},{(float)
  555. .11,(float)-.03},{(float)-.17,(float).46},{(float)-.17,(float)
  556. -.19},{(float)7.,(float)8.},{(float)7.,(float)8.},{(float)7.,(
  557. float)8.},{(float)7.,(float)8.},{(float)7.,(float)8.},{(float).19,
  558. (float)-.17},{(float).32,(float).09},{(float).23,(float)-.24},{(
  559. float).18,(float).01},{(float)2.,(float)3.},{(float)2.,(float)3.},
  560. {(float)2.,(float)3.},{(float)2.,(float)3.},{(float).1,(float).1},
  561. {(float)4.,(float)5.},{(float)4.,(float)5.},{(float)4.,(float)5.},
  562. {(float)4.,(float)5.},{(float)4.,(float)5.},{(float)4.,(float)5.},
  563. {(float)4.,(float)5.},{(float)-.16,(float)-.37},{(float)6.,(float)
  564. 7.},{(float)6.,(float)7.},{(float)6.,(float)7.},{(float)6.,(float)
  565. 7.},{(float)6.,(float)7.},{(float)6.,(float)7.},{(float)6.,(float)
  566. 7.},{(float)-.17,(float)-.19},{(float)8.,(float)9.},{(float).13,(
  567. float)-.39},{(float)2.,(float)5.},{(float)2.,(float)5.},{(float)
  568. 2.,(float)5.},{(float)2.,(float)5.},{(float)2.,(float)5.},{(float)
  569. .11,(float)-.03},{(float)3.,(float)6.},{(float)-.17,(float).46},{(
  570. float)4.,(float)7.},{(float)-.17,(float)-.19},{(float)7.,(float)
  571. 2.},{(float)7.,(float)2.},{(float)7.,(float)2.},{(float).19,(
  572. float)-.17},{(float)5.,(float)8.},{(float).32,(float).09},{(float)
  573. 6.,(float)9.},{(float).23,(float)-.24},{(float)8.,(float)3.},{(
  574. float).18,(float).01},{(float)9.,(float)4.} };
  575. static complex ctrue6[80] /* was [8][5][2] */ = { {(float).1,(float).1},
  576. {(float)1.,(float)2.},{(float)1.,(float)2.},{(float)1.,(float)2.},
  577. {(float)1.,(float)2.},{(float)1.,(float)2.},{(float)1.,(float)2.},
  578. {(float)1.,(float)2.},{(float).09,(float)-.12},{(float)3.,(float)
  579. 4.},{(float)3.,(float)4.},{(float)3.,(float)4.},{(float)3.,(float)
  580. 4.},{(float)3.,(float)4.},{(float)3.,(float)4.},{(float)3.,(float)
  581. 4.},{(float).03,(float)-.09},{(float).15,(float)-.03},{(float)5.,(
  582. float)6.},{(float)5.,(float)6.},{(float)5.,(float)6.},{(float)5.,(
  583. float)6.},{(float)5.,(float)6.},{(float)5.,(float)6.},{(float).03,
  584. (float).03},{(float)-.18,(float).03},{(float).03,(float)-.09},{(
  585. float)7.,(float)8.},{(float)7.,(float)8.},{(float)7.,(float)8.},{(
  586. float)7.,(float)8.},{(float)7.,(float)8.},{(float).09,(float).03},
  587. {(float).03,(float).12},{(float).12,(float).03},{(float).03,(
  588. float).06},{(float)2.,(float)3.},{(float)2.,(float)3.},{(float)2.,
  589. (float)3.},{(float)2.,(float)3.},{(float).1,(float).1},{(float)4.,
  590. (float)5.},{(float)4.,(float)5.},{(float)4.,(float)5.},{(float)4.,
  591. (float)5.},{(float)4.,(float)5.},{(float)4.,(float)5.},{(float)4.,
  592. (float)5.},{(float).09,(float)-.12},{(float)6.,(float)7.},{(float)
  593. 6.,(float)7.},{(float)6.,(float)7.},{(float)6.,(float)7.},{(float)
  594. 6.,(float)7.},{(float)6.,(float)7.},{(float)6.,(float)7.},{(float)
  595. .03,(float)-.09},{(float)8.,(float)9.},{(float).15,(float)-.03},{(
  596. float)2.,(float)5.},{(float)2.,(float)5.},{(float)2.,(float)5.},{(
  597. float)2.,(float)5.},{(float)2.,(float)5.},{(float).03,(float).03},
  598. {(float)3.,(float)6.},{(float)-.18,(float).03},{(float)4.,(float)
  599. 7.},{(float).03,(float)-.09},{(float)7.,(float)2.},{(float)7.,(
  600. float)2.},{(float)7.,(float)2.},{(float).09,(float).03},{(float)
  601. 5.,(float)8.},{(float).03,(float).12},{(float)6.,(float)9.},{(
  602. float).12,(float).03},{(float)8.,(float)3.},{(float).03,(float)
  603. .06},{(float)9.,(float)4.} };
  604. static integer itrue3[5] = { 0,1,2,2,2 };
  605. static real sa = (float).3;
  606. static complex ca = {(float).4,(float)-.7};
  607. static complex cv[80] /* was [8][5][2] */ = { {(float).1,(float).1},
  608. {(float)1.,(float)2.},{(float)1.,(float)2.},{(float)1.,(float)2.},
  609. {(float)1.,(float)2.},{(float)1.,(float)2.},{(float)1.,(float)2.},
  610. {(float)1.,(float)2.},{(float).3,(float)-.4},{(float)3.,(float)4.}
  611. ,{(float)3.,(float)4.},{(float)3.,(float)4.},{(float)3.,(float)4.}
  612. ,{(float)3.,(float)4.},{(float)3.,(float)4.},{(float)3.,(float)4.}
  613. ,{(float).1,(float)-.3},{(float).5,(float)-.1},{(float)5.,(float)
  614. 6.},{(float)5.,(float)6.},{(float)5.,(float)6.},{(float)5.,(float)
  615. 6.},{(float)5.,(float)6.},{(float)5.,(float)6.},{(float).1,(float)
  616. .1},{(float)-.6,(float).1},{(float).1,(float)-.3},{(float)7.,(
  617. float)8.},{(float)7.,(float)8.},{(float)7.,(float)8.},{(float)7.,(
  618. float)8.},{(float)7.,(float)8.},{(float).3,(float).1},{(float).1,(
  619. float).4},{(float).4,(float).1},{(float).1,(float).2},{(float)2.,(
  620. float)3.},{(float)2.,(float)3.},{(float)2.,(float)3.},{(float)2.,(
  621. float)3.},{(float).1,(float).1},{(float)4.,(float)5.},{(float)4.,(
  622. float)5.},{(float)4.,(float)5.},{(float)4.,(float)5.},{(float)4.,(
  623. float)5.},{(float)4.,(float)5.},{(float)4.,(float)5.},{(float).3,(
  624. float)-.4},{(float)6.,(float)7.},{(float)6.,(float)7.},{(float)6.,
  625. (float)7.},{(float)6.,(float)7.},{(float)6.,(float)7.},{(float)6.,
  626. (float)7.},{(float)6.,(float)7.},{(float).1,(float)-.3},{(float)
  627. 8.,(float)9.},{(float).5,(float)-.1},{(float)2.,(float)5.},{(
  628. float)2.,(float)5.},{(float)2.,(float)5.},{(float)2.,(float)5.},{(
  629. float)2.,(float)5.},{(float).1,(float).1},{(float)3.,(float)6.},{(
  630. float)-.6,(float).1},{(float)4.,(float)7.},{(float).1,(float)-.3},
  631. {(float)7.,(float)2.},{(float)7.,(float)2.},{(float)7.,(float)2.},
  632. {(float).3,(float).1},{(float)5.,(float)8.},{(float).1,(float).4},
  633. {(float)6.,(float)9.},{(float).4,(float).1},{(float)8.,(float)3.},
  634. {(float).1,(float).2},{(float)9.,(float)4.} };
  635. /* System generated locals */
  636. integer i__1, i__2, i__3;
  637. real r__1;
  638. complex q__1;
  639. /* Local variables */
  640. static integer i__;
  641. extern /* Subroutine */ int ctest_();
  642. static complex mwpcs[5], mwpct[5];
  643. extern /* Subroutine */ int itest1_(), stest1_();
  644. static complex cx[8];
  645. extern real scnrm2test_();
  646. static integer np1;
  647. extern integer icamaxtest_();
  648. extern /* Subroutine */ int csscaltest_();
  649. extern real scasumtest_();
  650. static integer len;
  651. /* .. Parameters .. */
  652. /* .. Scalar Arguments .. */
  653. /* .. Scalars in Common .. */
  654. /* .. Local Scalars .. */
  655. /* .. Local Arrays .. */
  656. /* .. External Functions .. */
  657. /* .. External Subroutines .. */
  658. /* .. Intrinsic Functions .. */
  659. /* .. Common blocks .. */
  660. /* .. Data statements .. */
  661. /* .. Executable Statements .. */
  662. for (combla_1.incx = 1; combla_1.incx <= 2; ++combla_1.incx) {
  663. for (np1 = 1; np1 <= 5; ++np1) {
  664. combla_1.n = np1 - 1;
  665. len = f2cmax(combla_1.n,1) << 1;
  666. /* .. Set vector arguments .. */
  667. i__1 = len;
  668. for (i__ = 1; i__ <= i__1; ++i__) {
  669. i__2 = i__ - 1;
  670. i__3 = i__ + (np1 + combla_1.incx * 5 << 3) - 49;
  671. cx[i__2].r = cv[i__3].r, cx[i__2].i = cv[i__3].i;
  672. /* L20: */
  673. }
  674. if (combla_1.icase == 6) {
  675. /* .. SCNRM2TEST .. */
  676. r__1 = scnrm2test_(&combla_1.n, cx, &combla_1.incx);
  677. stest1_(&r__1, &strue2[np1 - 1], &strue2[np1 - 1], sfac);
  678. } else if (combla_1.icase == 7) {
  679. /* .. SCASUMTEST .. */
  680. r__1 = scasumtest_(&combla_1.n, cx, &combla_1.incx);
  681. stest1_(&r__1, &strue4[np1 - 1], &strue4[np1 - 1], sfac);
  682. } else if (combla_1.icase == 8) {
  683. /* .. CSCAL .. */
  684. cscal_(&combla_1.n, &ca, cx, &combla_1.incx);
  685. ctest_(&len, cx, &ctrue5[(np1 + combla_1.incx * 5 << 3) - 48],
  686. &ctrue5[(np1 + combla_1.incx * 5 << 3) - 48], sfac);
  687. } else if (combla_1.icase == 9) {
  688. /* .. CSSCALTEST .. */
  689. csscaltest_(&combla_1.n, &sa, cx, &combla_1.incx);
  690. ctest_(&len, cx, &ctrue6[(np1 + combla_1.incx * 5 << 3) - 48],
  691. &ctrue6[(np1 + combla_1.incx * 5 << 3) - 48], sfac);
  692. } else if (combla_1.icase == 10) {
  693. /* .. ICAMAXTEST .. */
  694. i__1 = icamaxtest_(&combla_1.n, cx, &combla_1.incx);
  695. itest1_(&i__1, &itrue3[np1 - 1]);
  696. } else {
  697. fprintf(stderr,"Shouldn't be here in CHECK1\n");
  698. exit(0);
  699. }
  700. /* L40: */
  701. }
  702. /* L60: */
  703. }
  704. combla_1.incx = 1;
  705. if (combla_1.icase == 8) {
  706. /* CSCAL */
  707. /* Add a test for alpha equal to zero. */
  708. ca.r = (float)0., ca.i = (float)0.;
  709. for (i__ = 1; i__ <= 5; ++i__) {
  710. i__1 = i__ - 1;
  711. mwpct[i__1].r = (float)0., mwpct[i__1].i = (float)0.;
  712. i__1 = i__ - 1;
  713. mwpcs[i__1].r = (float)1., mwpcs[i__1].i = (float)1.;
  714. /* L80: */
  715. }
  716. cscal_(&c__5, &ca, cx, &combla_1.incx);
  717. ctest_(&c__5, cx, mwpct, mwpcs, sfac);
  718. } else if (combla_1.icase == 9) {
  719. /* CSSCALTEST */
  720. /* Add a test for alpha equal to zero. */
  721. sa = (float)0.;
  722. for (i__ = 1; i__ <= 5; ++i__) {
  723. i__1 = i__ - 1;
  724. mwpct[i__1].r = (float)0., mwpct[i__1].i = (float)0.;
  725. i__1 = i__ - 1;
  726. mwpcs[i__1].r = (float)1., mwpcs[i__1].i = (float)1.;
  727. /* L100: */
  728. }
  729. csscaltest_(&c__5, &sa, cx, &combla_1.incx);
  730. ctest_(&c__5, cx, mwpct, mwpcs, sfac);
  731. /* Add a test for alpha equal to one. */
  732. sa = (float)1.;
  733. for (i__ = 1; i__ <= 5; ++i__) {
  734. i__1 = i__ - 1;
  735. i__2 = i__ - 1;
  736. mwpct[i__1].r = cx[i__2].r, mwpct[i__1].i = cx[i__2].i;
  737. i__1 = i__ - 1;
  738. i__2 = i__ - 1;
  739. mwpcs[i__1].r = cx[i__2].r, mwpcs[i__1].i = cx[i__2].i;
  740. /* L120: */
  741. }
  742. csscaltest_(&c__5, &sa, cx, &combla_1.incx);
  743. ctest_(&c__5, cx, mwpct, mwpcs, sfac);
  744. /* Add a test for alpha equal to minus one. */
  745. sa = (float)-1.;
  746. for (i__ = 1; i__ <= 5; ++i__) {
  747. i__1 = i__ - 1;
  748. i__2 = i__ - 1;
  749. q__1.r = -cx[i__2].r, q__1.i = -cx[i__2].i;
  750. mwpct[i__1].r = q__1.r, mwpct[i__1].i = q__1.i;
  751. i__1 = i__ - 1;
  752. i__2 = i__ - 1;
  753. q__1.r = -cx[i__2].r, q__1.i = -cx[i__2].i;
  754. mwpcs[i__1].r = q__1.r, mwpcs[i__1].i = q__1.i;
  755. /* L140: */
  756. }
  757. csscaltest_(&c__5, &sa, cx, &combla_1.incx);
  758. ctest_(&c__5, cx, mwpct, mwpcs, sfac);
  759. }
  760. return 0;
  761. } /* check1_ */
  762. /* Subroutine */ int check2_(sfac)
  763. real *sfac;
  764. {
  765. /* Initialized data */
  766. static complex ca = {(float).4,(float)-.7};
  767. static integer incxs[4] = { 1,2,-2,-1 };
  768. static integer incys[4] = { 1,-2,1,-2 };
  769. static integer lens[8] /* was [4][2] */ = { 1,1,2,4,1,1,3,7 };
  770. static integer ns[4] = { 0,1,2,4 };
  771. static complex cx1[7] = { {(float).7,(float)-.8},{(float)-.4,(float)-.7},{
  772. (float)-.1,(float)-.9},{(float).2,(float)-.8},{(float)-.9,(float)
  773. -.4},{(float).1,(float).4},{(float)-.6,(float).6} };
  774. static complex cy1[7] = { {(float).6,(float)-.6},{(float)-.9,(float).5},{(
  775. float).7,(float)-.6},{(float).1,(float)-.5},{(float)-.1,(float)
  776. -.2},{(float)-.5,(float)-.3},{(float).8,(float)-.7} };
  777. static complex ct8[112] /* was [7][4][4] */ = { {(float).6,(float)-.6}
  778. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  779. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  780. ,{(float).32,(float)-1.41},{(float)0.,(float)0.},{(float)0.,(
  781. float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  782. float)0.},{(float)0.,(float)0.},{(float).32,(float)-1.41},{(float)
  783. -1.55,(float).5},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  784. float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  785. float).32,(float)-1.41},{(float)-1.55,(float).5},{(float).03,(
  786. float)-.89},{(float)-.38,(float)-.96},{(float)0.,(float)0.},{(
  787. float)0.,(float)0.},{(float)0.,(float)0.},{(float).6,(float)-.6},{
  788. (float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{
  789. (float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{
  790. (float).32,(float)-1.41},{(float)0.,(float)0.},{(float)0.,(float)
  791. 0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)
  792. 0.},{(float)0.,(float)0.},{(float)-.07,(float)-.89},{(float)-.9,(
  793. float).5},{(float).42,(float)-1.41},{(float)0.,(float)0.},{(float)
  794. 0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)
  795. .78,(float).06},{(float)-.9,(float).5},{(float).06,(float)-.13},{(
  796. float).1,(float)-.5},{(float)-.77,(float)-.49},{(float)-.5,(float)
  797. -.3},{(float).52,(float)-1.51},{(float).6,(float)-.6},{(float)0.,(
  798. float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  799. float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float).32,
  800. (float)-1.41},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)
  801. 0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)
  802. 0.,(float)0.},{(float)-.07,(float)-.89},{(float)-1.18,(float)-.31}
  803. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  804. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float).78,(float)
  805. .06},{(float)-1.54,(float).97},{(float).03,(float)-.89},{(float)
  806. -.18,(float)-1.31},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  807. float)0.,(float)0.},{(float).6,(float)-.6},{(float)0.,(float)0.},{
  808. (float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{
  809. (float)0.,(float)0.},{(float)0.,(float)0.},{(float).32,(float)
  810. -1.41},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  811. float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  812. float)0.},{(float).32,(float)-1.41},{(float)-.9,(float).5},{(
  813. float).05,(float)-.6},{(float)0.,(float)0.},{(float)0.,(float)0.},
  814. {(float)0.,(float)0.},{(float)0.,(float)0.},{(float).32,(float)
  815. -1.41},{(float)-.9,(float).5},{(float).05,(float)-.6},{(float).1,(
  816. float)-.5},{(float)-.77,(float)-.49},{(float)-.5,(float)-.3},{(
  817. float).32,(float)-1.16} };
  818. static complex ct7[16] /* was [4][4] */ = { {(float)0.,(float)0.},{(
  819. float)-.06,(float)-.9},{(float).65,(float)-.47},{(float)-.34,(
  820. float)-1.22},{(float)0.,(float)0.},{(float)-.06,(float)-.9},{(
  821. float)-.59,(float)-1.46},{(float)-1.04,(float)-.04},{(float)0.,(
  822. float)0.},{(float)-.06,(float)-.9},{(float)-.83,(float).59},{(
  823. float).07,(float)-.37},{(float)0.,(float)0.},{(float)-.06,(float)
  824. -.9},{(float)-.76,(float)-1.15},{(float)-1.33,(float)-1.82} };
  825. static complex ct6[16] /* was [4][4] */ = { {(float)0.,(float)0.},{(
  826. float).9,(float).06},{(float).91,(float)-.77},{(float)1.8,(float)
  827. -.1},{(float)0.,(float)0.},{(float).9,(float).06},{(float)1.45,(
  828. float).74},{(float).2,(float).9},{(float)0.,(float)0.},{(float).9,
  829. (float).06},{(float)-.55,(float).23},{(float).83,(float)-.39},{(
  830. float)0.,(float)0.},{(float).9,(float).06},{(float)1.04,(float)
  831. .79},{(float)1.95,(float)1.22} };
  832. static complex ct10x[112] /* was [7][4][4] */ = { {(float).7,(float)-.8}
  833. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  834. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  835. ,{(float).6,(float)-.6},{(float)0.,(float)0.},{(float)0.,(float)
  836. 0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)
  837. 0.},{(float)0.,(float)0.},{(float).6,(float)-.6},{(float)-.9,(
  838. float).5},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  839. float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float).6,(
  840. float)-.6},{(float)-.9,(float).5},{(float).7,(float)-.6},{(float)
  841. .1,(float)-.5},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  842. float)0.,(float)0.},{(float).7,(float)-.8},{(float)0.,(float)0.},{
  843. (float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{
  844. (float)0.,(float)0.},{(float)0.,(float)0.},{(float).6,(float)-.6},
  845. {(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},
  846. {(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},
  847. {(float).7,(float)-.6},{(float)-.4,(float)-.7},{(float).6,(float)
  848. -.6},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  849. float)0.},{(float)0.,(float)0.},{(float).8,(float)-.7},{(float)
  850. -.4,(float)-.7},{(float)-.1,(float)-.2},{(float).2,(float)-.8},{(
  851. float).7,(float)-.6},{(float).1,(float).4},{(float).6,(float)-.6},
  852. {(float).7,(float)-.8},{(float)0.,(float)0.},{(float)0.,(float)0.}
  853. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  854. ,{(float)0.,(float)0.},{(float).6,(float)-.6},{(float)0.,(float)
  855. 0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)
  856. 0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)-.9,(
  857. float).5},{(float)-.4,(float)-.7},{(float).6,(float)-.6},{(float)
  858. 0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)
  859. 0.,(float)0.},{(float).1,(float)-.5},{(float)-.4,(float)-.7},{(
  860. float).7,(float)-.6},{(float).2,(float)-.8},{(float)-.9,(float).5}
  861. ,{(float).1,(float).4},{(float).6,(float)-.6},{(float).7,(float)
  862. -.8},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  863. float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  864. float)0.},{(float).6,(float)-.6},{(float)0.,(float)0.},{(float)0.,
  865. (float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,
  866. (float)0.},{(float)0.,(float)0.},{(float).6,(float)-.6},{(float)
  867. .7,(float)-.6},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  868. float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  869. float).6,(float)-.6},{(float).7,(float)-.6},{(float)-.1,(float)
  870. -.2},{(float).8,(float)-.7},{(float)0.,(float)0.},{(float)0.,(
  871. float)0.},{(float)0.,(float)0.} };
  872. static complex ct10y[112] /* was [7][4][4] */ = { {(float).6,(float)-.6}
  873. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  874. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  875. ,{(float).7,(float)-.8},{(float)0.,(float)0.},{(float)0.,(float)
  876. 0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)
  877. 0.},{(float)0.,(float)0.},{(float).7,(float)-.8},{(float)-.4,(
  878. float)-.7},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,
  879. (float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float).7,
  880. (float)-.8},{(float)-.4,(float)-.7},{(float)-.1,(float)-.9},{(
  881. float).2,(float)-.8},{(float)0.,(float)0.},{(float)0.,(float)0.},{
  882. (float)0.,(float)0.},{(float).6,(float)-.6},{(float)0.,(float)0.},
  883. {(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},
  884. {(float)0.,(float)0.},{(float)0.,(float)0.},{(float).7,(float)-.8}
  885. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  886. ,{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.}
  887. ,{(float)-.1,(float)-.9},{(float)-.9,(float).5},{(float).7,(float)
  888. -.8},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  889. float)0.},{(float)0.,(float)0.},{(float)-.6,(float).6},{(float)
  890. -.9,(float).5},{(float)-.9,(float)-.4},{(float).1,(float)-.5},{(
  891. float)-.1,(float)-.9},{(float)-.5,(float)-.3},{(float).7,(float)
  892. -.8},{(float).6,(float)-.6},{(float)0.,(float)0.},{(float)0.,(
  893. float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  894. float)0.},{(float)0.,(float)0.},{(float).7,(float)-.8},{(float)0.,
  895. (float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,
  896. (float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)
  897. -.1,(float)-.9},{(float).7,(float)-.8},{(float)0.,(float)0.},{(
  898. float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  899. float)0.,(float)0.},{(float)-.6,(float).6},{(float)-.9,(float)-.4}
  900. ,{(float)-.1,(float)-.9},{(float).7,(float)-.8},{(float)0.,(float)
  901. 0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float).6,(float)
  902. -.6},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  903. float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(
  904. float)0.},{(float).7,(float)-.8},{(float)0.,(float)0.},{(float)0.,
  905. (float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,
  906. (float)0.},{(float)0.,(float)0.},{(float).7,(float)-.8},{(float)
  907. -.9,(float).5},{(float)-.4,(float)-.7},{(float)0.,(float)0.},{(
  908. float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  909. float).7,(float)-.8},{(float)-.9,(float).5},{(float)-.4,(float)
  910. -.7},{(float).1,(float)-.5},{(float)-.1,(float)-.9},{(float)-.5,(
  911. float)-.3},{(float).2,(float)-.8} };
  912. static complex csize1[4] = { {(float)0.,(float)0.},{(float).9,(float).9},{
  913. (float)1.63,(float)1.73},{(float)2.9,(float)2.78} };
  914. static complex csize3[14] = { {(float)0.,(float)0.},{(float)0.,(float)0.},
  915. {(float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},
  916. {(float)0.,(float)0.},{(float)0.,(float)0.},{(float)1.17,(float)
  917. 1.17},{(float)1.17,(float)1.17},{(float)1.17,(float)1.17},{(float)
  918. 1.17,(float)1.17},{(float)1.17,(float)1.17},{(float)1.17,(float)
  919. 1.17},{(float)1.17,(float)1.17} };
  920. static complex csize2[14] /* was [7][2] */ = { {(float)0.,(float)0.},{(
  921. float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  922. float)0.,(float)0.},{(float)0.,(float)0.},{(float)0.,(float)0.},{(
  923. float)1.54,(float)1.54},{(float)1.54,(float)1.54},{(float)1.54,(
  924. float)1.54},{(float)1.54,(float)1.54},{(float)1.54,(float)1.54},{(
  925. float)1.54,(float)1.54},{(float)1.54,(float)1.54} };
  926. /* System generated locals */
  927. integer i__1, i__2;
  928. /* Local variables */
  929. static complex cdot[1];
  930. static integer lenx, leny, i__;
  931. static complex ctemp;
  932. extern /* Subroutine */ int ctest_();
  933. static integer ksize;
  934. extern /* Subroutine */ int cdotctest_(), ccopytest_(), cdotutest_(),
  935. cswaptest_(), caxpytest_();
  936. static integer ki, kn;
  937. static complex cx[7], cy[7];
  938. static integer mx, my;
  939. /* .. Parameters .. */
  940. /* .. Scalar Arguments .. */
  941. /* .. Scalars in Common .. */
  942. /* .. Local Scalars .. */
  943. /* .. Local Arrays .. */
  944. /* .. External Functions .. */
  945. /* .. External Subroutines .. */
  946. /* .. Intrinsic Functions .. */
  947. /* .. Common blocks .. */
  948. /* .. Data statements .. */
  949. /* .. Executable Statements .. */
  950. for (ki = 1; ki <= 4; ++ki) {
  951. combla_1.incx = incxs[ki - 1];
  952. combla_1.incy = incys[ki - 1];
  953. mx = abs(combla_1.incx);
  954. my = abs(combla_1.incy);
  955. for (kn = 1; kn <= 4; ++kn) {
  956. combla_1.n = ns[kn - 1];
  957. ksize = f2cmin(2,kn);
  958. lenx = lens[kn + (mx << 2) - 5];
  959. leny = lens[kn + (my << 2) - 5];
  960. /* .. initialize all argument arrays .. */
  961. for (i__ = 1; i__ <= 7; ++i__) {
  962. i__1 = i__ - 1;
  963. i__2 = i__ - 1;
  964. cx[i__1].r = cx1[i__2].r, cx[i__1].i = cx1[i__2].i;
  965. i__1 = i__ - 1;
  966. i__2 = i__ - 1;
  967. cy[i__1].r = cy1[i__2].r, cy[i__1].i = cy1[i__2].i;
  968. /* L20: */
  969. }
  970. if (combla_1.icase == 1) {
  971. /* .. CDOTCTEST .. */
  972. cdotctest_(&combla_1.n, cx, &combla_1.incx, cy, &
  973. combla_1.incy, &ctemp);
  974. cdot[0].r = ctemp.r, cdot[0].i = ctemp.i;
  975. ctest_(&c__1, cdot, &ct6[kn + (ki << 2) - 5], &csize1[kn - 1],
  976. sfac);
  977. } else if (combla_1.icase == 2) {
  978. /* .. CDOTUTEST .. */
  979. cdotutest_(&combla_1.n, cx, &combla_1.incx, cy, &
  980. combla_1.incy, &ctemp);
  981. cdot[0].r = ctemp.r, cdot[0].i = ctemp.i;
  982. ctest_(&c__1, cdot, &ct7[kn + (ki << 2) - 5], &csize1[kn - 1],
  983. sfac);
  984. } else if (combla_1.icase == 3) {
  985. /* .. CAXPYTEST .. */
  986. caxpytest_(&combla_1.n, &ca, cx, &combla_1.incx, cy, &
  987. combla_1.incy);
  988. ctest_(&leny, cy, &ct8[(kn + (ki << 2)) * 7 - 35], &csize2[
  989. ksize * 7 - 7], sfac);
  990. } else if (combla_1.icase == 4) {
  991. /* .. CCOPYTEST .. */
  992. ccopytest_(&combla_1.n, cx, &combla_1.incx, cy, &
  993. combla_1.incy);
  994. ctest_(&leny, cy, &ct10y[(kn + (ki << 2)) * 7 - 35], csize3, &
  995. c_b43);
  996. } else if (combla_1.icase == 5) {
  997. /* .. CSWAPTEST .. */
  998. cswaptest_(&combla_1.n, cx, &combla_1.incx, cy, &
  999. combla_1.incy);
  1000. ctest_(&lenx, cx, &ct10x[(kn + (ki << 2)) * 7 - 35], csize3, &
  1001. c_b43);
  1002. ctest_(&leny, cy, &ct10y[(kn + (ki << 2)) * 7 - 35], csize3, &
  1003. c_b43);
  1004. } else {
  1005. fprintf(stderr,"Shouldn't be here in CHECK2\n");
  1006. exit(0);
  1007. }
  1008. /* L40: */
  1009. }
  1010. /* L60: */
  1011. }
  1012. return 0;
  1013. } /* check2_ */
  1014. /* Subroutine */ int stest_(len, scomp, strue, ssize, sfac)
  1015. integer *len;
  1016. real *scomp, *strue, *ssize, *sfac;
  1017. {
  1018. /* System generated locals */
  1019. integer i__1;
  1020. real r__1, r__2, r__3, r__4, r__5;
  1021. /* Local variables */
  1022. static integer i__;
  1023. extern doublereal sdiff_();
  1024. static real sd;
  1025. /* ********************************* STEST ************************** */
  1026. /* THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO */
  1027. /* SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE */
  1028. /* NEGLIGIBLE. */
  1029. /* C. L. LAWSON, JPL, 1974 DEC 10 */
  1030. /* .. Parameters .. */
  1031. /* .. Scalar Arguments .. */
  1032. /* .. Array Arguments .. */
  1033. /* .. Scalars in Common .. */
  1034. /* .. Local Scalars .. */
  1035. /* .. External Functions .. */
  1036. /* .. Intrinsic Functions .. */
  1037. /* .. Common blocks .. */
  1038. /* .. Executable Statements .. */
  1039. /* Parameter adjustments */
  1040. --ssize;
  1041. --strue;
  1042. --scomp;
  1043. /* Function Body */
  1044. i__1 = *len;
  1045. for (i__ = 1; i__ <= i__1; ++i__) {
  1046. sd = scomp[i__] - strue[i__];
  1047. r__4 = (r__1 = ssize[i__], dabs(r__1)) + (r__2 = *sfac * sd, dabs(
  1048. r__2));
  1049. r__5 = (r__3 = ssize[i__], dabs(r__3));
  1050. if (sdiff_(&r__4, &r__5) == (float)0.) {
  1051. goto L40;
  1052. }
  1053. /* HERE SCOMP(I) IS NOT CLOSE TO STRUE(I). */
  1054. if (! combla_1.pass) {
  1055. goto L20;
  1056. }
  1057. /* PRINT FAIL MESSAGE AND HEADER. */
  1058. combla_1.pass = FALSE_;
  1059. printf(" FAIL\n");
  1060. printf("CASE N INCX INCY MODE I COMP(I) TRUE(I) DIFFERENCE SIZE(I)\n");
  1061. L20:
  1062. printf("%4d %3d %5d %5d %5d %3d %36.8e %36.8e %12.4e %12.4e\n",combla_1.icase, combla_1.n, combla_1.incx, combla_1.incy,
  1063. combla_1.mode, i__, scomp[i__], strue[i__], sd, ssize[i__]);
  1064. L40:
  1065. ;
  1066. }
  1067. return 0;
  1068. } /* stest_ */
  1069. /* Subroutine */ int stest1_(scomp1, strue1, ssize, sfac)
  1070. real *scomp1, *strue1, *ssize, *sfac;
  1071. {
  1072. static real scomp[1], strue[1];
  1073. extern /* Subroutine */ int stest_();
  1074. /* ************************* STEST1 ***************************** */
  1075. /* THIS IS AN INTERFACE SUBROUTINE TO ACCOMMODATE THE FORTRAN */
  1076. /* REQUIREMENT THAT WHEN A DUMMY ARGUMENT IS AN ARRAY, THE */
  1077. /* ACTUAL ARGUMENT MUST ALSO BE AN ARRAY OR AN ARRAY ELEMENT. */
  1078. /* C.L. LAWSON, JPL, 1978 DEC 6 */
  1079. /* .. Scalar Arguments .. */
  1080. /* .. Array Arguments .. */
  1081. /* .. Local Arrays .. */
  1082. /* .. External Subroutines .. */
  1083. /* .. Executable Statements .. */
  1084. /* Parameter adjustments */
  1085. --ssize;
  1086. /* Function Body */
  1087. scomp[0] = *scomp1;
  1088. strue[0] = *strue1;
  1089. stest_(&c__1, scomp, strue, &ssize[1], sfac);
  1090. return 0;
  1091. } /* stest1_ */
  1092. doublereal sdiff_(sa, sb)
  1093. real *sa, *sb;
  1094. {
  1095. /* System generated locals */
  1096. real ret_val;
  1097. /* ********************************* SDIFF ************************** */
  1098. /* COMPUTES DIFFERENCE OF TWO NUMBERS. C. L. LAWSON, JPL 1974 FEB 15 */
  1099. /* .. Scalar Arguments .. */
  1100. /* .. Executable Statements .. */
  1101. ret_val = *sa - *sb;
  1102. return ret_val;
  1103. } /* sdiff_ */
  1104. /* Subroutine */ int ctest_(len, ccomp, ctrue, csize, sfac)
  1105. integer *len;
  1106. complex *ccomp, *ctrue, *csize;
  1107. real *sfac;
  1108. {
  1109. /* System generated locals */
  1110. integer i__1, i__2;
  1111. /* Builtin functions */
  1112. // double r_imag();
  1113. /* Local variables */
  1114. static integer i__;
  1115. static real scomp[20], ssize[20], strue[20];
  1116. extern /* Subroutine */ int stest_();
  1117. /* **************************** CTEST ***************************** */
  1118. /* C.L. LAWSON, JPL, 1978 DEC 6 */
  1119. /* .. Scalar Arguments .. */
  1120. /* .. Array Arguments .. */
  1121. /* .. Local Scalars .. */
  1122. /* .. Local Arrays .. */
  1123. /* .. External Subroutines .. */
  1124. /* .. Intrinsic Functions .. */
  1125. /* .. Executable Statements .. */
  1126. /* Parameter adjustments */
  1127. --csize;
  1128. --ctrue;
  1129. --ccomp;
  1130. /* Function Body */
  1131. i__1 = *len;
  1132. for (i__ = 1; i__ <= i__1; ++i__) {
  1133. i__2 = i__;
  1134. scomp[(i__ << 1) - 2] = ccomp[i__2].r;
  1135. scomp[(i__ << 1) - 1] = r_imag(&ccomp[i__]);
  1136. i__2 = i__;
  1137. strue[(i__ << 1) - 2] = ctrue[i__2].r;
  1138. strue[(i__ << 1) - 1] = r_imag(&ctrue[i__]);
  1139. i__2 = i__;
  1140. ssize[(i__ << 1) - 2] = csize[i__2].r;
  1141. ssize[(i__ << 1) - 1] = r_imag(&csize[i__]);
  1142. /* L20: */
  1143. }
  1144. i__1 = *len << 1;
  1145. stest_(&i__1, scomp, strue, ssize, sfac);
  1146. return 0;
  1147. } /* ctest_ */
  1148. /* Subroutine */ int itest1_(icomp, itrue)
  1149. integer *icomp, *itrue;
  1150. {
  1151. /* Local variables */
  1152. static integer id;
  1153. /* ********************************* ITEST1 ************************* */
  1154. /* THIS SUBROUTINE COMPARES THE VARIABLES ICOMP AND ITRUE FOR */
  1155. /* EQUALITY. */
  1156. /* C. L. LAWSON, JPL, 1974 DEC 10 */
  1157. /* .. Parameters .. */
  1158. /* .. Scalar Arguments .. */
  1159. /* .. Scalars in Common .. */
  1160. /* .. Local Scalars .. */
  1161. /* .. Common blocks .. */
  1162. /* .. Executable Statements .. */
  1163. if (*icomp == *itrue) {
  1164. goto L40;
  1165. }
  1166. /* HERE ICOMP IS NOT EQUAL TO ITRUE. */
  1167. if (! combla_1.pass) {
  1168. goto L20;
  1169. }
  1170. /* PRINT FAIL MESSAGE AND HEADER. */
  1171. combla_1.pass = FALSE_;
  1172. printf(" FAIL\n");
  1173. printf(" CASE N INCX INCY MODE COMP TRUE DIFFERENCE\n");
  1174. L20:
  1175. id = *icomp - *itrue;
  1176. printf("%4d %3d %5d %5d %5d %36d %36d %12d\n",combla_1.icase, combla_1.n, combla_1.incx, combla_1.incy,
  1177. combla_1.mode, *icomp, *itrue, id);
  1178. L40:
  1179. return 0;
  1180. } /* itest1_ */