#ifdef T
#include "test_helpers.h"
#include "templates.h"
TEST_TEMPLATE_FUNCTION_START(T, poly_divrem, state)
{
int i, result;
for (i = 0; i < 200 * flint_test_multiplier(); i++)
{
TEMPLATE(T, ctx_t) ctx;
TEMPLATE(T, poly_t) a, b, c, q, r;
TEMPLATE(T, ctx_init_randtest)(ctx, state, 3);
TEMPLATE(T, poly_init) (a, ctx);
TEMPLATE(T, poly_init) (b, ctx);
TEMPLATE(T, poly_init) (c, ctx);
TEMPLATE(T, poly_init) (q, ctx);
TEMPLATE(T, poly_init) (r, ctx);
TEMPLATE(T, poly_randtest) (a, state, n_randint(state, 50), ctx);
TEMPLATE(T, poly_randtest_not_zero) (b, state,
n_randint(state, 50) + 1, ctx);
TEMPLATE(T, poly_divrem) (q, r, a, b, ctx);
TEMPLATE(T, poly_mul) (c, q, b, ctx);
TEMPLATE(T, poly_add) (c, c, r, ctx);
result = (TEMPLATE(T, poly_equal) (a, c, ctx));
if (!result)
{
flint_printf("FAIL:\n\n");
flint_printf("a = "), TEMPLATE(T, poly_print_pretty) (a, "X", ctx),
flint_printf("\n");
flint_printf("b = "), TEMPLATE(T, poly_print_pretty) (b, "X", ctx),
flint_printf("\n");
flint_printf("c = "), TEMPLATE(T, poly_print_pretty) (c, "X", ctx),
flint_printf("\n");
flint_printf("q = "), TEMPLATE(T, poly_print_pretty) (q, "X", ctx),
flint_printf("\n");
flint_printf("r = "), TEMPLATE(T, poly_print_pretty) (r, "X", ctx),
flint_printf("\n");
fflush(stdout);
flint_abort();
}
TEMPLATE(T, poly_clear) (a, ctx);
TEMPLATE(T, poly_clear) (b, ctx);
TEMPLATE(T, poly_clear) (c, ctx);
TEMPLATE(T, poly_clear) (q, ctx);
TEMPLATE(T, poly_clear) (r, ctx);
TEMPLATE(T, ctx_clear) (ctx);
}
for (i = 0; i < 10 * flint_test_multiplier(); i++)
{
TEMPLATE(T, ctx_t) ctx;
TEMPLATE(T, poly_t) a, b, q, r;
TEMPLATE(T, ctx_init_randtest)(ctx, state, 3);
TEMPLATE(T, poly_init) (a, ctx);
TEMPLATE(T, poly_init) (b, ctx);
TEMPLATE(T, poly_init) (q, ctx);
TEMPLATE(T, poly_init) (r, ctx);
TEMPLATE(T, poly_randtest) (a, state, n_randint(state, 50), ctx);
TEMPLATE(T, poly_randtest_not_zero) (b, state,
n_randint(state, 50) + 1, ctx);
TEMPLATE(T, poly_divrem) (q, r, a, b, ctx);
TEMPLATE(T, poly_divrem) (q, a, a, b, ctx);
result = (TEMPLATE(T, poly_equal) (a, r, ctx));
if (!result)
{
flint_printf("FAIL:\n\n");
flint_printf("a = "), TEMPLATE(T, poly_print_pretty) (a, "X", ctx),
flint_printf("\n");
flint_printf("b = "), TEMPLATE(T, poly_print_pretty) (b, "X", ctx),
flint_printf("\n");
flint_printf("q = "), TEMPLATE(T, poly_print_pretty) (q, "X", ctx),
flint_printf("\n");
flint_printf("r = "), TEMPLATE(T, poly_print_pretty) (r, "X", ctx),
flint_printf("\n");
fflush(stdout);
flint_abort();
}
TEMPLATE(T, poly_clear) (a, ctx);
TEMPLATE(T, poly_clear) (b, ctx);
TEMPLATE(T, poly_clear) (q, ctx);
TEMPLATE(T, poly_clear) (r, ctx);
TEMPLATE(T, ctx_clear) (ctx);
}
for (i = 0; i < 10 * flint_test_multiplier(); i++)
{
TEMPLATE(T, ctx_t) ctx;
TEMPLATE(T, poly_t) a, b, q, r;
TEMPLATE(T, ctx_init_randtest)(ctx, state, 3);
TEMPLATE(T, poly_init) (a, ctx);
TEMPLATE(T, poly_init) (b, ctx);
TEMPLATE(T, poly_init) (q, ctx);
TEMPLATE(T, poly_init) (r, ctx);
TEMPLATE(T, poly_randtest) (a, state, n_randint(state, 50), ctx);
TEMPLATE(T, poly_randtest_not_zero) (b, state,
n_randint(state, 50) + 1, ctx);
TEMPLATE(T, poly_divrem) (q, r, a, b, ctx);
TEMPLATE(T, poly_divrem) (q, b, a, b, ctx);
result = (TEMPLATE(T, poly_equal) (b, r, ctx));
if (!result)
{
flint_printf("FAIL:\n\n");
flint_printf("a = "), TEMPLATE(T, poly_print_pretty) (a, "X", ctx),
flint_printf("\n");
flint_printf("b = "), TEMPLATE(T, poly_print_pretty) (b, "X", ctx),
flint_printf("\n");
flint_printf("q = "), TEMPLATE(T, poly_print_pretty) (q, "X", ctx),
flint_printf("\n");
flint_printf("r = "), TEMPLATE(T, poly_print_pretty) (r, "X", ctx),
flint_printf("\n");
fflush(stdout);
flint_abort();
}
TEMPLATE(T, poly_clear) (a, ctx);
TEMPLATE(T, poly_clear) (b, ctx);
TEMPLATE(T, poly_clear) (q, ctx);
TEMPLATE(T, poly_clear) (r, ctx);
TEMPLATE(T, ctx_clear) (ctx);
}
for (i = 0; i < 10 * flint_test_multiplier(); i++)
{
TEMPLATE(T, ctx_t) ctx;
TEMPLATE(T, poly_t) a, b, q, r;
TEMPLATE(T, ctx_init_randtest)(ctx, state, 3);
TEMPLATE(T, poly_init) (a, ctx);
TEMPLATE(T, poly_init) (b, ctx);
TEMPLATE(T, poly_init) (q, ctx);
TEMPLATE(T, poly_init) (r, ctx);
TEMPLATE(T, poly_randtest) (a, state, n_randint(state, 50), ctx);
TEMPLATE(T, poly_randtest_not_zero) (b, state,
n_randint(state, 50) + 1, ctx);
TEMPLATE(T, poly_divrem) (q, r, a, b, ctx);
TEMPLATE(T, poly_divrem) (a, r, a, b, ctx);
result = (TEMPLATE(T, poly_equal) (a, q, ctx));
if (!result)
{
flint_printf("FAIL:\n\n");
flint_printf("a = "), TEMPLATE(T, poly_print_pretty) (a, "X", ctx),
flint_printf("\n");
flint_printf("b = "), TEMPLATE(T, poly_print_pretty) (b, "X", ctx),
flint_printf("\n");
flint_printf("q = "), TEMPLATE(T, poly_print_pretty) (q, "X", ctx),
flint_printf("\n");
flint_printf("r = "), TEMPLATE(T, poly_print_pretty) (r, "X", ctx),
flint_printf("\n");
fflush(stdout);
flint_abort();
}
TEMPLATE(T, poly_clear) (a, ctx);
TEMPLATE(T, poly_clear) (b, ctx);
TEMPLATE(T, poly_clear) (q, ctx);
TEMPLATE(T, poly_clear) (r, ctx);
TEMPLATE(T, ctx_clear) (ctx);
}
for (i = 0; i < 10 * flint_test_multiplier(); i++)
{
TEMPLATE(T, ctx_t) ctx;
TEMPLATE(T, poly_t) a, b, q, r;
TEMPLATE(T, ctx_init_randtest)(ctx, state, 3);
TEMPLATE(T, poly_init) (a, ctx);
TEMPLATE(T, poly_init) (b, ctx);
TEMPLATE(T, poly_init) (q, ctx);
TEMPLATE(T, poly_init) (r, ctx);
TEMPLATE(T, poly_randtest) (a, state, n_randint(state, 50), ctx);
TEMPLATE(T, poly_randtest_not_zero) (b, state,
n_randint(state, 50) + 1, ctx);
TEMPLATE(T, poly_divrem) (q, r, a, b, ctx);
TEMPLATE(T, poly_divrem) (b, r, a, b, ctx);
result = (TEMPLATE(T, poly_equal) (b, q, ctx));
if (!result)
{
flint_printf("FAIL:\n\n");
flint_printf("a = "), TEMPLATE(T, poly_print_pretty) (a, "X", ctx),
flint_printf("\n");
flint_printf("b = "), TEMPLATE(T, poly_print_pretty) (b, "X", ctx),
flint_printf("\n");
flint_printf("q = "), TEMPLATE(T, poly_print_pretty) (q, "X", ctx),
flint_printf("\n");
flint_printf("r = "), TEMPLATE(T, poly_print_pretty) (r, "X", ctx),
flint_printf("\n");
fflush(stdout);
flint_abort();
}
TEMPLATE(T, poly_clear) (a, ctx);
TEMPLATE(T, poly_clear) (b, ctx);
TEMPLATE(T, poly_clear) (q, ctx);
TEMPLATE(T, poly_clear) (r, ctx);
TEMPLATE(T, ctx_clear) (ctx);
}
TEST_FUNCTION_END(state);
}
#endif