add a couple of fmpcb helper functions

This commit is contained in:
Fredrik Johansson 2012-11-10 18:53:47 +01:00
parent 8bb4f5a6a9
commit 4b05b7b123
2 changed files with 47 additions and 0 deletions

View file

@ -62,6 +62,8 @@ Basic manipulation
.. function:: void fmpcb_set(fmpcb_t z, const fmpcb_t x)
.. function:: void fmpcb_set_ui(fmpcb_t z, long x)
.. function:: void fmpcb_set_si(fmpcb_t z, long x)
.. function:: void fmpcb_set_fmpz(fmpcb_t z, const fmpz_t x)
@ -144,10 +146,14 @@ Arithmetic
Sets *z* to the complex conjugate of *x*.
.. function:: void fmpcb_add_ui(fmpcb_t z, const fmpcb_t x, ulong c, long prec)
.. function:: void fmpcb_add(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec)
Sets *z* to the sum of *x* and *y*.
.. function:: void fmpcb_sub_ui(fmpcb_t z, const fmpcb_t x, ulong c, long prec)
.. function:: void fmpcb_sub(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec)
Sets *z* to the difference of *x* and *y*.
@ -180,6 +186,10 @@ Arithmetic
has a large error and the other a small error, the output error will
be about twice that of the large input error, rather than about the same.
.. function:: void fmpcb_mul_2exp_si(fmpcb_t z, const fmpcb_t x, long e)
Sets *z* to *x* multiplied by `2^e`, without rounding.
.. function:: void fmpcb_addmul(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec)
.. function:: void fmpcb_submul(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec)
@ -190,6 +200,8 @@ Arithmetic
Sets *z* to the multiplicative inverse of *x*.
.. function:: void fmpcb_div_ui(fmpcb_t z, const fmpcb_t x, ulong y, long prec)
.. function:: void fmpcb_div(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec)
Sets *z* to the quotient of *x* and *y*.

35
fmpcb.h
View file

@ -160,6 +160,13 @@ fmpcb_contains_fmpz(const fmpcb_t x, const fmpz_t y)
fmprb_contains_zero(fmpcb_imagref(x));
}
static __inline__ void
fmpcb_set_ui(fmpcb_t z, ulong c)
{
fmprb_set_ui(fmpcb_realref(z), c);
fmprb_zero(fmpcb_imagref(z));
}
static __inline__ void
fmpcb_set_si(fmpcb_t z, long c)
{
@ -214,6 +221,20 @@ fmpcb_sub(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec)
fmprb_sub(fmpcb_imagref(z), fmpcb_imagref(x), fmpcb_imagref(y), prec);
}
static __inline__ void
fmpcb_add_ui(fmpcb_t z, const fmpcb_t x, ulong c, long prec)
{
fmprb_add_ui(fmpcb_realref(z), fmpcb_realref(x), c, prec);
fmprb_set_round(fmpcb_imagref(z), fmpcb_imagref(x), prec);
}
static __inline__ void
fmpcb_sub_ui(fmpcb_t z, const fmpcb_t x, ulong c, long prec)
{
fmprb_sub_ui(fmpcb_realref(z), fmpcb_realref(x), c, prec);
fmprb_set_round(fmpcb_imagref(z), fmpcb_imagref(x), prec);
}
static __inline__ void
fmpcb_neg(fmpcb_t z, const fmpcb_t x)
{
@ -261,6 +282,13 @@ void fmpcb_mul(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec);
void fmpcb_mul_alt(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec);
static __inline__ void
fmpcb_mul_2exp_si(fmpcb_t z, const fmpcb_t x, long e)
{
fmprb_mul_2exp_si(fmpcb_realref(z), fmpcb_realref(x), e);
fmprb_mul_2exp_si(fmpcb_imagref(z), fmpcb_imagref(x), e);
}
static __inline__ void
fmpcb_addmul(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec)
{
@ -314,6 +342,13 @@ fmpcb_div(fmpcb_t z, const fmpcb_t x, const fmpcb_t y, long prec)
fmpcb_clear(t);
}
static __inline__ void
fmpcb_div_ui(fmpcb_t z, const fmpcb_t x, ulong c, long prec)
{
fmprb_div_ui(fmpcb_realref(z), fmpcb_realref(x), c, prec);
fmprb_div_ui(fmpcb_imagref(z), fmpcb_imagref(x), c, prec);
}
void fmpcb_pow_fmpz(fmpcb_t y, const fmpcb_t b, const fmpz_t e, long prec);
void fmpcb_pow_ui(fmpcb_t y, const fmpcb_t b, ulong e, long prec);