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_sinh_series(acb_ptr g,acb_srcptr h,slong hlen,slong n,slong prec)15 _acb_poly_sinh_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec)
16 {
17 hlen = FLINT_MIN(hlen, n);
18
19 if (hlen == 1)
20 {
21 acb_sinh(g, h, prec);
22 _acb_vec_zero(g + 1, n - 1);
23 }
24 else if (n == 2)
25 {
26 acb_t t;
27 acb_init(t);
28 acb_sinh_cosh(g, t, h, prec);
29 acb_mul(g + 1, h + 1, t, prec); /* safe since hlen >= 2 */
30 acb_clear(t);
31 }
32 else
33 {
34 acb_ptr t = _acb_vec_init(n);
35 _acb_poly_sinh_cosh_series(g, t, h, hlen, n, prec);
36 _acb_vec_clear(t, n);
37 }
38 }
39
40 void
acb_poly_sinh_series(acb_poly_t g,const acb_poly_t h,slong n,slong prec)41 acb_poly_sinh_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec)
42 {
43 slong hlen = h->length;
44
45 if (hlen == 0 || n == 0)
46 {
47 acb_poly_zero(g);
48 return;
49 }
50
51 if (hlen == 1)
52 n = 1;
53
54 acb_poly_fit_length(g, n);
55 _acb_poly_sinh_series(g->coeffs, h->coeffs, hlen, n, prec);
56 _acb_poly_set_length(g, n);
57 _acb_poly_normalise(g);
58 }
59
60