Basic Arithmetic (GNU MPC 1.2.0)

Next: Power Functions and Logarithm, Previous: Projection & Decomposing, Up: Complex Functions [Index]

### 5.7 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 GNU MPFR library, with only a marginal overhead due to the GNU 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_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_sum (mpc_t rop, mpc_ptr* op, unsigned long n, mpc_rnd_t rnd)

  Set rop to the sum of the elements in the array op of length n, rounded according to rnd.

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. Note: for `mpc_mul`, in case op1 and op2 have the same value, use `mpc_sqr` for better efficiency.

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_fma (mpc_t rop, mpc_t op1, mpc_t op2, mpc_t op3, mpc_rnd_t rnd)

  Set rop to op1*op2+op3, rounded according to rnd, with only one final rounding.

Function: int mpc_dot (mpc_t rop, mpc_ptr* op1, mpc_ptr* op2, unsigned long n, mpc_rnd_t rnd)

  Set rop to the dot product of the elements in the arrays op1 and op2, both of length n, 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_div_fr (mpc_t rop, mpc_t op1, mpfr_t 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_fr_div (mpc_t rop, mpfr_t op1, mpc_t op2, mpc_rnd_t rnd)

  Set rop to op1/op2 rounded according to rnd.

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, mpfr_rnd_t rnd)

  Set the floating-point number rop to the absolute value of op, rounded in the direction rnd.

Function: int mpc_norm (mpfr_t rop, mpc_t op, mpfr_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.

Function: int mpc_mul_2ui (mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
Function: int mpc_mul_2si (mpc_t rop, mpc_t op1, long int op2, mpc_rnd_t rnd)

  Set rop to op1 times 2 raised to op2 rounded according to rnd. Just modifies the exponents of the real and imaginary parts by op2 when rop and op1 are identical.

Function: int mpc_div_2ui (mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
Function: int mpc_div_2si (mpc_t rop, mpc_t op1, long int op2, mpc_rnd_t rnd)

  Set rop to op1 divided by 2 raised to op2 rounded according to rnd. Just modifies the exponents of the real and imaginary parts by op2 when rop and op1 are identical.

Next: Power Functions and Logarithm, Previous: Projection & Decomposing, Up: Complex Functions [Index]