Next: , Previous: Trigonometric Functions, Up: Complex Functions


5.9 Miscellaneous Functions

— Function: int mpc_urandom (mpc_t rop, gmp_randstate_t state)

Generate a uniformly distributed random complex in the unit square [0, 1] * [0, 1]. Return 0, unless an exponent in the real or imaginary part is not in the current exponent range, in which case that part is set to NaN and a zero value is returned. The second argument is a gmp_randstate_t structure which should be created using the GMP rand_init function, see the GMP manual.

— Function: void mpc_random (mpc_t rop)

Generate a random complex, with real and imaginary parts uniformly distributed in the interval -1 < X < 1.

This function is deprecated and will be suppressed in the next release.

— Function: void mpc_random2 (mpc_t rop, mp_size_t max_size, mp_exp_t max_exp)

Generate a random complex, with real and imaginary part of at most max_size limbs, with long strings of zeros and ones in the binary representation. The exponent of the real (resp. imaginary) part is in the interval −exp to exp. This function is useful for testing functions and algorithms, since this kind of random numbers have proven to be more likely to trigger corner-case bugs. Negative parts are generated when max_size is negative.

This function is deprecated and will be suppressed in the next release.

— Function: const char * mpc_get_version (void)

Return the MPC version, as a null-terminated string.

— Macro: MPC_VERSION
— Macro: MPC_VERSION_MAJOR
— Macro: MPC_VERSION_MINOR
— Macro: MPC_VERSION_PATCHLEVEL
— Macro: MPC_VERSION_STRING

MPC_VERSION is the version of MPC as a preprocessing constant. MPC_VERSION_MAJOR, MPC_VERSION_MINOR and MPC_VERSION_PATCHLEVEL are respectively the major, minor and patch level of MPC version, as preprocessing constants. MPC_VERSION_STRING is the version as a string constant, which can be compared to the result of mpc_get_version to check at run time the header file and library used match:

          if (strcmp (mpc_get_version (), MPC_VERSION_STRING))
            fprintf (stderr, "Warning: header and library do not match\n");

Note: Obtaining different strings is not necessarily an error, as in general, a program compiled with some old MPC version can be dynamically linked with a newer MPC library version (if allowed by the library versioning system).

— Macro: long MPC_VERSION_NUM (major, minor, patchlevel)

Create an integer in the same format as used by MPC_VERSION from the given major, minor and patchlevel. Here is an example of how to check the MPC version at compile time:

          #if (!defined(MPC_VERSION) || (MPC_VERSION<MPC_VERSION_NUM(2,1,0)))
          # error "Wrong MPC version."
          #endif