Next: Converting Complex Numbers, Previous: Initializing Complex Numbers, Up: Complex Functions [Index]
These functions assign new values to already initialized complex numbers
(see Initializing Complex Numbers).
When using any functions with intmax_t
or uintmax_t
parameters, you must include
<stdint.h>
or <inttypes.h>
before mpc.h, to allow
mpc.h to define prototypes for these functions.
Similarly, functions with parameters of type complex
or
long complex
are defined only if <complex.h>
is included
before mpc.h.
If you need assignment functions that are not in the current API, you can
define them using the MPC_SET_X_Y
macro (see Advanced Functions).
Set the value of rop from op, rounded to the precision of rop with the given rounding mode rnd.
Set the value of rop from op, rounded to the precision of
rop with the given rounding mode rnd.
The argument op is interpreted as real, so the imaginary part of
rop is set to zero with a positive sign.
Please note that even a long int
may have to be rounded, if the
destination precision is less than the machine word width.
For mpc_set_d
, be careful that the input number op may not be
exactly representable as a double-precision number (this happens for 0.1 for
instance), in which case it is first rounded by the C compiler to a
double-precision number, and then only to a complex number.
Set the real part of rop from op1, and its imaginary part from op2, according to the rounding mode rnd.
Beware that the behaviour of mpc_set_fr_fr
is undefined if op1
or op2 is a pointer to the real or imaginary part of rop.
To exchange the real and the imaginary part of a complex number, either use
mpfr_swap (mpc_realref (rop), mpc_imagref (rop))
, which also exchanges
the precisions of the two parts; or use a temporary variable.
For functions assigning complex variables from strings or input streams, see String and Stream Input and Output.
Set rop to Nan+i*NaN.
Swap the values of op1 and op2 efficiently. Warning: The
precisions are exchanged, too; in case these are different,
mpc_swap
is thus not equivalent to three mpc_set
calls using a
third auxiliary variable.
Next: Converting Complex Numbers, Previous: Initializing Complex Numbers, Up: Complex Functions [Index]