#include "test_helpers.h"
#include "gr_poly.h"
#include "ulong_extras.h"
TEST_FUNCTION_START(gr_poly_nth_derivative, state)
{
slong iter;
for (iter = 0; iter < 1000; iter++)
{
int status;
ulong nth;
slong j;
gr_ctx_t ctx;
gr_poly_t a, b;
gr_ctx_init_random(ctx, state);
gr_poly_init(a, ctx);
gr_poly_init(b, ctx);
status = GR_SUCCESS;
status |= gr_poly_randtest(a, state, n_randint(state, 30), ctx);
status |= gr_poly_randtest(b, state, n_randint(state, 30), ctx);
nth = n_randint(state, 30);
if (n_randint(state, 2)) {
status |= gr_poly_nth_derivative(b, a, nth, ctx);
}
else
{
status |= gr_poly_set(b, a, ctx);
status |= gr_poly_nth_derivative(b, b, nth, ctx);
}
for (j = 0; j < nth; j ++)
status |= gr_poly_derivative(a, a, ctx);
if (status == GR_SUCCESS && gr_poly_equal(a, b, ctx) == T_FALSE)
{
flint_printf("FAIL:\n");
flint_printf("a = "); gr_poly_print(a, ctx); flint_printf("\n");
flint_printf("b = "); gr_poly_print(b, ctx); flint_printf("\n");
flint_abort();
}
gr_poly_clear(a, ctx);
gr_poly_clear(b, ctx);
gr_ctx_clear(ctx);
}
TEST_FUNCTION_END(state);
}