mirror of
https://github.com/vale981/arb
synced 2025-03-05 09:21:38 -05:00
add binomial and borel transforms for acb_poly
This commit is contained in:
parent
04e674da88
commit
e2635824ce
11 changed files with 727 additions and 0 deletions
24
acb_poly.h
24
acb_poly.h
|
@ -171,6 +171,30 @@ void _acb_poly_integral(acb_ptr res, acb_srcptr poly, slong len, slong prec);
|
|||
|
||||
void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, slong prec);
|
||||
|
||||
/* Transforms */
|
||||
|
||||
void acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec);
|
||||
|
||||
void _acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec);
|
||||
|
||||
void acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec);
|
||||
|
||||
void _acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec);
|
||||
|
||||
void _acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec);
|
||||
|
||||
void acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, slong len, slong prec);
|
||||
|
||||
void _acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec);
|
||||
|
||||
void acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, slong len, slong prec);
|
||||
|
||||
void _acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec);
|
||||
|
||||
void acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, slong len, slong prec);
|
||||
|
||||
|
||||
|
||||
void acb_poly_set(acb_poly_t dest, const acb_poly_t src);
|
||||
|
||||
void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, slong prec);
|
||||
|
|
49
acb_poly/binomial_transform.c
Normal file
49
acb_poly/binomial_transform.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
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 "acb_poly.h"
|
||||
|
||||
void
|
||||
_acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec)
|
||||
{
|
||||
if (alen < 10 || len < 10)
|
||||
_acb_poly_binomial_transform_basecase(b, a, alen, len, prec);
|
||||
else
|
||||
_acb_poly_binomial_transform_convolution(b, a, alen, len, prec);
|
||||
}
|
||||
|
||||
void
|
||||
acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, slong len, slong prec)
|
||||
{
|
||||
if (len == 0 || a->length == 0)
|
||||
{
|
||||
acb_poly_zero(b);
|
||||
return;
|
||||
}
|
||||
|
||||
if (b == a)
|
||||
{
|
||||
acb_poly_t c;
|
||||
acb_poly_init2(c, len);
|
||||
_acb_poly_binomial_transform(c->coeffs, a->coeffs, a->length, len, prec);
|
||||
acb_poly_swap(b, c);
|
||||
acb_poly_clear(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
acb_poly_fit_length(b, len);
|
||||
_acb_poly_binomial_transform(b->coeffs, a->coeffs, a->length, len, prec);
|
||||
}
|
||||
|
||||
_acb_poly_set_length(b, len);
|
||||
_acb_poly_normalise(b);
|
||||
}
|
||||
|
71
acb_poly/binomial_transform_basecase.c
Normal file
71
acb_poly/binomial_transform_basecase.c
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
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 "acb_poly.h"
|
||||
|
||||
void
|
||||
_acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec)
|
||||
{
|
||||
slong n, k;
|
||||
|
||||
fmpz_t t;
|
||||
fmpz_init(t);
|
||||
|
||||
for (n = 0; n < len; n++)
|
||||
{
|
||||
acb_zero(b + n);
|
||||
|
||||
for (k = 0; k < FLINT_MIN(n + 1, alen); k++)
|
||||
{
|
||||
if (k == 0)
|
||||
{
|
||||
fmpz_one(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_mul_si(t, t, -(n - k + 1));
|
||||
fmpz_divexact_ui(t, t, k);
|
||||
}
|
||||
|
||||
acb_addmul_fmpz(b + n, a + k, t, prec);
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_clear(t);
|
||||
}
|
||||
|
||||
void
|
||||
acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, slong len, slong prec)
|
||||
{
|
||||
if (len == 0 || a->length == 0)
|
||||
{
|
||||
acb_poly_zero(b);
|
||||
return;
|
||||
}
|
||||
|
||||
if (b == a)
|
||||
{
|
||||
acb_poly_t c;
|
||||
acb_poly_init2(c, len);
|
||||
_acb_poly_binomial_transform_basecase(c->coeffs, a->coeffs, a->length, len, prec);
|
||||
acb_poly_swap(b, c);
|
||||
acb_poly_clear(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
acb_poly_fit_length(b, len);
|
||||
_acb_poly_binomial_transform_basecase(b->coeffs, a->coeffs, a->length, len, prec);
|
||||
}
|
||||
|
||||
_acb_poly_set_length(b, len);
|
||||
_acb_poly_normalise(b);
|
||||
}
|
||||
|
68
acb_poly/binomial_transform_convolution.c
Normal file
68
acb_poly/binomial_transform_convolution.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
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 <math.h>
|
||||
#include "acb_poly.h"
|
||||
|
||||
void
|
||||
_acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec)
|
||||
{
|
||||
slong i;
|
||||
acb_ptr c, d;
|
||||
|
||||
alen = FLINT_MIN(alen, len);
|
||||
|
||||
c = _acb_vec_init(alen);
|
||||
d = _acb_vec_init(len);
|
||||
|
||||
_acb_poly_borel_transform(c, a, alen, prec);
|
||||
for (i = 1; i < alen; i += 2)
|
||||
acb_neg(c + i, c + i);
|
||||
|
||||
acb_one(d);
|
||||
for (i = 1; i < len; i++)
|
||||
acb_div_ui(d + i, d + i - 1, i, prec);
|
||||
|
||||
_acb_poly_mullow(b, d, len, c, alen, len, prec);
|
||||
|
||||
_acb_poly_inv_borel_transform(b, b, len, prec);
|
||||
|
||||
_acb_vec_clear(c, alen);
|
||||
_acb_vec_clear(d, len);
|
||||
}
|
||||
|
||||
void
|
||||
acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, slong len, slong prec)
|
||||
{
|
||||
if (len == 0 || a->length == 0)
|
||||
{
|
||||
acb_poly_zero(b);
|
||||
return;
|
||||
}
|
||||
|
||||
if (b == a)
|
||||
{
|
||||
acb_poly_t c;
|
||||
acb_poly_init2(c, len);
|
||||
_acb_poly_binomial_transform_convolution(c->coeffs, a->coeffs, a->length, len, prec);
|
||||
acb_poly_swap(b, c);
|
||||
acb_poly_clear(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
acb_poly_fit_length(b, len);
|
||||
_acb_poly_binomial_transform_convolution(b->coeffs, a->coeffs, a->length, len, prec);
|
||||
}
|
||||
|
||||
_acb_poly_set_length(b, len);
|
||||
_acb_poly_normalise(b);
|
||||
}
|
||||
|
43
acb_poly/borel_transform.c
Normal file
43
acb_poly/borel_transform.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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 "acb_poly.h"
|
||||
|
||||
void
|
||||
_acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec)
|
||||
{
|
||||
slong i;
|
||||
|
||||
arb_t t;
|
||||
arb_init(t);
|
||||
|
||||
arb_one(t);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (i > 1)
|
||||
arb_mul_ui(t, t, i, prec);
|
||||
|
||||
acb_div_arb(res + i, poly + i, t, prec);
|
||||
}
|
||||
|
||||
arb_clear(t);
|
||||
}
|
||||
|
||||
void
|
||||
acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec)
|
||||
{
|
||||
acb_poly_fit_length(res, poly->length);
|
||||
_acb_poly_borel_transform(res->coeffs, poly->coeffs, poly->length, prec);
|
||||
_acb_poly_set_length(res, poly->length);
|
||||
_acb_poly_normalise(res);
|
||||
}
|
||||
|
43
acb_poly/inv_borel_transform.c
Normal file
43
acb_poly/inv_borel_transform.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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 "acb_poly.h"
|
||||
|
||||
void
|
||||
_acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec)
|
||||
{
|
||||
slong i;
|
||||
|
||||
arb_t t;
|
||||
arb_init(t);
|
||||
|
||||
arb_one(t);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (i > 1)
|
||||
arb_mul_ui(t, t, i, prec);
|
||||
|
||||
acb_mul_arb(res + i, poly + i, t, prec);
|
||||
}
|
||||
|
||||
arb_clear(t);
|
||||
}
|
||||
|
||||
void
|
||||
acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec)
|
||||
{
|
||||
acb_poly_fit_length(res, poly->length);
|
||||
_acb_poly_inv_borel_transform(res->coeffs, poly->coeffs, poly->length, prec);
|
||||
_acb_poly_set_length(res, poly->length);
|
||||
_acb_poly_normalise(res);
|
||||
}
|
||||
|
105
acb_poly/test/t-binomial_transform.c
Normal file
105
acb_poly/test/t-binomial_transform.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
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 "acb_poly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
slong iter;
|
||||
flint_rand_t state;
|
||||
|
||||
flint_printf("binomial_transform....");
|
||||
fflush(stdout);
|
||||
|
||||
flint_randinit(state);
|
||||
|
||||
for (iter = 0; iter < 500 * arb_test_multiplier(); iter++)
|
||||
{
|
||||
acb_poly_t a, b, c, d;
|
||||
slong j, n, prec;
|
||||
|
||||
acb_poly_init(a);
|
||||
acb_poly_init(b);
|
||||
acb_poly_init(c);
|
||||
acb_poly_init(d);
|
||||
|
||||
n = n_randint(state, 20);
|
||||
prec = 2 + n_randint(state, 200);
|
||||
|
||||
acb_poly_randtest(a, state, n, prec, 10);
|
||||
acb_poly_randtest(b, state, n, prec, 10);
|
||||
acb_poly_randtest(c, state, n, prec, 10);
|
||||
|
||||
/* check self-inversion property */
|
||||
acb_poly_binomial_transform(b, a, n, prec);
|
||||
acb_poly_binomial_transform(c, b, n, prec);
|
||||
|
||||
acb_poly_set(d, a);
|
||||
acb_poly_truncate(d, n);
|
||||
|
||||
if (!acb_poly_contains(c, d))
|
||||
{
|
||||
flint_printf("FAIL (containment)\n\n");
|
||||
flint_printf("n = %wd, prec = %wd\n\n", n, prec);
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("c: "); acb_poly_printd(c, 15); flint_printf("\n\n");
|
||||
flint_printf("d: "); acb_poly_printd(d, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_set(d, a);
|
||||
acb_poly_binomial_transform(d, d, n, prec);
|
||||
if (!acb_poly_equal(d, b))
|
||||
{
|
||||
flint_printf("FAIL (aliasing)\n\n");
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("d: "); acb_poly_printd(d, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
/* compare with power series operations */
|
||||
acb_poly_zero(d);
|
||||
for (j = 1; j < n; j++)
|
||||
acb_poly_set_coeff_si(d, j, -1);
|
||||
acb_poly_compose_series(c, a, d, n, prec);
|
||||
for (j = 0; j < n; j++)
|
||||
acb_poly_set_coeff_si(d, j, 1);
|
||||
acb_poly_mullow(c, c, d, n, prec);
|
||||
|
||||
if (!acb_poly_overlaps(b, c))
|
||||
{
|
||||
flint_printf("FAIL (power series)\n\n");
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("c: "); acb_poly_printd(c, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_clear(a);
|
||||
acb_poly_clear(b);
|
||||
acb_poly_clear(c);
|
||||
acb_poly_clear(d);
|
||||
}
|
||||
|
||||
flint_randclear(state);
|
||||
flint_cleanup();
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
105
acb_poly/test/t-binomial_transform_basecase.c
Normal file
105
acb_poly/test/t-binomial_transform_basecase.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
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 "acb_poly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
slong iter;
|
||||
flint_rand_t state;
|
||||
|
||||
flint_printf("binomial_transform_basecase....");
|
||||
fflush(stdout);
|
||||
|
||||
flint_randinit(state);
|
||||
|
||||
for (iter = 0; iter < 500 * arb_test_multiplier(); iter++)
|
||||
{
|
||||
acb_poly_t a, b, c, d;
|
||||
slong j, n, prec;
|
||||
|
||||
acb_poly_init(a);
|
||||
acb_poly_init(b);
|
||||
acb_poly_init(c);
|
||||
acb_poly_init(d);
|
||||
|
||||
n = n_randint(state, 20);
|
||||
prec = 2 + n_randint(state, 200);
|
||||
|
||||
acb_poly_randtest(a, state, n, prec, 10);
|
||||
acb_poly_randtest(b, state, n, prec, 10);
|
||||
acb_poly_randtest(c, state, n, prec, 10);
|
||||
|
||||
/* check self-inversion property */
|
||||
acb_poly_binomial_transform_basecase(b, a, n, prec);
|
||||
acb_poly_binomial_transform_basecase(c, b, n, prec);
|
||||
|
||||
acb_poly_set(d, a);
|
||||
acb_poly_truncate(d, n);
|
||||
|
||||
if (!acb_poly_contains(c, d))
|
||||
{
|
||||
flint_printf("FAIL (containment)\n\n");
|
||||
flint_printf("n = %wd, prec = %wd\n\n", n, prec);
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("c: "); acb_poly_printd(c, 15); flint_printf("\n\n");
|
||||
flint_printf("d: "); acb_poly_printd(d, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_set(d, a);
|
||||
acb_poly_binomial_transform_basecase(d, d, n, prec);
|
||||
if (!acb_poly_equal(d, b))
|
||||
{
|
||||
flint_printf("FAIL (aliasing)\n\n");
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("d: "); acb_poly_printd(d, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
/* compare with power series operations */
|
||||
acb_poly_zero(d);
|
||||
for (j = 1; j < n; j++)
|
||||
acb_poly_set_coeff_si(d, j, -1);
|
||||
acb_poly_compose_series(c, a, d, n, prec);
|
||||
for (j = 0; j < n; j++)
|
||||
acb_poly_set_coeff_si(d, j, 1);
|
||||
acb_poly_mullow(c, c, d, n, prec);
|
||||
|
||||
if (!acb_poly_overlaps(b, c))
|
||||
{
|
||||
flint_printf("FAIL (power series)\n\n");
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("c: "); acb_poly_printd(c, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_clear(a);
|
||||
acb_poly_clear(b);
|
||||
acb_poly_clear(c);
|
||||
acb_poly_clear(d);
|
||||
}
|
||||
|
||||
flint_randclear(state);
|
||||
flint_cleanup();
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
105
acb_poly/test/t-binomial_transform_convolution.c
Normal file
105
acb_poly/test/t-binomial_transform_convolution.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
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 "acb_poly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
slong iter;
|
||||
flint_rand_t state;
|
||||
|
||||
flint_printf("binomial_transform_convolution....");
|
||||
fflush(stdout);
|
||||
|
||||
flint_randinit(state);
|
||||
|
||||
for (iter = 0; iter < 500 * arb_test_multiplier(); iter++)
|
||||
{
|
||||
acb_poly_t a, b, c, d;
|
||||
slong j, n, prec;
|
||||
|
||||
acb_poly_init(a);
|
||||
acb_poly_init(b);
|
||||
acb_poly_init(c);
|
||||
acb_poly_init(d);
|
||||
|
||||
n = n_randint(state, 20);
|
||||
prec = 2 + n_randint(state, 200);
|
||||
|
||||
acb_poly_randtest(a, state, n, prec, 10);
|
||||
acb_poly_randtest(b, state, n, prec, 10);
|
||||
acb_poly_randtest(c, state, n, prec, 10);
|
||||
|
||||
/* check self-inversion property */
|
||||
acb_poly_binomial_transform_convolution(b, a, n, prec);
|
||||
acb_poly_binomial_transform_convolution(c, b, n, prec);
|
||||
|
||||
acb_poly_set(d, a);
|
||||
acb_poly_truncate(d, n);
|
||||
|
||||
if (!acb_poly_contains(c, d))
|
||||
{
|
||||
flint_printf("FAIL (containment)\n\n");
|
||||
flint_printf("n = %wd, prec = %wd\n\n", n, prec);
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("c: "); acb_poly_printd(c, 15); flint_printf("\n\n");
|
||||
flint_printf("d: "); acb_poly_printd(d, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_set(d, a);
|
||||
acb_poly_binomial_transform_convolution(d, d, n, prec);
|
||||
if (!acb_poly_equal(d, b))
|
||||
{
|
||||
flint_printf("FAIL (aliasing)\n\n");
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("d: "); acb_poly_printd(d, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
/* compare with power series operations */
|
||||
acb_poly_zero(d);
|
||||
for (j = 1; j < n; j++)
|
||||
acb_poly_set_coeff_si(d, j, -1);
|
||||
acb_poly_compose_series(c, a, d, n, prec);
|
||||
for (j = 0; j < n; j++)
|
||||
acb_poly_set_coeff_si(d, j, 1);
|
||||
acb_poly_mullow(c, c, d, n, prec);
|
||||
|
||||
if (!acb_poly_overlaps(b, c))
|
||||
{
|
||||
flint_printf("FAIL (power series)\n\n");
|
||||
|
||||
flint_printf("a: "); acb_poly_printd(a, 15); flint_printf("\n\n");
|
||||
flint_printf("b: "); acb_poly_printd(b, 15); flint_printf("\n\n");
|
||||
flint_printf("c: "); acb_poly_printd(c, 15); flint_printf("\n\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_clear(a);
|
||||
acb_poly_clear(b);
|
||||
acb_poly_clear(c);
|
||||
acb_poly_clear(d);
|
||||
}
|
||||
|
||||
flint_randclear(state);
|
||||
flint_cleanup();
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
77
acb_poly/test/t-borel_transform.c
Normal file
77
acb_poly/test/t-borel_transform.c
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
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 "acb_poly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
slong iter;
|
||||
flint_rand_t state;
|
||||
|
||||
flint_printf("borel_transform....");
|
||||
fflush(stdout);
|
||||
|
||||
flint_randinit(state);
|
||||
|
||||
for (iter = 0; iter < 500 * arb_test_multiplier(); iter++)
|
||||
{
|
||||
acb_poly_t a, b, c, d;
|
||||
slong n, prec;
|
||||
|
||||
acb_poly_init(a);
|
||||
acb_poly_init(b);
|
||||
acb_poly_init(c);
|
||||
acb_poly_init(d);
|
||||
|
||||
n = n_randint(state, 30);
|
||||
prec = n_randint(state, 200);
|
||||
|
||||
acb_poly_randtest(a, state, n, prec, 10);
|
||||
acb_poly_randtest(b, state, n, prec, 10);
|
||||
acb_poly_randtest(c, state, n, prec, 10);
|
||||
|
||||
acb_poly_borel_transform(b, a, prec);
|
||||
acb_poly_inv_borel_transform(c, b, prec);
|
||||
|
||||
if (!acb_poly_contains(c, a))
|
||||
{
|
||||
flint_printf("FAIL (containment)\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_set(d, a);
|
||||
acb_poly_borel_transform(d, d, prec);
|
||||
if (!acb_poly_equal(d, b))
|
||||
{
|
||||
flint_printf("FAIL (aliasing 1)\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_set(d, b);
|
||||
acb_poly_inv_borel_transform(d, d, prec);
|
||||
if (!acb_poly_equal(d, c))
|
||||
{
|
||||
flint_printf("FAIL (aliasing 2)\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
acb_poly_clear(a);
|
||||
acb_poly_clear(b);
|
||||
acb_poly_clear(c);
|
||||
acb_poly_clear(d);
|
||||
}
|
||||
|
||||
flint_randclear(state);
|
||||
flint_cleanup();
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -614,6 +614,43 @@ Differentiation
|
|||
Sets *res* to the integral of *poly*.
|
||||
|
||||
|
||||
Transforms
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
.. function:: void _acb_poly_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec)
|
||||
|
||||
.. function:: void acb_poly_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec)
|
||||
|
||||
Computes the Borel transform of the input polynomial, mapping `\sum_k a_k x^k`
|
||||
to `\sum_k (a_k / k!) x^k`. The underscore method allows aliasing.
|
||||
|
||||
.. function:: void _acb_poly_inv_borel_transform(acb_ptr res, acb_srcptr poly, slong len, slong prec)
|
||||
|
||||
.. function:: void acb_poly_inv_borel_transform(acb_poly_t res, const acb_poly_t poly, slong prec)
|
||||
|
||||
Computes the inverse Borel transform of the input polynomial, mapping `\sum_k a_k x^k`
|
||||
to `\sum_k a_k k! x^k`. The underscore method allows aliasing.
|
||||
|
||||
.. function:: void _acb_poly_binomial_transform_basecase(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec)
|
||||
|
||||
.. function:: void acb_poly_binomial_transform_basecase(acb_poly_t b, const acb_poly_t a, slong len, slong prec)
|
||||
|
||||
.. function:: void _acb_poly_binomial_transform_convolution(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec)
|
||||
|
||||
.. function:: void acb_poly_binomial_transform_convolution(acb_poly_t b, const acb_poly_t a, slong len, slong prec)
|
||||
|
||||
.. function:: void _acb_poly_binomial_transform(acb_ptr b, acb_srcptr a, slong alen, slong len, slong prec)
|
||||
|
||||
.. function:: void acb_poly_binomial_transform(acb_poly_t b, const acb_poly_t a, slong len, slong prec)
|
||||
|
||||
Computes the binomial transform of the input polynomial, truncating
|
||||
the output to length *len*. See :func:`arb_poly_binomial_transform` for
|
||||
details.
|
||||
|
||||
The underscore methods do not support aliasing, and assume that
|
||||
the lengths are nonzero.
|
||||
|
||||
|
||||
Elementary functions
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue