1 /*
2 Copyright (C) 2013 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_revert_series(acb_ptr Qinv,acb_srcptr Q,slong Qlen,slong n,slong prec)15 _acb_poly_revert_series(acb_ptr Qinv,
16 acb_srcptr Q, slong Qlen, slong n, slong prec)
17 {
18 _acb_poly_revert_series_lagrange_fast(Qinv, Q, Qlen, n, prec);
19 }
20
21 void
acb_poly_revert_series(acb_poly_t Qinv,const acb_poly_t Q,slong n,slong prec)22 acb_poly_revert_series(acb_poly_t Qinv,
23 const acb_poly_t Q, slong n, slong prec)
24 {
25 slong Qlen = Q->length;
26
27 if (Qlen < 2 || !acb_is_zero(Q->coeffs)
28 || acb_contains_zero(Q->coeffs + 1))
29 {
30 flint_printf("Exception (acb_poly_revert_series). Input must \n"
31 "have zero constant term and nonzero coefficient of x^1.\n");
32 flint_abort();
33 }
34
35 if (Qinv != Q)
36 {
37 acb_poly_fit_length(Qinv, n);
38 _acb_poly_revert_series(Qinv->coeffs, Q->coeffs, Qlen, n, prec);
39 }
40 else
41 {
42 acb_poly_t t;
43 acb_poly_init2(t, n);
44 _acb_poly_revert_series(t->coeffs, Q->coeffs, Qlen, n, prec);
45 acb_poly_swap(Qinv, t);
46 acb_poly_clear(t);
47 }
48
49 _acb_poly_set_length(Qinv, n);
50 _acb_poly_normalise(Qinv);
51 }
52
53