add arb_rising/acb_rising and use gamma for large n in rising_ui

This commit is contained in:
Fredrik Johansson 2015-10-17 01:11:58 +02:00
parent ceb8ad55f0
commit 3ba474dd42
6 changed files with 80 additions and 10 deletions

1
acb.h
View file

@ -754,6 +754,7 @@ void acb_rising_ui_bs(acb_t y, const acb_t x, ulong n, long prec);
void acb_rising_ui_rs(acb_t y, const acb_t x, ulong n, ulong m, long prec);
void acb_rising_ui_rec(acb_t y, const acb_t x, ulong n, long prec);
void acb_rising_ui(acb_t z, const acb_t x, ulong n, long prec);
void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec);
void acb_rising2_ui_bs(acb_t u, acb_t v, const acb_t x, ulong n, long prec);
void acb_rising2_ui_rs(acb_t u, acb_t v, const acb_t x, ulong n, ulong m, long prec);

View file

@ -28,6 +28,40 @@
void
acb_rising_ui(acb_t y, const acb_t x, ulong n, long prec)
{
acb_rising_ui_rec(y, x, n, prec);
if (n < FLINT_MAX(prec, 100))
{
acb_rising_ui_rec(y, x, n, prec);
}
else
{
acb_t t;
acb_init(t);
acb_add_ui(t, x, n, prec);
acb_gamma(t, t, prec);
acb_rgamma(y, x, prec);
acb_mul(y, y, t, prec);
acb_clear(t);
}
}
void
acb_rising(acb_t y, const acb_t x, const acb_t n, long prec)
{
if (acb_is_int(n) && arf_sgn(arb_midref(acb_realref(n))) >= 0 &&
arf_cmpabs_ui(arb_midref(acb_realref(n)), FLINT_MAX(prec, 100)) < 0)
{
acb_rising_ui_rec(y, x,
arf_get_si(arb_midref(acb_realref(n)), ARF_RND_DOWN), prec);
}
else
{
acb_t t;
acb_init(t);
acb_add(t, x, n, prec);
acb_gamma(t, t, prec);
acb_rgamma(y, x, prec);
acb_mul(y, y, t, prec);
acb_clear(t);
}
}

1
arb.h
View file

@ -644,6 +644,7 @@ void arb_rising_ui_rs(arb_t y, const arb_t x, ulong n, ulong m, long prec);
void arb_rising_ui_rec(arb_t y, const arb_t x, ulong n, long prec);
void arb_rising_ui(arb_t z, const arb_t x, ulong n, long prec);
void arb_rising_fmpq_ui(arb_t y, const fmpq_t x, ulong n, long prec);
void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec);
void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, ulong n, ulong m, long prec);
void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, ulong n, long prec);

View file

@ -28,6 +28,40 @@
void
arb_rising_ui(arb_t y, const arb_t x, ulong n, long prec)
{
arb_rising_ui_rec(y, x, n, prec);
if (n < FLINT_MAX(prec, 100))
{
arb_rising_ui_rec(y, x, n, prec);
}
else
{
arb_t t;
arb_init(t);
arb_add_ui(t, x, n, prec);
arb_gamma(t, t, prec);
arb_rgamma(y, x, prec);
arb_mul(y, y, t, prec);
arb_clear(t);
}
}
void
arb_rising(arb_t y, const arb_t x, const arb_t n, long prec)
{
if (arb_is_int(n) && arf_sgn(arb_midref(n)) >= 0 &&
arf_cmpabs_ui(arb_midref(n), FLINT_MAX(prec, 100)) < 0)
{
arb_rising_ui_rec(y, x,
arf_get_si(arb_midref(n), ARF_RND_DOWN), prec);
}
else
{
arb_t t;
arb_init(t);
arb_add(t, x, n, prec);
arb_gamma(t, t, prec);
arb_rgamma(y, x, prec);
arb_mul(y, y, t, prec);
arb_clear(t);
}
}

View file

@ -570,14 +570,14 @@ Rising factorials
.. function:: void acb_rising_ui(acb_t z, const acb_t x, ulong n, long prec)
.. function:: void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`.
The *bs* version uses binary splitting. The *rs* version uses rectangular
splitting. The *rec* version uses either *bs* or *rs* depending
on the input.
The default version is currently identical to the *rec* version.
In a future version, it will use the gamma function or asymptotic
series when this is more efficient.
on the input. The default version uses the gamma function unless
*n* is a small integer.
The *rs* version takes an optional *step* parameter for tuning
purposes (to use the default step length, pass zero).

View file

@ -985,14 +985,14 @@ Gamma function and factorials
.. function:: void arb_rising_ui(arb_t z, const arb_t x, ulong n, long prec)
.. function:: void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
Computes the rising factorial `z = x (x+1) (x+2) \cdots (x+n-1)`.
The *bs* version uses binary splitting. The *rs* version uses rectangular
splitting. The *rec* version uses either *bs* or *rs* depending
on the input.
The default version is currently identical to the *rec* version.
In a future version, it will use the gamma function or asymptotic
series when this is more efficient.
on the input. The default version uses the gamma function unless
*n* is a small integer.
The *rs* version takes an optional *step* parameter for tuning
purposes (to use the default step length, pass zero).