From 512d72b2e4732a0b3e809cd0a4e4fd9d1c8a9a3b Mon Sep 17 00:00:00 2001 From: fredrik Date: Thu, 23 Sep 2021 16:04:31 +0200 Subject: [PATCH] wrap more functions --- arb_fpwrap.h | 102 +++++++ arb_fpwrap/fpwrap.c | 625 ++++++++++++++++++++++++++++++++++---- doc/source/arb_fpwrap.rst | 128 ++++++++ 3 files changed, 803 insertions(+), 52 deletions(-) diff --git a/arb_fpwrap.h b/arb_fpwrap.h index 799cf433..f40fffed 100644 --- a/arb_fpwrap.h +++ b/arb_fpwrap.h @@ -39,6 +39,86 @@ typedef struct } complex_double; +int arb_fpwrap_double_exp(double * res, double x, int flags); +int arb_fpwrap_cdouble_exp(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_expm1(double * res, double x, int flags); +int arb_fpwrap_cdouble_expm1(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_log(double * res, double x, int flags); +int arb_fpwrap_cdouble_log(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_log1p(double * res, double x, int flags); +int arb_fpwrap_cdouble_log1p(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_sqrt(double * res, double x, int flags); +int arb_fpwrap_cdouble_sqrt(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_rsqrt(double * res, double x, int flags); +int arb_fpwrap_cdouble_rsqrt(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_cbrt(double * res, double x, int flags); +int arb_fpwrap_cdouble_cbrt(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_sin(double * res, double x, int flags); +int arb_fpwrap_cdouble_sin(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_cos(double * res, double x, int flags); +int arb_fpwrap_cdouble_cos(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_tan(double * res, double x, int flags); +int arb_fpwrap_cdouble_tan(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_cot(double * res, double x, int flags); +int arb_fpwrap_cdouble_cot(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_sec(double * res, double x, int flags); +int arb_fpwrap_cdouble_sec(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_csc(double * res, double x, int flags); +int arb_fpwrap_cdouble_csc(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_sinc(double * res, double x, int flags); +int arb_fpwrap_cdouble_sinc(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_sin_pi(double * res, double x, int flags); +int arb_fpwrap_cdouble_sin_pi(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_cos_pi(double * res, double x, int flags); +int arb_fpwrap_cdouble_cos_pi(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_tan_pi(double * res, double x, int flags); +int arb_fpwrap_cdouble_tan_pi(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_cot_pi(double * res, double x, int flags); +int arb_fpwrap_cdouble_cot_pi(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_sinc_pi(double * res, double x, int flags); +int arb_fpwrap_cdouble_sinc_pi(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_asin(double * res, double x, int flags); +int arb_fpwrap_cdouble_asin(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_acos(double * res, double x, int flags); +int arb_fpwrap_cdouble_acos(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_atan(double * res, double x, int flags); +int arb_fpwrap_cdouble_atan(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_atan2(double * res, double x1, double x2, int flags); + +int arb_fpwrap_double_asinh(double * res, double x, int flags); +int arb_fpwrap_cdouble_asinh(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_acosh(double * res, double x, int flags); +int arb_fpwrap_cdouble_acosh(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_atanh(double * res, double x, int flags); +int arb_fpwrap_cdouble_atanh(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_rising(double * res, double x, double n, int flags); +int arb_fpwrap_cdouble_rising(complex_double * res, complex_double x, complex_double n, int flags); + int arb_fpwrap_double_gamma(double * res, double x, int flags); int arb_fpwrap_cdouble_gamma(complex_double * res, complex_double x, int flags); @@ -54,6 +134,28 @@ int arb_fpwrap_cdouble_digamma(complex_double * res, complex_double x, int flags int arb_fpwrap_double_zeta(double * res, double x, int flags); int arb_fpwrap_cdouble_zeta(complex_double * res, complex_double x, int flags); +int arb_fpwrap_double_hurwitz_zeta(double * res, double s, double z, int flags); +int arb_fpwrap_cdouble_hurwitz_zeta(complex_double * res, complex_double s, complex_double z, int flags); + +int arb_fpwrap_double_barnes_g(double * res, double x, int flags); +int arb_fpwrap_cdouble_barnes_g(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_log_barnes_g(double * res, double x, int flags); +int arb_fpwrap_cdouble_log_barnes_g(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_polygamma(double * res, double s, double z, int flags); +int arb_fpwrap_cdouble_polygamma(complex_double * res, complex_double s, complex_double z, int flags); + +int arb_fpwrap_double_polylog(double * res, double s, double z, int flags); +int arb_fpwrap_cdouble_polylog(complex_double * res, complex_double s, complex_double z, int flags); + +int arb_fpwrap_double_agm1(double * res, double x, int flags); +int arb_fpwrap_cdouble_agm1(complex_double * res, complex_double x, int flags); + +int arb_fpwrap_double_agm(double * res, double x, double y, int flags); +int arb_fpwrap_cdouble_agm(complex_double * res, complex_double x, complex_double y, int flags); + + #ifdef __cplusplus } diff --git a/arb_fpwrap/fpwrap.c b/arb_fpwrap/fpwrap.c index 1b6b80d2..b7cf0a5e 100644 --- a/arb_fpwrap/fpwrap.c +++ b/arb_fpwrap/fpwrap.c @@ -104,9 +104,16 @@ double_wp_max(int flags) typedef void (*arb_func_1)(arb_t, const arb_t, slong prec); -typedef void (*acb_func_1)(acb_t, const acb_t, slong prec); +typedef void (*arb_func_2)(arb_t, const arb_t, const arb_t, slong prec); +typedef void (*arb_func_3)(arb_t, const arb_t, const arb_t, const arb_t, slong prec); +typedef void (*arb_func_4)(arb_t, const arb_t, const arb_t, const arb_t, const arb_t, slong prec); -int arb_fpwrap_double(double * res, arb_func_1 func, double x, int flags) +typedef void (*acb_func_1)(acb_t, const acb_t, slong prec); +typedef void (*acb_func_2)(acb_t, const acb_t, const acb_t, slong prec); +typedef void (*acb_func_3)(acb_t, const acb_t, const acb_t, const acb_t, slong prec); +typedef void (*acb_func_4)(acb_t, const acb_t, const acb_t, const acb_t, const acb_t, slong prec); + +int arb_fpwrap_double_1(double * res, arb_func_1 func, double x, int flags) { arb_t arb_res, arb_x; slong wp; @@ -119,27 +126,28 @@ int arb_fpwrap_double(double * res, arb_func_1 func, double x, int flags) if (!arb_is_finite(arb_x)) { - arb_clear(arb_x); *res = D_NAN; - return FPWRAP_UNABLE; + status = FPWRAP_UNABLE; } - - for (wp = WP_INITIAL; ; wp *= 2) + else { - func(arb_res, arb_x, wp); - - if (arb_accurate_enough_d(arb_res, flags)) + for (wp = WP_INITIAL; ; wp *= 2) { - *res = arf_get_d(arb_midref(arb_res), ARF_RND_NEAR); - status = FPWRAP_SUCCESS; - break; - } + func(arb_res, arb_x, wp); - if (wp >= double_wp_max(flags)) - { - *res = D_NAN; - status = FPWRAP_UNABLE; - break; + if (arb_accurate_enough_d(arb_res, flags)) + { + *res = arf_get_d(arb_midref(arb_res), ARF_RND_NEAR); + status = FPWRAP_SUCCESS; + break; + } + + if (wp >= double_wp_max(flags)) + { + *res = D_NAN; + status = FPWRAP_UNABLE; + break; + } } } @@ -149,7 +157,158 @@ int arb_fpwrap_double(double * res, arb_func_1 func, double x, int flags) return status; } -int arb_fpwrap_cdouble(complex_double * res, acb_func_1 func, complex_double x, int flags) +int arb_fpwrap_double_2(double * res, arb_func_2 func, double x1, double x2, int flags) +{ + arb_t arb_res, arb_x1, arb_x2; + slong wp; + int status; + + arb_init(arb_res); + arb_init(arb_x1); + arb_init(arb_x2); + + arb_set_d(arb_x1, x1); + arb_set_d(arb_x2, x2); + + if (!arb_is_finite(arb_x1) || !arb_is_finite(arb_x2)) + { + *res = D_NAN; + status = FPWRAP_UNABLE; + } + else + { + for (wp = WP_INITIAL; ; wp *= 2) + { + func(arb_res, arb_x1, arb_x2, wp); + + if (arb_accurate_enough_d(arb_res, flags)) + { + *res = arf_get_d(arb_midref(arb_res), ARF_RND_NEAR); + status = FPWRAP_SUCCESS; + break; + } + + if (wp >= double_wp_max(flags)) + { + *res = D_NAN; + status = FPWRAP_UNABLE; + break; + } + } + } + + arb_clear(arb_x1); + arb_clear(arb_x2); + arb_clear(arb_res); + + return status; +} + +int arb_fpwrap_double_3(double * res, arb_func_3 func, double x1, double x2, double x3, int flags) +{ + arb_t arb_res, arb_x1, arb_x2, arb_x3; + slong wp; + int status; + + arb_init(arb_res); + arb_init(arb_x1); + arb_init(arb_x2); + arb_init(arb_x3); + + arb_set_d(arb_x1, x1); + arb_set_d(arb_x2, x2); + arb_set_d(arb_x3, x3); + + if (!arb_is_finite(arb_x1) || !arb_is_finite(arb_x2) || !arb_is_finite(arb_x3)) + { + *res = D_NAN; + status = FPWRAP_UNABLE; + } + else + { + for (wp = WP_INITIAL; ; wp *= 2) + { + func(arb_res, arb_x1, arb_x2, arb_x3, wp); + + if (arb_accurate_enough_d(arb_res, flags)) + { + *res = arf_get_d(arb_midref(arb_res), ARF_RND_NEAR); + status = FPWRAP_SUCCESS; + break; + } + + if (wp >= double_wp_max(flags)) + { + *res = D_NAN; + status = FPWRAP_UNABLE; + break; + } + } + } + + arb_clear(arb_x1); + arb_clear(arb_x2); + arb_clear(arb_x3); + arb_clear(arb_res); + + return status; +} + +int arb_fpwrap_double_4(double * res, arb_func_4 func, double x1, double x2, double x3, double x4, int flags) +{ + arb_t arb_res, arb_x1, arb_x2, arb_x3, arb_x4; + slong wp; + int status; + + arb_init(arb_res); + arb_init(arb_x1); + arb_init(arb_x2); + arb_init(arb_x3); + arb_init(arb_x4); + + arb_set_d(arb_x1, x1); + arb_set_d(arb_x2, x2); + arb_set_d(arb_x3, x3); + arb_set_d(arb_x3, x4); + + if (!arb_is_finite(arb_x1) || !arb_is_finite(arb_x2) || !arb_is_finite(arb_x3) || !arb_is_finite(arb_x4)) + { + *res = D_NAN; + status = FPWRAP_UNABLE; + } + else + { + for (wp = WP_INITIAL; ; wp *= 2) + { + func(arb_res, arb_x1, arb_x2, arb_x3, arb_x4, wp); + + if (arb_accurate_enough_d(arb_res, flags)) + { + *res = arf_get_d(arb_midref(arb_res), ARF_RND_NEAR); + status = FPWRAP_SUCCESS; + break; + } + + if (wp >= double_wp_max(flags)) + { + *res = D_NAN; + status = FPWRAP_UNABLE; + break; + } + } + } + + arb_clear(arb_x1); + arb_clear(arb_x2); + arb_clear(arb_x3); + arb_clear(arb_x4); + arb_clear(arb_res); + + return status; +} + + +int arb_fpwrap_cdouble_1(complex_double * res, acb_func_1 func, complex_double x, int flags) { acb_t acb_res, acb_x; slong wp; @@ -160,33 +319,33 @@ int arb_fpwrap_cdouble(complex_double * res, acb_func_1 func, complex_double x, acb_set_d_d(acb_x, x.real, x.imag); - /* no need to clear */ if (!acb_is_finite(acb_x)) { - acb_clear(acb_x); res->real = D_NAN; res->imag = D_NAN; - return FPWRAP_UNABLE; + status = FPWRAP_UNABLE; } - - for (wp = WP_INITIAL; ; wp *= 2) + else { - func(acb_res, acb_x, wp); - - if (acb_accurate_enough_d(acb_res, flags)) + for (wp = WP_INITIAL; ; wp *= 2) { - res->real = arf_get_d(arb_midref(acb_realref(acb_res)), ARF_RND_NEAR); - res->imag = arf_get_d(arb_midref(acb_imagref(acb_res)), ARF_RND_NEAR); - status = FPWRAP_SUCCESS; - break; - } + func(acb_res, acb_x, wp); - if (wp >= double_wp_max(flags)) - { - res->real = D_NAN; - res->imag = D_NAN; - status = FPWRAP_UNABLE; - break; + if (acb_accurate_enough_d(acb_res, flags)) + { + res->real = arf_get_d(arb_midref(acb_realref(acb_res)), ARF_RND_NEAR); + res->imag = arf_get_d(arb_midref(acb_imagref(acb_res)), ARF_RND_NEAR); + status = FPWRAP_SUCCESS; + break; + } + + if (wp >= double_wp_max(flags)) + { + res->real = D_NAN; + res->imag = D_NAN; + status = FPWRAP_UNABLE; + break; + } } } @@ -196,32 +355,394 @@ int arb_fpwrap_cdouble(complex_double * res, acb_func_1 func, complex_double x, return status; } -#define DEF_DOUBLE_FUN(name, arb_fun) \ +int arb_fpwrap_cdouble_2(complex_double * res, acb_func_2 func, complex_double x1, complex_double x2, int flags) +{ + acb_t acb_res, acb_x1, acb_x2; + slong wp; + int status; + + acb_init(acb_res); + acb_init(acb_x1); + acb_init(acb_x2); + + acb_set_d_d(acb_x1, x1.real, x1.imag); + acb_set_d_d(acb_x2, x2.real, x2.imag); + + if (!acb_is_finite(acb_x1) || !acb_is_finite(acb_x2)) + { + res->real = D_NAN; + res->imag = D_NAN; + status = FPWRAP_UNABLE; + } + else + { + for (wp = WP_INITIAL; ; wp *= 2) + { + func(acb_res, acb_x1, acb_x2, wp); + + if (acb_accurate_enough_d(acb_res, flags)) + { + res->real = arf_get_d(arb_midref(acb_realref(acb_res)), ARF_RND_NEAR); + res->imag = arf_get_d(arb_midref(acb_imagref(acb_res)), ARF_RND_NEAR); + status = FPWRAP_SUCCESS; + break; + } + + if (wp >= double_wp_max(flags)) + { + res->real = D_NAN; + res->imag = D_NAN; + status = FPWRAP_UNABLE; + break; + } + } + } + + acb_clear(acb_x1); + acb_clear(acb_x2); + acb_clear(acb_res); + + return status; +} + +int arb_fpwrap_cdouble_3(complex_double * res, acb_func_3 func, complex_double x1, complex_double x2, complex_double x3, int flags) +{ + acb_t acb_res, acb_x1, acb_x2, acb_x3; + slong wp; + int status; + + acb_init(acb_res); + acb_init(acb_x1); + acb_init(acb_x2); + acb_init(acb_x3); + + acb_set_d_d(acb_x1, x1.real, x1.imag); + acb_set_d_d(acb_x2, x2.real, x2.imag); + acb_set_d_d(acb_x3, x3.real, x3.imag); + + if (!acb_is_finite(acb_x1) || !acb_is_finite(acb_x2) || !acb_is_finite(acb_x3)) + { + res->real = D_NAN; + res->imag = D_NAN; + status = FPWRAP_UNABLE; + } + else + { + for (wp = WP_INITIAL; ; wp *= 2) + { + func(acb_res, acb_x1, acb_x2, acb_x3, wp); + + if (acb_accurate_enough_d(acb_res, flags)) + { + res->real = arf_get_d(arb_midref(acb_realref(acb_res)), ARF_RND_NEAR); + res->imag = arf_get_d(arb_midref(acb_imagref(acb_res)), ARF_RND_NEAR); + status = FPWRAP_SUCCESS; + break; + } + + if (wp >= double_wp_max(flags)) + { + res->real = D_NAN; + res->imag = D_NAN; + status = FPWRAP_UNABLE; + break; + } + } + } + + acb_clear(acb_x1); + acb_clear(acb_x2); + acb_clear(acb_x3); + acb_clear(acb_res); + + return status; +} + +int arb_fpwrap_cdouble_4(complex_double * res, acb_func_4 func, complex_double x1, complex_double x2, complex_double x3, complex_double x4, int flags) +{ + acb_t acb_res, acb_x1, acb_x2, acb_x3, acb_x4; + slong wp; + int status; + + acb_init(acb_res); + acb_init(acb_x1); + acb_init(acb_x2); + acb_init(acb_x3); + acb_init(acb_x4); + + acb_set_d_d(acb_x1, x1.real, x1.imag); + acb_set_d_d(acb_x2, x2.real, x2.imag); + acb_set_d_d(acb_x3, x3.real, x3.imag); + acb_set_d_d(acb_x4, x4.real, x4.imag); + + if (!acb_is_finite(acb_x1) || !acb_is_finite(acb_x2) || !acb_is_finite(acb_x3) || !acb_is_finite(acb_x4)) + { + res->real = D_NAN; + res->imag = D_NAN; + status = FPWRAP_UNABLE; + } + else + { + for (wp = WP_INITIAL; ; wp *= 2) + { + func(acb_res, acb_x1, acb_x2, acb_x3, acb_x4, wp); + + if (acb_accurate_enough_d(acb_res, flags)) + { + res->real = arf_get_d(arb_midref(acb_realref(acb_res)), ARF_RND_NEAR); + res->imag = arf_get_d(arb_midref(acb_imagref(acb_res)), ARF_RND_NEAR); + status = FPWRAP_SUCCESS; + break; + } + + if (wp >= double_wp_max(flags)) + { + res->real = D_NAN; + res->imag = D_NAN; + status = FPWRAP_UNABLE; + break; + } + } + } + + acb_clear(acb_x1); + acb_clear(acb_x2); + acb_clear(acb_x3); + acb_clear(acb_x4); + acb_clear(acb_res); + + return status; +} + +#define DEF_DOUBLE_FUN_1(name, arb_fun) \ int arb_fpwrap_double_ ## name(double * res, double x, int flags) \ { \ - return arb_fpwrap_double(res, arb_fun, x, flags); \ + return arb_fpwrap_double_1(res, arb_fun, x, flags); \ } \ -#define DEF_CDOUBLE_FUN(name, acb_fun) \ +#define DEF_DOUBLE_FUN_2(name, arb_fun) \ + int arb_fpwrap_double_ ## name(double * res, double x1, double x2, int flags) \ + { \ + return arb_fpwrap_double_2(res, arb_fun, x1, x2, flags); \ + } \ + +#define DEF_DOUBLE_FUN_3(name, arb_fun) \ + int arb_fpwrap_double_ ## name(double * res, double x1, double x2, double x3, int flags) \ + { \ + return arb_fpwrap_double_3(res, arb_fun, x1, x2, x3, flags); \ + } \ + +#define DEF_DOUBLE_FUN_4(name, arb_fun) \ + int arb_fpwrap_double_ ## name(double * res, double x1, double x2, double x3, double x4, int flags) \ + { \ + return arb_fpwrap_double_4(res, arb_fun, x1, x2, x3, x4, flags); \ + } \ + +#define DEF_CDOUBLE_FUN_1(name, acb_fun) \ int arb_fpwrap_cdouble_ ## name(complex_double * res, complex_double x, int flags) \ { \ - return arb_fpwrap_cdouble(res, acb_fun, x, flags); \ + return arb_fpwrap_cdouble_1(res, acb_fun, x, flags); \ + } \ + +#define DEF_CDOUBLE_FUN_2(name, acb_fun) \ + int arb_fpwrap_cdouble_ ## name(complex_double * res, complex_double x1, complex_double x2, int flags) \ + { \ + return arb_fpwrap_cdouble_2(res, acb_fun, x1, x2, flags); \ + } \ + +#define DEF_CDOUBLE_FUN_3(name, acb_fun) \ + int arb_fpwrap_cdouble_ ## name(complex_double * res, complex_double x1, complex_double x2, complex_double x3, int flags) \ + { \ + return arb_fpwrap_cdouble_3(res, acb_fun, x1, x2, x3, flags); \ + } \ + +#define DEF_CDOUBLE_FUN_4(name, acb_fun) \ + int arb_fpwrap_cdouble_ ## name(complex_double * res, complex_double x1, complex_double x2, complex_double x3, complex_double x4, int flags) \ + { \ + return arb_fpwrap_cdouble_4(res, acb_fun, x1, x2, x3, x4, flags); \ } \ -DEF_DOUBLE_FUN(gamma, arb_gamma) -DEF_CDOUBLE_FUN(gamma, acb_gamma) +DEF_DOUBLE_FUN_1(exp, arb_exp) +DEF_CDOUBLE_FUN_1(exp, acb_exp) -DEF_DOUBLE_FUN(rgamma, arb_rgamma) -DEF_CDOUBLE_FUN(rgamma, acb_rgamma) +DEF_DOUBLE_FUN_1(expm1, arb_expm1) +DEF_CDOUBLE_FUN_1(expm1, acb_expm1) -DEF_DOUBLE_FUN(lgamma, arb_lgamma) -DEF_CDOUBLE_FUN(lgamma, acb_lgamma) +DEF_DOUBLE_FUN_1(log, arb_log) +DEF_CDOUBLE_FUN_1(log, acb_log) -DEF_DOUBLE_FUN(digamma, arb_digamma) -DEF_CDOUBLE_FUN(digamma, acb_digamma) +DEF_DOUBLE_FUN_1(log1p, arb_log1p) +DEF_CDOUBLE_FUN_1(log1p, acb_log1p) -DEF_DOUBLE_FUN(zeta, arb_zeta) -DEF_CDOUBLE_FUN(zeta, acb_zeta) +DEF_DOUBLE_FUN_1(sqrt, arb_sqrt) +DEF_CDOUBLE_FUN_1(sqrt, acb_sqrt) + +DEF_DOUBLE_FUN_1(rsqrt, arb_rsqrt) +DEF_CDOUBLE_FUN_1(rsqrt, acb_rsqrt) + +static void _arb_cbrt(arb_t res, const arb_t x, slong prec) { arb_root_ui(res, x, 3, prec); } +static void _acb_cbrt(acb_t res, const acb_t x, slong prec) { acb_root_ui(res, x, 3, prec); } + +DEF_DOUBLE_FUN_1(cbrt, _arb_cbrt) +DEF_CDOUBLE_FUN_1(cbrt, _acb_cbrt) + +DEF_DOUBLE_FUN_1(sin, arb_sin) +DEF_CDOUBLE_FUN_1(sin, acb_sin) + +DEF_DOUBLE_FUN_1(cos, arb_cos) +DEF_CDOUBLE_FUN_1(cos, acb_cos) + +DEF_DOUBLE_FUN_1(tan, arb_tan) +DEF_CDOUBLE_FUN_1(tan, acb_tan) + +DEF_DOUBLE_FUN_1(cot, arb_cot) +DEF_CDOUBLE_FUN_1(cot, acb_cot) + +DEF_DOUBLE_FUN_1(sec, arb_sec) +DEF_CDOUBLE_FUN_1(sec, acb_sec) + +DEF_DOUBLE_FUN_1(csc, arb_csc) +DEF_CDOUBLE_FUN_1(csc, acb_csc) + +DEF_DOUBLE_FUN_1(sinc, arb_sinc) +DEF_CDOUBLE_FUN_1(sinc, acb_sinc) + +DEF_DOUBLE_FUN_1(sin_pi, arb_sin_pi) +DEF_CDOUBLE_FUN_1(sin_pi, acb_sin_pi) + +DEF_DOUBLE_FUN_1(cos_pi, arb_cos_pi) +DEF_CDOUBLE_FUN_1(cos_pi, acb_cos_pi) + +DEF_DOUBLE_FUN_1(tan_pi, arb_tan_pi) +DEF_CDOUBLE_FUN_1(tan_pi, acb_tan_pi) + +DEF_DOUBLE_FUN_1(cot_pi, arb_cot_pi) +DEF_CDOUBLE_FUN_1(cot_pi, acb_cot_pi) + +DEF_DOUBLE_FUN_1(sinc_pi, arb_sinc_pi) +DEF_CDOUBLE_FUN_1(sinc_pi, acb_sinc_pi) + +DEF_DOUBLE_FUN_1(asin, arb_asin) +DEF_CDOUBLE_FUN_1(asin, acb_asin) + +DEF_DOUBLE_FUN_1(acos, arb_acos) +DEF_CDOUBLE_FUN_1(acos, acb_acos) + +DEF_DOUBLE_FUN_1(atan, arb_atan) +DEF_CDOUBLE_FUN_1(atan, acb_atan) + +DEF_DOUBLE_FUN_2(atan2, arb_atan2) + +DEF_DOUBLE_FUN_1(asinh, arb_asinh) +DEF_CDOUBLE_FUN_1(asinh, acb_asinh) + +DEF_DOUBLE_FUN_1(acosh, arb_acosh) +DEF_CDOUBLE_FUN_1(acosh, acb_acosh) + +DEF_DOUBLE_FUN_1(atanh, arb_atanh) +DEF_CDOUBLE_FUN_1(atanh, acb_atanh) + +/* todo: lambertw (with branches) */ +DEF_DOUBLE_FUN_2(rising, arb_rising) +DEF_CDOUBLE_FUN_2(rising, acb_rising) + +DEF_DOUBLE_FUN_1(gamma, arb_gamma) +DEF_CDOUBLE_FUN_1(gamma, acb_gamma) + +DEF_DOUBLE_FUN_1(rgamma, arb_rgamma) +DEF_CDOUBLE_FUN_1(rgamma, acb_rgamma) + +DEF_DOUBLE_FUN_1(lgamma, arb_lgamma) +DEF_CDOUBLE_FUN_1(lgamma, acb_lgamma) + +DEF_DOUBLE_FUN_1(digamma, arb_digamma) +DEF_CDOUBLE_FUN_1(digamma, acb_digamma) + +DEF_DOUBLE_FUN_1(zeta, arb_zeta) +DEF_CDOUBLE_FUN_1(zeta, acb_zeta) + +DEF_DOUBLE_FUN_2(hurwitz_zeta, arb_hurwitz_zeta) +DEF_CDOUBLE_FUN_2(hurwitz_zeta, acb_hurwitz_zeta) + +void +_arb_polygamma(arb_t res, const arb_t s, const arb_t z, slong prec) +{ + acb_t t, u, v; + acb_init(t); + acb_init(u); + acb_init(v); + acb_set_arb(t, s); + acb_set_arb(u, z); + acb_polygamma(v, t, u, prec); + if (acb_is_real(v)) + arb_set(res, acb_realref(v)); + else + arb_indeterminate(res); + acb_clear(t); + acb_clear(u); + acb_clear(v); +} + +void +_arb_barnes_g(arb_t res, const arb_t x, slong prec) +{ + acb_t t, u; + acb_init(t); + acb_init(u); + acb_set_arb(t, x); + acb_barnes_g(u, t, prec); + if (acb_is_real(u)) + arb_set(res, acb_realref(u)); + else + arb_indeterminate(res); + acb_clear(t); + acb_clear(u); +} + +void +_arb_log_barnes_g(arb_t res, const arb_t x, slong prec) +{ + acb_t t, u; + acb_init(t); + acb_init(u); + acb_set_arb(t, x); + acb_log_barnes_g(u, t, prec); + if (acb_is_real(u)) + arb_set(res, acb_realref(u)); + else + arb_indeterminate(res); + acb_clear(t); + acb_clear(u); +} + +DEF_DOUBLE_FUN_1(barnes_g, _arb_barnes_g) +DEF_CDOUBLE_FUN_1(barnes_g, acb_barnes_g) + +DEF_DOUBLE_FUN_1(log_barnes_g, _arb_log_barnes_g) +DEF_CDOUBLE_FUN_1(log_barnes_g, acb_log_barnes_g) + +DEF_DOUBLE_FUN_2(polygamma, _arb_polygamma) +DEF_CDOUBLE_FUN_2(polygamma, acb_polygamma) + +DEF_DOUBLE_FUN_2(polylog, arb_polylog) +DEF_CDOUBLE_FUN_2(polylog, acb_polylog) + +void +_arb_agm1(arb_t res, const arb_t x, slong prec) +{ + arb_t t; + arb_init(t); + arb_one(t); + arb_agm(res, t, x, prec); + arb_clear(t); +} + +DEF_DOUBLE_FUN_1(agm1, _arb_agm1) +DEF_CDOUBLE_FUN_1(agm1, acb_agm1) + +DEF_DOUBLE_FUN_2(agm, arb_agm) +DEF_CDOUBLE_FUN_2(agm, acb_agm) + diff --git a/doc/source/arb_fpwrap.rst b/doc/source/arb_fpwrap.rst index 6834ac02..feefc5fb 100644 --- a/doc/source/arb_fpwrap.rst +++ b/doc/source/arb_fpwrap.rst @@ -115,6 +115,94 @@ multiple outputs. Functions ------------------------------------------------------------------------------- +Elementary functions +............................................................................... + +.. function:: int arb_fpwrap_double_exp(double * res, double x, int flags) + int arb_fpwrap_cdouble_exp(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_expm1(double * res, double x, int flags) + int arb_fpwrap_cdouble_expm1(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_log(double * res, double x, int flags) + int arb_fpwrap_cdouble_log(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_log1p(double * res, double x, int flags) + int arb_fpwrap_cdouble_log1p(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_sqrt(double * res, double x, int flags) + int arb_fpwrap_cdouble_sqrt(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_rsqrt(double * res, double x, int flags) + int arb_fpwrap_cdouble_rsqrt(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_cbrt(double * res, double x, int flags) + int arb_fpwrap_cdouble_cbrt(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_sin(double * res, double x, int flags) + int arb_fpwrap_cdouble_sin(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_cos(double * res, double x, int flags) + int arb_fpwrap_cdouble_cos(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_tan(double * res, double x, int flags) + int arb_fpwrap_cdouble_tan(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_cot(double * res, double x, int flags) + int arb_fpwrap_cdouble_cot(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_sec(double * res, double x, int flags) + int arb_fpwrap_cdouble_sec(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_csc(double * res, double x, int flags) + int arb_fpwrap_cdouble_csc(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_sinc(double * res, double x, int flags) + int arb_fpwrap_cdouble_sinc(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_sin_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_sin_pi(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_cos_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_cos_pi(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_tan_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_tan_pi(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_cot_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_cot_pi(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_sinc_pi(double * res, double x, int flags) + int arb_fpwrap_cdouble_sinc_pi(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_asin(double * res, double x, int flags) + int arb_fpwrap_cdouble_asin(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_acos(double * res, double x, int flags) + int arb_fpwrap_cdouble_acos(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_atan(double * res, double x, int flags) + int arb_fpwrap_cdouble_atan(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_atan2(double * res, double x1, double x2, int flags) + +.. function:: int arb_fpwrap_double_asinh(double * res, double x, int flags) + int arb_fpwrap_cdouble_asinh(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_acosh(double * res, double x, int flags) + int arb_fpwrap_cdouble_acosh(complex_double * res, complex_double x, int flags) + +.. function:: int arb_fpwrap_double_atanh(double * res, double x, int flags) + int arb_fpwrap_cdouble_atanh(complex_double * res, complex_double x, int flags) + +Gamma, zeta and related functions +............................................................................... + +.. function:: int arb_fpwrap_double_rising(double * res, double x, double n, int flags) + int arb_fpwrap_cdouble_rising(complex_double * res, complex_double x, complex_double n, int flags) + + Rising factorial. + .. function:: int arb_fpwrap_double_gamma(double * res, double x, int flags) int arb_fpwrap_cdouble_gamma(complex_double * res, complex_double x, int flags) @@ -140,6 +228,46 @@ Functions Riemann zeta function. +.. function:: int arb_fpwrap_double_hurwitz_zeta(double * res, double s, double z, int flags) + int arb_fpwrap_cdouble_hurwitz_zeta(complex_double * res, complex_double s, complex_double z, int flags) + + Hurwitz zeta function. + +.. function:: int arb_fpwrap_double_barnes_g(double * res, double x, int flags) + int arb_fpwrap_cdouble_barnes_g(complex_double * res, complex_double x, int flags) + + Barnes G-function. + +.. function:: int arb_fpwrap_double_log_barnes_g(double * res, double x, int flags) + int arb_fpwrap_cdouble_log_barnes_g(complex_double * res, complex_double x, int flags) + + Logarithmic Barnes G-function. + +.. function:: int arb_fpwrap_double_polygamma(double * res, double s, double z, int flags) + int arb_fpwrap_cdouble_polygamma(complex_double * res, complex_double s, complex_double z, int flags) + + Polygamma function. + +.. function:: int arb_fpwrap_double_polylog(double * res, double s, double z, int flags) + int arb_fpwrap_cdouble_polylog(complex_double * res, complex_double s, complex_double z, int flags) + + Polylogarithm. + + +Elliptic integrals and elliptic functions +............................................................................... + +.. function:: int arb_fpwrap_double_agm1(double * res, double x, int flags) + int arb_fpwrap_cdouble_agm1(complex_double * res, complex_double x, int flags) + + Arithmetic-geometric mean with second variable 1. + +.. function:: int arb_fpwrap_double_agm(double * res, double x, double y, int flags) + int arb_fpwrap_cdouble_agm(complex_double * res, complex_double x, complex_double y, int flags) + + Arithmetic-geometric mean. + + Interfacing from Python -------------------------------------------------------------------------------