5.6 Basic Arithmetic Functions
All the following functions are designed in such a way that, when working
with real numbers instead of complex numbers, their complexity should
essentially be the same as with the MPFR library, with only a marginal
overhead due to the MPC layer.
— Function: int
mpc_add (
mpc_t rop, mpc_t op1, mpc_t op2, mpc_rnd_t rnd)
— Function: int
mpc_add_ui (
mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
— Function: int
mpc_add_fr (
mpc_t rop, mpc_t op1, mpfr_t op2, mpc_rnd_t rnd)
Set rop to op1 + op2 rounded according to rnd.
— Function: int
mpc_sub (
mpc_t rop, mpc_t op1, mpc_t op2, mpc_rnd_t rnd)
— Function: int
mpc_sub_fr (
mpc_t rop, mpc_t op1, mpfr_t op2, mpc_rnd_t rnd)
— Function: int
mpc_fr_sub (
mpc_t rop, mpfr_t op1, mpc_t op2, mpc_rnd_t rnd)
— Function: int
mpc_sub_ui (
mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
— Macro: int
mpc_ui_sub (
mpc_t rop, unsigned long int op1, mpc_t op2, mpc_rnd_t rnd)
— Function: int
mpc_ui_ui_sub (
mpc_t rop, unsigned long int re1, unsigned long int im1, mpc_t op2, mpc_rnd_t rnd)
Set rop to op1 − op2 rounded according to rnd.
For mpc_ui_ui_sub
, op1 is re1 + im1.
— Function: int
mpc_mul (
mpc_t rop, mpc_t op1, mpc_t op2, mpc_rnd_t rnd)
— Function: int
mpc_mul_ui (
mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
— Function: int
mpc_mul_si (
mpc_t rop, mpc_t op1, long int op2, mpc_rnd_t rnd)
— Function: int
mpc_mul_fr (
mpc_t rop, mpc_t op1, mpfr_t op2, mpc_rnd_t rnd)
Set rop to op1 times op2 rounded according to rnd.
— Function: int
mpc_mul_i (
mpc_t rop, mpc_t op, int sgn, mpc_rnd_t rnd)
Set rop to op times the imaginary unit i if sgn is
non-negative, set rop to op times -i otherwise,
in both cases rounded according to rnd.
— Function: int
mpc_sqr (
mpc_t rop, mpc_t op, mpc_rnd_t rnd)
Set rop to the square of op rounded according to rnd.
— Function: int
mpc_div (
mpc_t rop, mpc_t op1, mpc_t op2, mpc_rnd_t rnd)
— Function: int
mpc_div_ui (
mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
— Function: int
mpc_ui_div (
mpc_t rop, unsigned long int op1, mpc_t op2, mpc_rnd_t rnd)
— Function: int
mpc_div_fr (
mpc_t rop, mpc_t op1, mpfr_t op2, mpc_rnd_t rnd)
— Function: int
mpc_fr_div (
mpc_t rop, mpfr_t op1, mpc_t op2, mpc_rnd_t rnd)
Set rop to op1/op2 rounded according to rnd.
For mpc_div
and mpc_ui_div
, the return value may fail to
recognize some exact results. The sign of returned value is
significant only for mpc_div_ui
.
— Function: int
mpc_neg (
mpc_t rop, mpc_t op, mpc_rnd_t rnd)
Set rop to −op rounded according to rnd.
Just changes the sign if rop and op are the same variable.
— Function: int
mpc_conj (
mpc_t rop, mpc_t op, mpc_rnd_t rnd)
Set rop to the conjugate of op rounded according to rnd.
Just changes the sign of the imaginary part
if rop and op are the same variable.
— Function: int
mpc_abs (
mpfr_t rop, mpc_t op, mp_rnd_t rnd)
Set the floating-point number rop to the absolute value of op,
rounded in the direction rnd.
The returned value is zero iff the result is exact.
— Function: int
mpc_norm (
mpfr_t rop, mpc_t op, mp_rnd_t rnd)
Set the floating-point number rop to the norm of op
(i.e. the square of its absolute value),
rounded in the direction rnd.
The returned value is zero iff the result is exact.
Note that the destination is of type mpfr_t
, not mpc_t
.
— Function: int
mpc_mul_2exp (
mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
Set rop to op1 times 2 raised to op2
rounded according to rnd. Just increases the exponents
of the real and imaginary parts by op2
when rop and op1 are identical.
— Function: int
mpc_div_2exp (
mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
Set rop to op1 divided by 2 raised to op2
rounded according to rnd. Just decreases the exponents
of the real and imaginary parts by op2
when rop and op1 are identical.