Blame src/math/y1f.c

Szabolcs Nagy 2c671f
#define _DEFAULT_SOURCE 1
Szabolcs Nagy 7b5ccd
#define _BSD_SOURCE 1
nsz f9d179
#include <stdint.h>
nsz f9d179
#include <stdio.h>
Szabolcs Nagy cfa23c
#include "mtest.h"
nsz f9d179
nsz f9d179
static struct f_f t[] = {
nsz f9d179
#include "sanity/y1f.h"
Szabolcs Nagy f3f0ff
#include "special/y1f.h"
nsz 4282b0
nsz f9d179
};
nsz f9d179
nsz f9d179
int main(void)
nsz f9d179
{
nsz d22f4f
	#pragma STDC FENV_ACCESS ON
nsz f9d179
	float y;
nsz f9d179
	float d;
nsz f9d179
	int e, i, err = 0;
nsz f9d179
	struct f_f *p;
nsz f9d179
nsz f9d179
	for (i = 0; i < sizeof t/sizeof *t; i++) {
nsz f9d179
		p = t + i;
nsz d22f4f
nsz d22f4f
		if (p->r < 0)
nsz d22f4f
			continue;
nsz d22f4f
		fesetround(p->r);
nsz d22f4f
		feclearexcept(FE_ALL_EXCEPT);
nsz f9d179
		y = y1f(p->x);
nsz d22f4f
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
nsz d22f4f
nsz f9d179
		if (!checkexcept(e, p->e, p->r)) {
nsz 457b0d
			printf("%s:%d: bad fp exception: %s y1f(%a)=%a, want %s",
nsz 457b0d
				p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
nsz f9d179
			printf(" got %s\n", estr(e));
nsz f9d179
			err++;
nsz f9d179
		}
nsz f9d179
		d = ulperrf(y, p->y, p->dy);
Szabolcs Nagy b3580f
		if ((!(p->x < 0) && !checkulp(d, p->r)) || (p->x < 0 && !isnan(y) && y != -inf)) {
nsz 457b0d
			printf("%s:%d: %s y1f(%a) want %a got %a ulperr %.3f = %a + %a\n",
nsz 457b0d
				p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
nsz f9d179
			err++;
nsz f9d179
		}
nsz f9d179
	}
nsz f9d179
	return !!err;
nsz f9d179
}