1 /*
2 Copyright (C) 2016 Fredrik Johansson
3
4 This file is part of Arb.
5
6 Arb is free software: you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License (LGPL) as published
8 by the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version. See <http://www.gnu.org/licenses/>.
10 */
11
12 #include "acb_poly.h"
13
14 void
_acb_poly_taylor_shift_horner(acb_ptr poly,const acb_t c,slong n,slong prec)15 _acb_poly_taylor_shift_horner(acb_ptr poly, const acb_t c, slong n, slong prec)
16 {
17 slong i, j;
18
19 if (acb_is_one(c))
20 {
21 for (i = n - 2; i >= 0; i--)
22 for (j = i; j < n - 1; j++)
23 acb_add(poly + j, poly + j, poly + j + 1, prec);
24 }
25 else if (acb_equal_si(c, -1))
26 {
27 for (i = n - 2; i >= 0; i--)
28 for (j = i; j < n - 1; j++)
29 acb_sub(poly + j, poly + j, poly + j + 1, prec);
30 }
31 else if (!acb_is_zero(c))
32 {
33 for (i = n - 2; i >= 0; i--)
34 for (j = i; j < n - 1; j++)
35 acb_addmul(poly + j, poly + j + 1, c, prec);
36 }
37 }
38
39 void
acb_poly_taylor_shift_horner(acb_poly_t g,const acb_poly_t f,const acb_t c,slong prec)40 acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f,
41 const acb_t c, slong prec)
42 {
43 if (f != g)
44 acb_poly_set_round(g, f, prec);
45
46 _acb_poly_taylor_shift_horner(g->coeffs, c, g->length, prec);
47 }
48
49