2021-07-27 14:12:42 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2013 Fredrik Johansson
|
|
|
|
|
|
|
|
This file is part of Arb.
|
|
|
|
|
|
|
|
Arb is free software: you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
|
|
|
by the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "arb_poly.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
slong iter;
|
|
|
|
flint_rand_t state;
|
2021-07-28 16:21:59 +02:00
|
|
|
arb_poly_t a, b, c;
|
2021-07-28 18:29:33 +02:00
|
|
|
arb_ptr roots;
|
2021-07-28 19:34:15 +02:00
|
|
|
arb_t leading;
|
2021-07-27 14:12:42 +02:00
|
|
|
|
|
|
|
flint_printf("graeffe_transform....");
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
|
|
|
arb_poly_init(a);
|
|
|
|
arb_poly_init(b);
|
|
|
|
arb_poly_init(c);
|
|
|
|
|
2021-07-28 19:34:15 +02:00
|
|
|
arb_init(leading);
|
|
|
|
|
2021-07-27 18:59:01 +02:00
|
|
|
for (iter = 0; iter < 200 * arb_test_multiplier(); iter++)
|
2021-07-27 14:12:42 +02:00
|
|
|
{
|
|
|
|
slong n, prec, i;
|
2021-07-28 16:21:59 +02:00
|
|
|
|
2021-07-27 18:59:01 +02:00
|
|
|
n = n_randint(state, 20);
|
|
|
|
prec = 2 + n_randint(state, 256);
|
2021-07-27 14:12:42 +02:00
|
|
|
|
|
|
|
roots = _arb_vec_init(n);
|
|
|
|
|
2021-07-28 19:34:15 +02:00
|
|
|
arb_randtest(leading, state, prec, n_randint(state, 16));
|
|
|
|
|
2021-07-27 18:59:01 +02:00
|
|
|
for (i = 0; i < n; i++)
|
2021-07-28 19:34:15 +02:00
|
|
|
arb_randtest(roots + i, state, prec, n_randint(state, 16));
|
2021-07-27 14:12:42 +02:00
|
|
|
arb_poly_product_roots(a, roots, n, prec);
|
2021-07-28 19:34:15 +02:00
|
|
|
arb_poly_scalar_mul(a, a, leading, prec);
|
2021-07-27 14:12:42 +02:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
2021-07-28 19:34:15 +02:00
|
|
|
arb_sqr(roots + i, roots + i, prec);
|
|
|
|
arb_sqr(leading, leading, prec);
|
2021-07-27 14:12:42 +02:00
|
|
|
arb_poly_product_roots(c, roots, n, prec);
|
2021-07-28 19:34:15 +02:00
|
|
|
arb_poly_scalar_mul(c, c, leading, prec);
|
2021-07-27 14:12:42 +02:00
|
|
|
|
|
|
|
arb_poly_graeffe_transform(b, a, prec);
|
|
|
|
if (!arb_poly_overlaps(b, c))
|
|
|
|
{
|
2021-07-28 16:21:59 +02:00
|
|
|
flint_printf("FAIL (overlap)\n\n");
|
2021-07-27 14:12:42 +02:00
|
|
|
flint_printf("n = %wd, prec = %wd\n\n", n, prec);
|
|
|
|
|
|
|
|
flint_printf("a: "); arb_poly_printd(a, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("b: "); arb_poly_printd(b, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("c: "); arb_poly_printd(c, 15); flint_printf("\n\n");
|
|
|
|
|
|
|
|
flint_abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
arb_poly_graeffe_transform(a, a, prec);
|
|
|
|
if (!arb_poly_equal(a, b))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL (aliasing)\n\n");
|
|
|
|
flint_printf("n = %wd, prec = %wd\n\n", n, prec);
|
|
|
|
|
|
|
|
flint_printf("a: "); arb_poly_printd(a, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("b: "); arb_poly_printd(b, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("c: "); arb_poly_printd(c, 15); flint_printf("\n\n");
|
|
|
|
|
|
|
|
flint_abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
_arb_vec_clear(roots, n);
|
|
|
|
}
|
|
|
|
|
|
|
|
arb_poly_clear(a);
|
|
|
|
arb_poly_clear(b);
|
|
|
|
arb_poly_clear(c);
|
|
|
|
|
2021-07-28 19:34:15 +02:00
|
|
|
arb_clear(leading);
|
|
|
|
|
2021-07-27 14:12:42 +02:00
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
|
|
|
flint_printf("PASS\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|