pqc/external/flint-2.4.3/fmpz_poly_q/test/t-pow.c

51 lines
1.0 KiB
C
Raw Normal View History

2014-05-18 22:03:37 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include "fmpz_poly_q.h"
#include "ulong_extras.h"
int
main(void)
{
int i, result;
FLINT_TEST_INIT(state);
flint_printf("pow... ");
fflush(stdout);
/* Check aliasing of a and b */
for (i = 0; i < 100; i++)
{
fmpz_poly_q_t a, b;
ulong e;
fmpz_poly_q_init(a);
fmpz_poly_q_init(b);
fmpz_poly_q_randtest(b, state, n_randint(state, 10), 10, n_randint(state, 10), 10);
e = n_randint(state, 10);
fmpz_poly_q_pow(a, b, e);
fmpz_poly_q_pow(b, b, e);
result = fmpz_poly_q_equal(a, b) && fmpz_poly_q_is_canonical(a);
if (!result)
{
flint_printf("FAIL:\n");
fmpz_poly_q_print(a), flint_printf("\n\n");
fmpz_poly_q_print(b), flint_printf("\n\n");
abort();
}
fmpz_poly_q_clear(a);
fmpz_poly_q_clear(b);
}
FLINT_TEST_CLEANUP(state);
flint_printf("PASS\n");
return EXIT_SUCCESS;
}