Next: Assigning Complex Numbers, Up: Complex Functions [Index]
An mpc_t
object must be initialized before storing the first value in
it. The functions mpc_init2
and mpc_init3
are used for that purpose.
Initialize z to precision prec bits
and set its real and imaginary parts to NaN.
Normally, a variable should be initialized once only
or at least be cleared, using mpc_clear
, between initializations.
Initialize z with the precision of its real part being prec_r bits and the precision of its imaginary part being prec_i bits, and set the real and imaginary parts to NaN.
Free the space occupied by z. Make sure to call this function for all
mpc_t
variables when you are done with them.
Here is an example on how to initialize complex variables:
{ mpc_t x, y; mpc_init2 (x, 256); /* precision exactly 256 bits */ mpc_init3 (y, 100, 50); /* 100/50 bits for the real/imaginary part */ … mpc_clear (x); mpc_clear (y); }
The following function is useful for changing the precision during a calculation. A typical use would be for adjusting the precision gradually in iterative algorithms like Newton-Raphson, making the computation precision closely match the actual accurate part of the numbers.
Reset the precision of x to be exactly prec bits,
and set its real/imaginary parts to NaN.
The previous value stored in x is lost. It is equivalent to
a call to mpc_clear(x)
followed by a call to
mpc_init2(x, prec)
, but more efficient as no allocation is done in
case the current allocated space for the mantissa of x is sufficient.
If the real and imaginary part of x have the same precision, it is returned, otherwise, 0 is returned.
Returns the precision of the real part of x via pr and of its imaginary part via pi.
Next: Assigning Complex Numbers, Up: Complex Functions [Index]