Commit 1d00d483 authored by Andreas Enge's avatar Andreas Enge

Wrap MPFR functions.

* src/mpfr.c, src/paritwine.h, gp/paritwine-mpfr.gp, doc/paritwine.texi:
  Wrap MPFR functions.
parent 9f2fca43
......@@ -429,13 +429,74 @@ is wrapped to become
Currently, the following wrapped functions are available in PariTwine;
see @ref{Extending PariTwine} for instructions on how to add more functions.
@deftypefun GEN pari_mpfr_erf (GEN x, long prec)
@deftypefunx GEN pari_mpfr_zeta (GEN x, long prec)
@deftypefun GEN pari_mpfr_add (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpfr_sub (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpfr_mul (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpfr_sqr (GEN x, long prec)
@deftypefunx GEN pari_mpfr_div (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpfr_sqrt (GEN x, long prec)
@deftypefunx GEN pari_mpfr_rec_sqrt (GEN x, long prec)
@deftypefunx GEN pari_mpfr_cbrt (GEN x, long prec)
@deftypefunx GEN pari_mpfr_pow (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpfr_log (GEN x, long prec)
@deftypefunx GEN pari_mpfr_log2 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_log10 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_exp (GEN x, long prec)
@deftypefunx GEN pari_mpfr_exp2 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_exp10 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_sin (GEN x, long prec)
@deftypefunx GEN pari_mpfr_cos (GEN x, long prec)
@deftypefunx GEN pari_mpfr_tan (GEN x, long prec)
@deftypefunx GEN pari_mpfr_sec (GEN x, long prec)
@deftypefunx GEN pari_mpfr_csc (GEN x, long prec)
@deftypefunx GEN pari_mpfr_cot (GEN x, long prec)
@deftypefunx GEN pari_mpfr_acos (GEN x, long prec)
@deftypefunx GEN pari_mpfr_asin (GEN x, long prec)
@deftypefunx GEN pari_mpfr_atan (GEN x, long prec)
@deftypefunx GEN pari_mpfr_cosh (GEN x, long prec)
@deftypefunx GEN pari_mpfr_sinh (GEN x, long prec)
@deftypefunx GEN pari_mpfr_tanh (GEN x, long prec)
@deftypefunx GEN pari_mpfr_sech (GEN x, long prec)
@deftypefunx GEN pari_mpfr_csch (GEN x, long prec)
@deftypefunx GEN pari_mpfr_coth (GEN x, long prec)
@deftypefunx GEN pari_mpfr_acosh (GEN x, long prec)
@deftypefunx GEN pari_mpfr_asinh (GEN x, long prec)
@deftypefunx GEN pari_mpfr_atanh (GEN x, long prec)
@deftypefunx GEN pari_mpfr_log1p (GEN x, long prec)
@deftypefunx GEN pari_mpfr_expm1 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_eint (GEN x, long prec)
@deftypefunx GEN pari_mpfr_li2 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_gamma (GEN x, long prec)
@deftypefunx GEN pari_mpfr_lngamma (GEN x, long prec)
@deftypefunx GEN pari_mpfr_digamma (GEN x, long prec)
@deftypefunx GEN pari_mpfr_zeta (GEN x, long prec)
@deftypefunx GEN pari_mpfr_erf (GEN x, long prec)
@deftypefunx GEN pari_mpfr_erfc (GEN x, long prec)
@deftypefunx GEN pari_mpfr_j0 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_j1 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_y0 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_y1 (GEN x, long prec)
@deftypefunx GEN pari_mpfr_fma (GEN x, GEN y, GEN z, long prec)
@deftypefunx GEN pari_mpfr_fms (GEN x, GEN y, GEN z, long prec)
@deftypefunx GEN pari_mpfr_agm (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpfr_hypot (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpfr_ai (GEN x, long prec)
These functions take arguments of types @code{t_INT}, @code{t_FRAC} or
@code{t_REAL} and use GNU MPFR to return a result of type @code{t_REAL}.
@end deftypefun
@deftypefun GEN pari_mpfr_fac_ui (unsigned long int t, long prec)
This function takes as argument a small unsigned integer and
returns its factorial as a number of type @code{t_REAL}.
@end deftypefun
@deftypefun GEN pari_mpfr_jn (long int i, GEN x, long prec)
@deftypefunx GEN pari_mpfr_yn (long int i, GEN x, long prec)
These functions take as arguments a small integer and a number of type
@code{t_INT}, @code{t_FRAC} or @code{t_REAL} and returns a Bessel
function of the given order of the first or second kind in the argument.
@end deftypefun
@deftypefun GEN pari_mpc_add (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpc_sub (GEN x, GEN y, long prec)
@deftypefunx GEN pari_mpc_mul (GEN x, GEN y, long prec)
......@@ -459,15 +520,15 @@ These functions take arguments of types @code{t_INT}, @code{t_FRAC} or
@deftypefunx GEN pari_mpc_asinh (GEN x, long prec)
@deftypefunx GEN pari_mpc_acosh (GEN x, long prec)
@deftypefunx GEN pari_mpc_atanh (GEN x, long prec)
This function takes arguments of types @code{t_INT}, @code{t_FRAC},
@code{t_REAL} or @code{t_COMPLEX} and uses GNU MPC to return a result
These functions take arguments of types @code{t_INT}, @code{t_FRAC},
@code{t_REAL} or @code{t_COMPLEX} and use GNU MPC to return a result
of type @code{t_COMPLEX}.
@end deftypefun
@deftypefun GEN pari_mpc_abs (GEN x, long prec)
@deftypefunx GEN pari_mpc_norm (GEN x, long prec)
This function takes arguments of types @code{t_INT}, @code{t_FRAC},
@code{t_REAL} or @code{t_COMPLEX} and uses MPC to return a result
These functions take arguments of types @code{t_INT}, @code{t_FRAC},
@code{t_REAL} or @code{t_COMPLEX} and use MPC to return a result
of type @code{t_REAL}.
@end deftypefun
......
install ("pari_mpfr_add", "GGb", "mpfr_add", LIBPARITWINESO);
install ("pari_mpfr_sub", "GGb", "mpfr_sub", LIBPARITWINESO);
install ("pari_mpfr_mul", "GGb", "mpfr_mul", LIBPARITWINESO);
install ("pari_mpfr_erf", "Gb", "mpfr_erf", LIBPARITWINESO);
install ("pari_mpfr_sqr", "Gb", "mpfr_sqr", LIBPARITWINESO);
install ("pari_mpfr_div", "GGb", "mpfr_div", LIBPARITWINESO);
install ("pari_mpfr_sqrt", "Gb", "mpfr_sqrt", LIBPARITWINESO);
install ("pari_mpfr_rec_sqrt", "Gb", "mpfr_rec_sqrt", LIBPARITWINESO);
install ("pari_mpfr_cbrt", "Gb", "mpfr_cbrt", LIBPARITWINESO);
install ("pari_mpfr_pow", "GGb", "mpfr_pow", LIBPARITWINESO);
install ("pari_mpfr_log", "Gb", "mpfr_log", LIBPARITWINESO);
install ("pari_mpfr_log2", "Gb", "mpfr_log2", LIBPARITWINESO);
install ("pari_mpfr_log10", "Gb", "mpfr_log10", LIBPARITWINESO);
install ("pari_mpfr_exp", "Gb", "mpfr_exp", LIBPARITWINESO);
install ("pari_mpfr_exp2", "Gb", "mpfr_exp2", LIBPARITWINESO);
install ("pari_mpfr_exp10", "Gb", "mpfr_exp10", LIBPARITWINESO);
install ("pari_mpfr_sin", "Gb", "mpfr_sin", LIBPARITWINESO);
install ("pari_mpfr_cos", "Gb", "mpfr_cos", LIBPARITWINESO);
install ("pari_mpfr_tan", "Gb", "mpfr_tan", LIBPARITWINESO);
install ("pari_mpfr_sec", "Gb", "mpfr_sec", LIBPARITWINESO);
install ("pari_mpfr_csc", "Gb", "mpfr_csc", LIBPARITWINESO);
install ("pari_mpfr_cot", "Gb", "mpfr_cot", LIBPARITWINESO);
install ("pari_mpfr_acos", "Gb", "mpfr_acos", LIBPARITWINESO);
install ("pari_mpfr_asin", "Gb", "mpfr_asin", LIBPARITWINESO);
install ("pari_mpfr_atan", "Gb", "mpfr_atan", LIBPARITWINESO);
install ("pari_mpfr_cosh", "Gb", "mpfr_cosh", LIBPARITWINESO);
install ("pari_mpfr_sinh", "Gb", "mpfr_sinh", LIBPARITWINESO);
install ("pari_mpfr_tanh", "Gb", "mpfr_tanh", LIBPARITWINESO);
install ("pari_mpfr_sech", "Gb", "mpfr_sech", LIBPARITWINESO);
install ("pari_mpfr_csch", "Gb", "mpfr_csch", LIBPARITWINESO);
install ("pari_mpfr_coth", "Gb", "mpfr_coth", LIBPARITWINESO);
install ("pari_mpfr_acosh", "Gb", "mpfr_acosh", LIBPARITWINESO);
install ("pari_mpfr_asinh", "Gb", "mpfr_asinh", LIBPARITWINESO);
install ("pari_mpfr_atanh", "Gb", "mpfr_atanh", LIBPARITWINESO);
install ("pari_mpfr_fac_ui", "Lb", "mpfr_fac_ui", LIBPARITWINESO);
install ("pari_mpfr_log1p", "Gb", "mpfr_log1p", LIBPARITWINESO);
install ("pari_mpfr_expm1", "Gb", "mpfr_expm1", LIBPARITWINESO);
install ("pari_mpfr_eint", "Gb", "mpfr_eint", LIBPARITWINESO);
install ("pari_mpfr_li2", "Gb", "mpfr_li2", LIBPARITWINESO);
install ("pari_mpfr_gamma", "Gb", "mpfr_gamma", LIBPARITWINESO);
install ("pari_mpfr_lngamma", "Gb", "mpfr_lngamma", LIBPARITWINESO);
install ("pari_mpfr_digamma", "Gb", "mpfr_digamma", LIBPARITWINESO);
install ("pari_mpfr_zeta", "Gb", "mpfr_zeta", LIBPARITWINESO);
install ("pari_mpfr_erf", "Gb", "mpfr_erf", LIBPARITWINESO);
install ("pari_mpfr_erfc", "Gb", "mpfr_erfc", LIBPARITWINESO);
install ("pari_mpfr_j0", "Gb", "mpfr_j0", LIBPARITWINESO);
install ("pari_mpfr_j1", "Gb", "mpfr_j1", LIBPARITWINESO);
install ("pari_mpfr_jn", "LGb", "mpfr_jn", LIBPARITWINESO);
install ("pari_mpfr_y0", "Gb", "mpfr_y0", LIBPARITWINESO);
install ("pari_mpfr_y1", "Gb", "mpfr_y1", LIBPARITWINESO);
install ("pari_mpfr_yn", "LGb", "mpfr_yn", LIBPARITWINESO);
install ("pari_mpfr_fma", "GGGb", "mpfr_fma", LIBPARITWINESO);
install ("pari_mpfr_fms", "GGGb", "mpfr_fms", LIBPARITWINESO);
install ("pari_mpfr_agm", "GGb", "mpfr_agm", LIBPARITWINESO);
install ("pari_mpfr_hypot", "GGb", "mpfr_hypot", LIBPARITWINESO);
install ("pari_mpfr_ai", "Gb", "mpfr_ai", LIBPARITWINESO);
......@@ -61,12 +61,110 @@ GEN pari_mpfr_ ## name (GEN x, GEN y, long prec) \
return gerepileuptoleaf (ltop, mpfr_get_GEN (z)); \
}
/* Macro for wrapping a function with three MPFR inputs and one MPFR output */
#define WRAP_F_FFF(name) \
GEN pari_mpfr_ ## name (GEN x, GEN y, GEN t, long prec) \
{ \
pari_sp ltop = avma; \
mpfr_prec_t p = prec; \
mpfr_t z, z1, z2, z3; \
pari_mpfr_init2 (z, p); \
pari_mpfr_init_set_GEN (z1, x, p); \
pari_mpfr_init_set_GEN (z2, y, p); \
pari_mpfr_init_set_GEN (z3, t, p); \
mpfr_ ## name (z, z1, z2, z3, MPFR_RNDN); \
return gerepileuptoleaf (ltop, mpfr_get_GEN (z)); \
}
/* Macro for wrapping a function with one unsigned long int input
and one MPFR output */
#define WRAP_F_u(name) \
GEN pari_mpfr_ ## name (unsigned long int i, long prec) \
{ \
pari_sp ltop = avma; \
mpfr_prec_t p = prec; \
mpfr_t z; \
pari_mpfr_init2 (z, p); \
mpfr_ ## name (z, i, MPFR_RNDN); \
return gerepileuptoleaf (ltop, mpfr_get_GEN (z)); \
}
/* Macro for wrapping a function with one long int and one MPFR input
and one MPFR output */
#define WRAP_F_lF(name) \
GEN pari_mpfr_ ## name (long int i, GEN x, long prec) \
{ \
pari_sp ltop = avma; \
mpfr_prec_t p = prec; \
mpfr_t z, z1; \
pari_mpfr_init2 (z, p); \
pari_mpfr_init_set_GEN (z1, x, p); \
mpfr_ ## name (z, i, z1, MPFR_RNDN); \
return gerepileuptoleaf (ltop, mpfr_get_GEN (z)); \
}
/****************************************************************************/
#ifdef HAVE_LIBMPFR
WRAP_F_F(erf)
WRAP_F_F(zeta)
/* Basic arithmetic functions */
WRAP_F_FF(add)
WRAP_F_FF(sub)
WRAP_F_FF(mul)
WRAP_F_F(sqr)
WRAP_F_FF(div)
WRAP_F_F(sqrt)
WRAP_F_F(rec_sqrt)
WRAP_F_F(cbrt)
WRAP_F_FF(pow)
/* Special functions */
WRAP_F_F(log)
WRAP_F_F(log2)
WRAP_F_F(log10)
WRAP_F_F(exp)
WRAP_F_F(exp2)
WRAP_F_F(exp10)
WRAP_F_F(cos)
WRAP_F_F(sin)
WRAP_F_F(tan)
WRAP_F_F(sec)
WRAP_F_F(csc)
WRAP_F_F(cot)
WRAP_F_F(acos)
WRAP_F_F(asin)
WRAP_F_F(atan)
WRAP_F_F(cosh)
WRAP_F_F(sinh)
WRAP_F_F(tanh)
WRAP_F_F(sech)
WRAP_F_F(csch)
WRAP_F_F(coth)
WRAP_F_F(acosh)
WRAP_F_F(asinh)
WRAP_F_F(atanh)
WRAP_F_u(fac_ui)
WRAP_F_F(log1p)
WRAP_F_F(expm1)
WRAP_F_F(eint)
WRAP_F_F(li2)
WRAP_F_F(gamma)
WRAP_F_F(lngamma)
WRAP_F_F(digamma)
WRAP_F_F(zeta)
WRAP_F_F(erf)
WRAP_F_F(erfc)
WRAP_F_F(j0)
WRAP_F_F(j1)
WRAP_F_lF(jn)
WRAP_F_F(y0)
WRAP_F_F(y1)
WRAP_F_lF(yn)
WRAP_F_FFF(fma)
WRAP_F_FFF(fms)
WRAP_F_FF(agm)
WRAP_F_FF(hypot)
WRAP_F_F(ai)
#endif
......@@ -91,9 +91,60 @@ void acb_set_GEN(acb_t y, const GEN x, slong prec);
/* Bindings to the different libraries. */
#ifdef HAVE_LIBMPFR
GEN pari_mpfr_add (GEN x, GEN y, long prec);
GEN pari_mpfr_sub (GEN x, GEN y, long prec);
GEN pari_mpfr_mul (GEN x, GEN y, long prec);
GEN pari_mpfr_erf (GEN x, long prec);
GEN pari_mpfr_sqr (GEN x, long prec);
GEN pari_mpfr_div (GEN x, GEN y, long prec);
GEN pari_mpfr_sqrt (GEN x, long prec);
GEN pari_mpfr_rec_sqrt (GEN x, long prec);
GEN pari_mpfr_cbrt (GEN x, long prec);
GEN pari_mpfr_log (GEN x, long prec);
GEN pari_mpfr_log2 (GEN x, long prec);
GEN pari_mpfr_log10 (GEN x, long prec);
GEN pari_mpfr_exp (GEN x, long prec);
GEN pari_mpfr_exp2 (GEN x, long prec);
GEN pari_mpfr_exp10 (GEN x, long prec);
GEN pari_mpfr_cos (GEN x, long prec);
GEN pari_mpfr_sin (GEN x, long prec);
GEN pari_mpfr_tan (GEN x, long prec);
GEN pari_mpfr_sec (GEN x, long prec);
GEN pari_mpfr_csc (GEN x, long prec);
GEN pari_mpfr_cot (GEN x, long prec);
GEN pari_mpfr_acos (GEN x, long prec);
GEN pari_mpfr_asin (GEN x, long prec);
GEN pari_mpfr_atan (GEN x, long prec);
GEN pari_mpfr_cosh (GEN x, long prec);
GEN pari_mpfr_sinh (GEN x, long prec);
GEN pari_mpfr_tanh (GEN x, long prec);
GEN pari_mpfr_sech (GEN x, long prec);
GEN pari_mpfr_csch (GEN x, long prec);
GEN pari_mpfr_coth (GEN x, long prec);
GEN pari_mpfr_acosh (GEN x, long prec);
GEN pari_mpfr_asinh (GEN x, long prec);
GEN pari_mpfr_atanh (GEN x, long prec);
GEN pari_mpfr_fac_ui (unsigned long int i, long prec);
GEN pari_mpfr_log1p (GEN x, long prec);
GEN pari_mpfr_expm1 (GEN x, long prec);
GEN pari_mpfr_eint (GEN x, long prec);
GEN pari_mpfr_li2 (GEN x, long prec);
GEN pari_mpfr_gamma (GEN x, long prec);
GEN pari_mpfr_lngamma (GEN x, long prec);
GEN pari_mpfr_digamma (GEN x, long prec);
GEN pari_mpfr_zeta (GEN x, long prec);
GEN pari_mpfr_erf (GEN x, long prec);
GEN pari_mpfr_erfc (GEN x, long prec);
GEN pari_mpfr_j0 (GEN x, long prec);
GEN pari_mpfr_j1 (GEN x, long prec);
GEN pari_mpfr_jn (long int i, GEN x, long prec);
GEN pari_mpfr_y0 (GEN x, long prec);
GEN pari_mpfr_y1 (GEN x, long prec);
GEN pari_mpfr_yn (long int i, GEN x, long prec);
GEN pari_mpfr_fma (GEN x, GEN y, GEN z, long prec);
GEN pari_mpfr_fms (GEN x, GEN y, GEN z, long prec);
GEN pari_mpfr_agm (GEN x, GEN y, long prec);
GEN pari_mpfr_hypot (GEN x, GEN y, long prec);
GEN pari_mpfr_ai (GEN x, long prec);
#endif
#ifdef HAVE_LIBMPC
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment