1 /*
2     Copyright (C) 2017 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_exp_pi_i_series(acb_ptr f,acb_srcptr h,slong hlen,slong len,slong prec)15 _acb_poly_exp_pi_i_series(acb_ptr f, acb_srcptr h, slong hlen, slong len, slong prec)
16 {
17     hlen = FLINT_MIN(hlen, len);
18 
19     if (hlen == 1)
20     {
21         acb_exp_pi_i(f, h, prec);
22         _acb_vec_zero(f + 1, len - 1);
23     }
24     else if (len == 2)
25     {
26         arb_t t;
27         arb_init(t);
28         arb_const_pi(t, prec);
29         acb_exp_pi_i(f, h, prec);
30         acb_mul_arb(f + 1, h + 1, t, prec);
31         acb_mul_onei(f + 1, f + 1);
32         acb_mul(f + 1, f + 1, f + 0, prec);
33         arb_clear(t);
34     }
35     else
36     {
37         acb_ptr t;
38         t = _acb_vec_init(hlen + 1);
39         acb_const_pi(t, prec);
40         acb_mul_onei(t, t);
41         _acb_vec_scalar_mul(t + 1, h + 1, hlen - 1, t, prec);
42         acb_zero(t);
43         acb_exp_pi_i(t + hlen, h, prec);
44         _acb_poly_exp_series(f, t, hlen, len, prec);
45         _acb_vec_scalar_mul(f, f, len, t + hlen, prec);
46         _acb_vec_clear(t, hlen + 1);
47     }
48 }
49 
50 void
acb_poly_exp_pi_i_series(acb_poly_t f,const acb_poly_t h,slong n,slong prec)51 acb_poly_exp_pi_i_series(acb_poly_t f, const acb_poly_t h, slong n, slong prec)
52 {
53     slong hlen = h->length;
54 
55     if (n == 0)
56     {
57         acb_poly_zero(f);
58         return;
59     }
60 
61     if (hlen == 0)
62     {
63         acb_poly_one(f);
64         return;
65     }
66 
67     if (hlen == 1)
68         n = 1;
69 
70     acb_poly_fit_length(f, n);
71     _acb_poly_exp_pi_i_series(f->coeffs, h->coeffs, hlen, n, prec);
72     _acb_poly_set_length(f, n);
73     _acb_poly_normalise(f);
74 }
75 
76