• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define _GNU_SOURCE 1
2 #include <stdint.h>
3 #include <stdio.h>
4 #include "mtest.h"
5 
6 static struct l_ll t[] = {
7 #if LDBL_MANT_DIG == 53
8 #include "sanity/sincos.h"
9 #include "special/sincos.h"
10 #elif LDBL_MANT_DIG == 64
11 #include "sanity/sincosl.h"
12 #include "special/sincosl.h"
13 #endif
14 };
15 
main(void)16 int main(void)
17 {
18 	#pragma STDC FENV_ACCESS ON
19 	long double ysin, ycos;
20 	float dsin, dcos;
21 	int e, i, err = 0;
22 	struct l_ll *p;
23 
24 	for (i = 0; i < sizeof t/sizeof *t; i++) {
25 		p = t + i;
26 
27 		if (p->r < 0)
28 			continue;
29 		fesetround(p->r);
30 		feclearexcept(FE_ALL_EXCEPT);
31 		sincosl(p->x, &ysin, &ycos);
32 		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
33 
34 		if (!checkexcept(e, p->e, p->r)) {
35 			printf("%s:%d: bad fp exception: %s sincosl(%La)=%La,%La, want %s",
36 				p->file, p->line, rstr(p->r), p->x, p->y, p->y2, estr(p->e));
37 			printf(" got %s\n", estr(e));
38 			err++;
39 		}
40 		dsin = ulperr(ysin, p->y, p->dy);
41 		dcos = ulperr(ycos, p->y2, p->dy2);
42 		if (!checkulp(dsin, p->r) || !checkulp(dcos, p->r)) {
43 			printf("%s:%d: %s sincosl(%La) want %La,%La got %La,%La, ulperr %.3f = %a + %a, %.3f = %a + %a\n",
44 				p->file, p->line, rstr(p->r), p->x, p->y, p->y2, ysin, ycos,
45 				dsin, dsin-p->dy, p->dy, dcos, dcos-p->dy2, p->dy2);
46 			err++;
47 		}
48 	}
49 	return !!err;
50 }
51