1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
Copyright (C) 2013 Fredrik Johansson
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/
#include "arb.h"
static void
bsplit(arb_t y, const fmpz_t p, const fmpz_t q, ulong a, ulong b, slong prec)
{
if (b - a <= 8)
{
fmpz_t t, u;
ulong c;
fmpz_init(t);
fmpz_init(u);
fmpz_mul_ui(t, q, a);
fmpz_add(t, t, p);
fmpz_set(u, t);
for (c = a + 1; c < b; c++)
{
fmpz_add(u, u, q);
fmpz_mul(t, t, u);
}
arb_set_round_fmpz(y, t, prec);
fmpz_clear(t);
fmpz_clear(u);
}
else
{
arb_t w;
ulong m = a + (b - a) / 2;
arb_init(w);
bsplit(y, p, q, a, m, prec);
bsplit(w, p, q, m, b, prec);
arb_mul(y, y, w, prec);
arb_clear(w);
}
}
void
arb_rising_fmpq_ui(arb_t y, const fmpq_t x, ulong n, slong prec)
{
if (n == 0)
{
arb_one(y);
}
else if (n == 1)
{
arb_set_fmpq(y, x, prec);
}
else
{
slong wp;
wp = ARF_PREC_ADD(prec, FLINT_BIT_COUNT(n));
bsplit(y, fmpq_numref(x), fmpq_denref(x), 0, n, wp);
if (fmpz_is_one(fmpq_denref(x)))
{
arb_set_round(y, y, prec);
}
else
{
arb_t t;
arb_init(t);
arb_set_fmpz(t, fmpq_denref(x));
arb_pow_ui(t, t, n, wp);
arb_div(y, y, t, prec);
arb_clear(t);
}
}
}