dtestvec.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. /* Test vectors for math functions.
  2. See C9X section F.9. */
  3. /*
  4. Cephes Math Library Release 2.8: June, 2000
  5. Copyright 1998, 2000 by Stephen L. Moshier
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. int isfinite (double);
  11. /* C9X spells lgam lgamma. */
  12. #define GLIBC2 0
  13. extern double PI;
  14. static double MPI, PIO2, MPIO2, PIO4, MPIO4, THPIO4, MTHPIO4;
  15. #if 0
  16. #define PI 3.141592653589793238463E0
  17. #define PIO2 1.570796326794896619231E0
  18. #define PIO4 7.853981633974483096157E-1
  19. #define THPIO4 2.35619449019234492884698
  20. #define SQRT2 1.414213562373095048802E0
  21. #define SQRTH 7.071067811865475244008E-1
  22. #define INF (1.0/0.0)
  23. #define MINF (-1.0/0.0)
  24. #endif
  25. extern double MACHEP, SQRTH, SQRT2;
  26. extern double NAN, INFINITY, NEGZERO;
  27. static double INF, MINF;
  28. static double ZERO, MZERO, HALF, MHALF, ONE, MONE, TWO, MTWO, THREE, MTHREE;
  29. /* #define NAN (1.0/0.0 - 1.0/0.0) */
  30. /* Functions of one variable. */
  31. double log (double);
  32. double exp ( double);
  33. double atan (double);
  34. double sin (double);
  35. double cos (double);
  36. double tan (double);
  37. double acos (double);
  38. double asin (double);
  39. double acosh (double);
  40. double asinh (double);
  41. double atanh (double);
  42. double sinh (double);
  43. double cosh (double);
  44. double tanh (double);
  45. double exp2 (double);
  46. double expm1 (double);
  47. double log10 (double);
  48. double log1p (double);
  49. double log2 (double);
  50. double fabs (double);
  51. double erf (double);
  52. double erfc (double);
  53. double gamma (double);
  54. double floor (double);
  55. double ceil (double);
  56. double cbrt (double);
  57. #if GLIBC2
  58. double lgamma (double);
  59. #else
  60. double lgam (double);
  61. #endif
  62. struct oneargument
  63. {
  64. char *name; /* Name of the function. */
  65. double (*func) (double);
  66. double *arg1;
  67. double *answer;
  68. int thresh; /* Error report threshold. */
  69. };
  70. struct oneargument test1[] =
  71. {
  72. {"atan", atan, &ONE, &PIO4, 0},
  73. {"sin", sin, &PIO2, &ONE, 0},
  74. #if 0
  75. {"cos", cos, &PIO4, &SQRTH, 0},
  76. {"sin", sin, 32767., 1.8750655394138942394239E-1, 0},
  77. {"cos", cos, 32767., 9.8226335176928229845654E-1, 0},
  78. {"tan", tan, 32767., 1.9089234430221485740826E-1, 0},
  79. {"sin", sin, 8388607., 9.9234509376961249835628E-1, 0},
  80. {"cos", cos, 8388607., -1.2349580912475928183718E-1, 0},
  81. {"tan", tan, 8388607., -8.0354556223613614748329E0, 0},
  82. /*
  83. {"sin", sin, 2147483647., -7.2491655514455639054829E-1, 0},
  84. {"cos", cos, 2147483647., -6.8883669187794383467976E-1, 0},
  85. {"tan", tan, 2147483647., 1.0523779637351339136698E0, 0},
  86. */
  87. {"cos", cos, &PIO2, 6.1232339957367574e-17, 1},
  88. {"sin", sin, &PIO4, &SQRTH, 1},
  89. #endif
  90. {"acos", acos, &NAN, &NAN, 0},
  91. {"acos", acos, &ONE, &ZERO, 0},
  92. {"acos", acos, &TWO, &NAN, 0},
  93. {"acos", acos, &MTWO, &NAN, 0},
  94. {"asin", asin, &NAN, &NAN, 0},
  95. {"asin", asin, &ZERO, &ZERO, 0},
  96. {"asin", asin, &MZERO, &MZERO, 0},
  97. {"asin", asin, &TWO, &NAN, 0},
  98. {"asin", asin, &MTWO, &NAN, 0},
  99. {"atan", atan, &NAN, &NAN, 0},
  100. {"atan", atan, &ZERO, &ZERO, 0},
  101. {"atan", atan, &MZERO, &MZERO, 0},
  102. {"atan", atan, &INF, &PIO2, 0},
  103. {"atan", atan, &MINF, &MPIO2, 0},
  104. {"cos", cos, &NAN, &NAN, 0},
  105. {"cos", cos, &ZERO, &ONE, 0},
  106. {"cos", cos, &MZERO, &ONE, 0},
  107. {"cos", cos, &INF, &NAN, 0},
  108. {"cos", cos, &MINF, &NAN, 0},
  109. {"sin", sin, &NAN, &NAN, 0},
  110. {"sin", sin, &MZERO, &MZERO, 0},
  111. {"sin", sin, &ZERO, &ZERO, 0},
  112. {"sin", sin, &INF, &NAN, 0},
  113. {"sin", sin, &MINF, &NAN, 0},
  114. {"tan", tan, &NAN, &NAN, 0},
  115. {"tan", tan, &ZERO, &ZERO, 0},
  116. {"tan", tan, &MZERO, &MZERO, 0},
  117. {"tan", tan, &INF, &NAN, 0},
  118. {"tan", tan, &MINF, &NAN, 0},
  119. {"acosh", acosh, &NAN, &NAN, 0},
  120. {"acosh", acosh, &ONE, &ZERO, 0},
  121. {"acosh", acosh, &INF, &INF, 0},
  122. {"acosh", acosh, &HALF, &NAN, 0},
  123. {"acosh", acosh, &MONE, &NAN, 0},
  124. {"asinh", asinh, &NAN, &NAN, 0},
  125. {"asinh", asinh, &ZERO, &ZERO, 0},
  126. {"asinh", asinh, &MZERO, &MZERO, 0},
  127. {"asinh", asinh, &INF, &INF, 0},
  128. {"asinh", asinh, &MINF, &MINF, 0},
  129. {"atanh", atanh, &NAN, &NAN, 0},
  130. {"atanh", atanh, &ZERO, &ZERO, 0},
  131. {"atanh", atanh, &MZERO, &MZERO, 0},
  132. {"atanh", atanh, &ONE, &INF, 0},
  133. {"atanh", atanh, &MONE, &MINF, 0},
  134. {"atanh", atanh, &TWO, &NAN, 0},
  135. {"atanh", atanh, &MTWO, &NAN, 0},
  136. {"cosh", cosh, &NAN, &NAN, 0},
  137. {"cosh", cosh, &ZERO, &ONE, 0},
  138. {"cosh", cosh, &MZERO, &ONE, 0},
  139. {"cosh", cosh, &INF, &INF, 0},
  140. {"cosh", cosh, &MINF, &INF, 0},
  141. {"sinh", sinh, &NAN, &NAN, 0},
  142. {"sinh", sinh, &ZERO, &ZERO, 0},
  143. {"sinh", sinh, &MZERO, &MZERO, 0},
  144. {"sinh", sinh, &INF, &INF, 0},
  145. {"sinh", sinh, &MINF, &MINF, 0},
  146. {"tanh", tanh, &NAN, &NAN, 0},
  147. {"tanh", tanh, &ZERO, &ZERO, 0},
  148. {"tanh", tanh, &MZERO, &MZERO, 0},
  149. {"tanh", tanh, &INF, &ONE, 0},
  150. {"tanh", tanh, &MINF, &MONE, 0},
  151. {"exp", exp, &NAN, &NAN, 0},
  152. {"exp", exp, &ZERO, &ONE, 0},
  153. {"exp", exp, &MZERO, &ONE, 0},
  154. {"exp", exp, &INF, &INF, 0},
  155. {"exp", exp, &MINF, &ZERO, 0},
  156. #if !GLIBC2
  157. {"exp2", exp2, &NAN, &NAN, 0},
  158. {"exp2", exp2, &ZERO, &ONE, 0},
  159. {"exp2", exp2, &MZERO, &ONE, 0},
  160. {"exp2", exp2, &INF, &INF, 0},
  161. {"exp2", exp2, &MINF, &ZERO, 0},
  162. #endif
  163. {"expm1", expm1, &NAN, &NAN, 0},
  164. {"expm1", expm1, &ZERO, &ZERO, 0},
  165. {"expm1", expm1, &MZERO, &MZERO, 0},
  166. {"expm1", expm1, &INF, &INF, 0},
  167. {"expm1", expm1, &MINF, &MONE, 0},
  168. {"log", log, &NAN, &NAN, 0},
  169. {"log", log, &ZERO, &MINF, 0},
  170. {"log", log, &MZERO, &MINF, 0},
  171. {"log", log, &ONE, &ZERO, 0},
  172. {"log", log, &MONE, &NAN, 0},
  173. {"log", log, &INF, &INF, 0},
  174. {"log10", log10, &NAN, &NAN, 0},
  175. {"log10", log10, &ZERO, &MINF, 0},
  176. {"log10", log10, &MZERO, &MINF, 0},
  177. {"log10", log10, &ONE, &ZERO, 0},
  178. {"log10", log10, &MONE, &NAN, 0},
  179. {"log10", log10, &INF, &INF, 0},
  180. {"log1p", log1p, &NAN, &NAN, 0},
  181. {"log1p", log1p, &ZERO, &ZERO, 0},
  182. {"log1p", log1p, &MZERO, &MZERO, 0},
  183. {"log1p", log1p, &MONE, &MINF, 0},
  184. {"log1p", log1p, &MTWO, &NAN, 0},
  185. {"log1p", log1p, &INF, &INF, 0},
  186. #if !GLIBC2
  187. {"log2", log2, &NAN, &NAN, 0},
  188. {"log2", log2, &ZERO, &MINF, 0},
  189. {"log2", log2, &MZERO, &MINF, 0},
  190. {"log2", log2, &MONE, &NAN, 0},
  191. {"log2", log2, &INF, &INF, 0},
  192. #endif
  193. /* {"fabs", fabs, NAN, NAN, 0}, */
  194. {"fabs", fabs, &ONE, &ONE, 0},
  195. {"fabs", fabs, &MONE, &ONE, 0},
  196. {"fabs", fabs, &ZERO, &ZERO, 0},
  197. {"fabs", fabs, &MZERO, &ZERO, 0},
  198. {"fabs", fabs, &INF, &INF, 0},
  199. {"fabs", fabs, &MINF, &INF, 0},
  200. {"cbrt", cbrt, &NAN, &NAN, 0},
  201. {"cbrt", cbrt, &ZERO, &ZERO, 0},
  202. {"cbrt", cbrt, &MZERO, &MZERO, 0},
  203. {"cbrt", cbrt, &INF, &INF, 0},
  204. {"cbrt", cbrt, &MINF, &MINF, 0},
  205. {"erf", erf, &NAN, &NAN, 0},
  206. {"erf", erf, &ZERO, &ZERO, 0},
  207. {"erf", erf, &MZERO, &MZERO, 0},
  208. {"erf", erf, &INF, &ONE, 0},
  209. {"erf", erf, &MINF, &MONE, 0},
  210. {"erfc", erfc, &NAN, &NAN, 0},
  211. {"erfc", erfc, &INF, &ZERO, 0},
  212. {"erfc", erfc, &MINF, &TWO, 0},
  213. {"gamma", gamma, &NAN, &NAN, 0},
  214. {"gamma", gamma, &INF, &INF, 0},
  215. {"gamma", gamma, &MONE, &NAN, 0},
  216. {"gamma", gamma, &ZERO, &NAN, 0},
  217. {"gamma", gamma, &MINF, &NAN, 0},
  218. #if GLIBC2
  219. {"lgamma", lgamma, &NAN, &NAN, 0},
  220. {"lgamma", lgamma, &INF, &INF, 0},
  221. {"lgamma", lgamma, &MONE, &INF, 0},
  222. {"lgamma", lgamma, &ZERO, &INF, 0},
  223. {"lgamma", lgamma, &MINF, &INF, 0},
  224. #else
  225. {"lgam", lgam, &NAN, &NAN, 0},
  226. {"lgam", lgam, &INF, &INF, 0},
  227. {"lgam", lgam, &MONE, &INF, 0},
  228. {"lgam", lgam, &ZERO, &INF, 0},
  229. {"lgam", lgam, &MINF, &INF, 0},
  230. #endif
  231. {"ceil", ceil, &NAN, &NAN, 0},
  232. {"ceil", ceil, &ZERO, &ZERO, 0},
  233. {"ceil", ceil, &MZERO, &MZERO, 0},
  234. {"ceil", ceil, &INF, &INF, 0},
  235. {"ceil", ceil, &MINF, &MINF, 0},
  236. {"floor", floor, &NAN, &NAN, 0},
  237. {"floor", floor, &ZERO, &ZERO, 0},
  238. {"floor", floor, &MZERO, &MZERO, 0},
  239. {"floor", floor, &INF, &INF, 0},
  240. {"floor", floor, &MINF, &MINF, 0},
  241. {"null", NULL, &ZERO, &ZERO, 0},
  242. };
  243. /* Functions of two variables. */
  244. double atan2 (double, double);
  245. double pow (double, double);
  246. struct twoarguments
  247. {
  248. char *name; /* Name of the function. */
  249. double (*func) (double, double);
  250. double *arg1;
  251. double *arg2;
  252. double *answer;
  253. int thresh;
  254. };
  255. struct twoarguments test2[] =
  256. {
  257. {"atan2", atan2, &ZERO, &ONE, &ZERO, 0},
  258. {"atan2", atan2, &MZERO, &ONE, &MZERO, 0},
  259. {"atan2", atan2, &ZERO, &ZERO, &ZERO, 0},
  260. {"atan2", atan2, &MZERO, &ZERO, &MZERO, 0},
  261. {"atan2", atan2, &ZERO, &MONE, &PI, 0},
  262. {"atan2", atan2, &MZERO, &MONE, &MPI, 0},
  263. {"atan2", atan2, &ZERO, &MZERO, &PI, 0},
  264. {"atan2", atan2, &MZERO, &MZERO, &MPI, 0},
  265. {"atan2", atan2, &ONE, &ZERO, &PIO2, 0},
  266. {"atan2", atan2, &ONE, &MZERO, &PIO2, 0},
  267. {"atan2", atan2, &MONE, &ZERO, &MPIO2, 0},
  268. {"atan2", atan2, &MONE, &MZERO, &MPIO2, 0},
  269. {"atan2", atan2, &ONE, &INF, &ZERO, 0},
  270. {"atan2", atan2, &MONE, &INF, &MZERO, 0},
  271. {"atan2", atan2, &INF, &ONE, &PIO2, 0},
  272. {"atan2", atan2, &INF, &MONE, &PIO2, 0},
  273. {"atan2", atan2, &MINF, &ONE, &MPIO2, 0},
  274. {"atan2", atan2, &MINF, &MONE, &MPIO2, 0},
  275. {"atan2", atan2, &ONE, &MINF, &PI, 0},
  276. {"atan2", atan2, &MONE, &MINF, &MPI, 0},
  277. {"atan2", atan2, &INF, &INF, &PIO4, 0},
  278. {"atan2", atan2, &MINF, &INF, &MPIO4, 0},
  279. {"atan2", atan2, &INF, &MINF, &THPIO4, 0},
  280. {"atan2", atan2, &MINF, &MINF, &MTHPIO4, 0},
  281. {"atan2", atan2, &ONE, &ONE, &PIO4, 0},
  282. {"atan2", atan2, &NAN, &ONE, &NAN, 0},
  283. {"atan2", atan2, &ONE, &NAN, &NAN, 0},
  284. {"atan2", atan2, &NAN, &NAN, &NAN, 0},
  285. {"pow", pow, &ONE, &ZERO, &ONE, 0},
  286. {"pow", pow, &ONE, &MZERO, &ONE, 0},
  287. {"pow", pow, &MONE, &ZERO, &ONE, 0},
  288. {"pow", pow, &MONE, &MZERO, &ONE, 0},
  289. {"pow", pow, &INF, &ZERO, &ONE, 0},
  290. {"pow", pow, &INF, &MZERO, &ONE, 0},
  291. {"pow", pow, &NAN, &ZERO, &ONE, 0},
  292. {"pow", pow, &NAN, &MZERO, &ONE, 0},
  293. {"pow", pow, &TWO, &INF, &INF, 0},
  294. {"pow", pow, &MTWO, &INF, &INF, 0},
  295. {"pow", pow, &HALF, &INF, &ZERO, 0},
  296. {"pow", pow, &MHALF, &INF, &ZERO, 0},
  297. {"pow", pow, &TWO, &MINF, &ZERO, 0},
  298. {"pow", pow, &MTWO, &MINF, &ZERO, 0},
  299. {"pow", pow, &HALF, &MINF, &INF, 0},
  300. {"pow", pow, &MHALF, &MINF, &INF, 0},
  301. {"pow", pow, &INF, &HALF, &INF, 0},
  302. {"pow", pow, &INF, &TWO, &INF, 0},
  303. {"pow", pow, &INF, &MHALF, &ZERO, 0},
  304. {"pow", pow, &INF, &MTWO, &ZERO, 0},
  305. {"pow", pow, &MINF, &THREE, &MINF, 0},
  306. {"pow", pow, &MINF, &TWO, &INF, 0},
  307. {"pow", pow, &MINF, &MTHREE, &MZERO, 0},
  308. {"pow", pow, &MINF, &MTWO, &ZERO, 0},
  309. {"pow", pow, &NAN, &ONE, &NAN, 0},
  310. {"pow", pow, &ONE, &NAN, &NAN, 0},
  311. {"pow", pow, &NAN, &NAN, &NAN, 0},
  312. {"pow", pow, &ONE, &INF, &NAN, 0},
  313. {"pow", pow, &MONE, &INF, &NAN, 0},
  314. {"pow", pow, &ONE, &MINF, &NAN, 0},
  315. {"pow", pow, &MONE, &MINF, &NAN, 0},
  316. {"pow", pow, &MTWO, &HALF, &NAN, 0},
  317. {"pow", pow, &ZERO, &MTHREE, &INF, 0},
  318. {"pow", pow, &MZERO, &MTHREE, &MINF, 0},
  319. {"pow", pow, &ZERO, &MHALF, &INF, 0},
  320. {"pow", pow, &MZERO, &MHALF, &INF, 0},
  321. {"pow", pow, &ZERO, &THREE, &ZERO, 0},
  322. {"pow", pow, &MZERO, &THREE, &MZERO, 0},
  323. {"pow", pow, &ZERO, &HALF, &ZERO, 0},
  324. {"pow", pow, &MZERO, &HALF, &ZERO, 0},
  325. {"null", NULL, &ZERO, &ZERO, &ZERO, 0},
  326. };
  327. /* Integer functions of one variable. */
  328. int isnan (double);
  329. int signbit (double);
  330. struct intans
  331. {
  332. char *name; /* Name of the function. */
  333. int (*func) (double);
  334. double *arg1;
  335. int ianswer;
  336. };
  337. struct intans test3[] =
  338. {
  339. {"isfinite", isfinite, &ZERO, 1},
  340. {"isfinite", isfinite, &INF, 0},
  341. {"isfinite", isfinite, &MINF, 0},
  342. {"isnan", isnan, &NAN, 1},
  343. {"isnan", isnan, &INF, 0},
  344. {"isnan", isnan, &ZERO, 0},
  345. {"isnan", isnan, &MZERO, 0},
  346. {"signbit", signbit, &MZERO, 1},
  347. {"signbit", signbit, &MONE, 1},
  348. {"signbit", signbit, &ZERO, 0},
  349. {"signbit", signbit, &ONE, 0},
  350. {"signbit", signbit, &MINF, 1},
  351. {"signbit", signbit, &INF, 0},
  352. {"null", NULL, &ZERO, 0},
  353. };
  354. static volatile double x1;
  355. static volatile double x2;
  356. static volatile double y;
  357. static volatile double answer;
  358. void
  359. pvec(x)
  360. double x;
  361. {
  362. union
  363. {
  364. double d;
  365. unsigned short s[4];
  366. } u;
  367. int i;
  368. u.d = x;
  369. for (i = 0; i < 4; i++)
  370. printf ("0x%04x ", u.s[i]);
  371. printf ("\n");
  372. }
  373. int
  374. main ()
  375. {
  376. int i, nerrors, k, ianswer, ntests;
  377. double (*fun1) (double);
  378. double (*fun2) (double, double);
  379. int (*fun3) (double);
  380. double e;
  381. union
  382. {
  383. double d;
  384. char c[8];
  385. } u, v;
  386. ZERO = 0.0;
  387. MZERO = NEGZERO;
  388. HALF = 0.5;
  389. MHALF = -HALF;
  390. ONE = 1.0;
  391. MONE = -ONE;
  392. TWO = 2.0;
  393. MTWO = -TWO;
  394. THREE = 3.0;
  395. MTHREE = -THREE;
  396. INF = INFINITY;
  397. MINF = -INFINITY;
  398. MPI = -PI;
  399. PIO2 = 0.5 * PI;
  400. MPIO2 = -PIO2;
  401. PIO4 = 0.5 * PIO2;
  402. MPIO4 = -PIO4;
  403. THPIO4 = 3.0 * PIO4;
  404. MTHPIO4 = -THPIO4;
  405. nerrors = 0;
  406. ntests = 0;
  407. i = 0;
  408. for (;;)
  409. {
  410. fun1 = test1[i].func;
  411. if (fun1 == NULL)
  412. break;
  413. x1 = *(test1[i].arg1);
  414. y = (*(fun1)) (x1);
  415. answer = *(test1[i].answer);
  416. if (test1[i].thresh == 0)
  417. {
  418. v.d = answer;
  419. u.d = y;
  420. if (memcmp(u.c, v.c, 8) != 0)
  421. {
  422. if( isnan(v.d) && isnan(u.d) )
  423. goto nxttest1;
  424. goto wrongone;
  425. }
  426. else
  427. goto nxttest1;
  428. }
  429. if (y != answer)
  430. {
  431. e = y - answer;
  432. if (answer != 0.0)
  433. e = e / answer;
  434. if (e < 0)
  435. e = -e;
  436. if (e > test1[i].thresh * MACHEP)
  437. {
  438. wrongone:
  439. printf ("%s (%.16e) = %.16e\n should be %.16e\n",
  440. test1[i].name, x1, y, answer);
  441. nerrors += 1;
  442. }
  443. }
  444. nxttest1:
  445. ntests += 1;
  446. i += 1;
  447. }
  448. i = 0;
  449. for (;;)
  450. {
  451. fun2 = test2[i].func;
  452. if (fun2 == NULL)
  453. break;
  454. x1 = *(test2[i].arg1);
  455. x2 = *(test2[i].arg2);
  456. y = (*(fun2)) (x1, x2);
  457. answer = *(test2[i].answer);
  458. if (test2[i].thresh == 0)
  459. {
  460. v.d = answer;
  461. u.d = y;
  462. if (memcmp(u.c, v.c, 8) != 0)
  463. {
  464. if( isnan(v.d) && isnan(u.d) )
  465. goto nxttest2;
  466. #if 0
  467. if( isnan(v.d) )
  468. pvec(v.d);
  469. if( isnan(u.d) )
  470. pvec(u.d);
  471. #endif
  472. goto wrongtwo;
  473. }
  474. else
  475. goto nxttest2;
  476. }
  477. if (y != answer)
  478. {
  479. e = y - answer;
  480. if (answer != 0.0)
  481. e = e / answer;
  482. if (e < 0)
  483. e = -e;
  484. if (e > test2[i].thresh * MACHEP)
  485. {
  486. wrongtwo:
  487. printf ("%s (%.16e, %.16e) = %.16e\n should be %.16e\n",
  488. test2[i].name, x1, x2, y, answer);
  489. nerrors += 1;
  490. }
  491. }
  492. nxttest2:
  493. ntests += 1;
  494. i += 1;
  495. }
  496. i = 0;
  497. for (;;)
  498. {
  499. fun3 = test3[i].func;
  500. if (fun3 == NULL)
  501. break;
  502. x1 = *(test3[i].arg1);
  503. k = (*(fun3)) (x1);
  504. ianswer = test3[i].ianswer;
  505. if (k != ianswer)
  506. {
  507. printf ("%s (%.16e) = %d\n should be. %d\n",
  508. test3[i].name, x1, k, ianswer);
  509. nerrors += 1;
  510. }
  511. ntests += 1;
  512. i += 1;
  513. }
  514. printf ("testvect: %d errors in %d tests\n", nerrors, ntests);
  515. exit (0);
  516. }