1 /*
2     Copyright (C) 2021 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_hypgeom.h"
13 
14 static void
bsplit(acb_t y,const acb_t x,ulong a,ulong b,slong prec)15 bsplit(acb_t y, const acb_t x, ulong a, ulong b, slong prec)
16 {
17     if (b - a <= 4)
18     {
19         if (a == 0)
20         {
21             acb_hypgeom_rising_ui_forward(y, x, b, prec);
22         }
23         else
24         {
25             acb_add_ui(y, x, a, prec);
26             acb_hypgeom_rising_ui_forward(y, y, b - a, prec);
27         }
28     }
29     else
30     {
31         acb_t t, u;
32         ulong m = a + (b - a) / 2;
33 
34         acb_init(t);
35         acb_init(u);
36 
37         bsplit(t, x, a, m, prec);
38         bsplit(u, x, m, b, prec);
39 
40         acb_mul(y, t, u, prec);
41 
42         acb_clear(t);
43         acb_clear(u);
44     }
45 }
46 
47 void
acb_hypgeom_rising_ui_bs(acb_t res,const acb_t x,ulong n,slong prec)48 acb_hypgeom_rising_ui_bs(acb_t res, const acb_t x, ulong n, slong prec)
49 {
50     if (n <= 1)
51     {
52         if (n == 0)
53             acb_one(res);
54         else
55             acb_set_round(res, x, prec);
56         return;
57     }
58 
59     {
60         acb_t t;
61         slong wp = ARF_PREC_ADD(prec, FLINT_BIT_COUNT(n));
62 
63         acb_init(t);
64         bsplit(t, x, 0, n, wp);
65         acb_set_round(res, t, prec);
66         acb_clear(t);
67     }
68 }
69 
70