2016-10-11 17:15:38 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2016 Pascal Molin
|
|
|
|
|
|
|
|
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 "acb_dft.h"
|
|
|
|
|
|
|
|
typedef void (*do_f) (acb_ptr z, acb_srcptr x, acb_srcptr y, slong len, slong prec);
|
|
|
|
|
|
|
|
void
|
|
|
|
check_vec_eq_prec(acb_srcptr w1, acb_srcptr w2, slong len, slong prec, slong digits, ulong q, char f1[], char f2[])
|
|
|
|
{
|
|
|
|
slong i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
if (!acb_overlaps(w1 + i, w2 + i))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL\n\n");
|
|
|
|
flint_printf("q = %wu, size = %wu\n", q, len);
|
|
|
|
flint_printf("\nDFT differ from index %ld / %ld \n", i, len);
|
|
|
|
flint_printf("\n%s =\n", f1);
|
|
|
|
acb_vec_printd_index(w1, len, digits);
|
|
|
|
flint_printf("\n%s =\n", f2);
|
|
|
|
acb_vec_printd_index(w2, len, digits);
|
|
|
|
flint_printf("\n\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
else if (!acb_is_zero(w1+i) && (acb_rel_accuracy_bits(w1 + i) < 30
|
|
|
|
|| acb_rel_accuracy_bits(w2 + i) < 30))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL\n\n");
|
|
|
|
flint_printf("q = %wu\n", q);
|
|
|
|
flint_printf("\nDFT inaccurate from index %ld / %ld \n", i, len);
|
2017-10-06 17:51:21 +02:00
|
|
|
flint_printf("\n%s =\n", f1);
|
2016-10-11 17:15:38 +02:00
|
|
|
acb_printd(w1 + i, digits);
|
2017-10-06 17:51:21 +02:00
|
|
|
flint_printf("\n%s =\n", f2);
|
2016-10-11 17:15:38 +02:00
|
|
|
acb_printd(w2 + i, digits);
|
|
|
|
flint_printf("\nerrors %ld & %ld [prec = %wu]\n",
|
|
|
|
acb_rel_accuracy_bits(w1 + i),
|
|
|
|
acb_rel_accuracy_bits(w2 + i), prec);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
|
|
|
|
slong k;
|
|
|
|
slong prec = 100, digits = 30;
|
2017-10-23 09:45:01 +02:00
|
|
|
slong nq = 17;
|
|
|
|
ulong q[17] = { 0, 1, 2, 3, 4, 5, 6, 23, 10, 15, 30, 59, 256, 308, 335, 344, 961};
|
|
|
|
ulong nr = 5;
|
2016-10-11 17:15:38 +02:00
|
|
|
flint_rand_t state;
|
|
|
|
|
2017-10-29 00:52:56 +02:00
|
|
|
slong f, nf = 4;
|
|
|
|
do_f func[4] = { acb_dft_convol_naive, acb_dft_convol_rad2, acb_dft_convol_dft, acb_dft_convol_mullow };
|
|
|
|
char * name[4] = { "naive", "rad2", "dft", "mullow" };
|
2016-10-11 17:15:38 +02:00
|
|
|
|
|
|
|
flint_printf("convol....");
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
2017-10-23 09:45:01 +02:00
|
|
|
for (k = 0; k < nq + nr; k++)
|
2016-10-11 17:15:38 +02:00
|
|
|
{
|
2017-10-23 09:45:01 +02:00
|
|
|
slong i, len;
|
2016-10-11 17:15:38 +02:00
|
|
|
acb_ptr z1, z2, x, y;
|
|
|
|
|
2017-10-23 09:45:01 +02:00
|
|
|
if (k < nq)
|
|
|
|
len = q[k];
|
|
|
|
else
|
|
|
|
len = n_randint(state, 2000);
|
|
|
|
|
|
|
|
z1 = _acb_vec_init(len);
|
|
|
|
z2 = _acb_vec_init(len);
|
|
|
|
x = _acb_vec_init(len);
|
|
|
|
y = _acb_vec_init(len);
|
2016-10-11 17:15:38 +02:00
|
|
|
|
2017-10-23 09:45:01 +02:00
|
|
|
for (i = 0; i < len; i++)
|
2016-10-11 17:15:38 +02:00
|
|
|
{
|
2017-10-29 00:37:27 +02:00
|
|
|
#if 1
|
|
|
|
acb_set_si(x + i, n_randint(state, 4 * len));
|
|
|
|
acb_set_si(y + i, n_randint(state, 4 * len));
|
|
|
|
#else
|
|
|
|
acb_set_si_si(x + i, n_randint(state, 4 * len), n_randint(state, 4 * len));
|
|
|
|
acb_set_si_si(y + i, n_randint(state, 4 * len), n_randint(state, 4 * len));
|
|
|
|
#endif
|
2016-10-11 17:15:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (f = 0; f < nf; f++)
|
|
|
|
{
|
|
|
|
|
|
|
|
acb_ptr z = (f == 0) ? z1 : z2;
|
|
|
|
|
2017-10-23 09:45:01 +02:00
|
|
|
func[f](z, x, y, len, prec);
|
2016-10-11 17:15:38 +02:00
|
|
|
|
|
|
|
if (f == 0)
|
|
|
|
continue;
|
|
|
|
|
2017-10-23 09:45:01 +02:00
|
|
|
check_vec_eq_prec(z1, z2, len, prec, digits, len, name[0], name[f]);
|
2016-10-11 17:15:38 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-10-23 09:45:01 +02:00
|
|
|
_acb_vec_clear(x, len);
|
|
|
|
_acb_vec_clear(y, len);
|
|
|
|
_acb_vec_clear(z1, len);
|
|
|
|
_acb_vec_clear(z2, len);
|
2016-10-11 17:15:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
|
|
|
flint_printf("PASS\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|