Search code examples
c++gmp

Naming conventions in GMP documentation


Currently I am looking at the GMP library's documentation, and I am having some difficulty understanding the naming conventions of the variables listed in the function specifications.

Particularly the use of rop and op confuses me.

Here is the page that lists import and export functions, and due to my confusion with the naming conventions, I am having a lot of trouble understanding exactly what they are to do.

https://gmplib.org/manual/Integer-Import-and-Export.html

Would it be possible to get an explanation on the naming conventions of the variables, and an explanation of what the functions do (in hopes that I can get an even better understanding that just knowing the naming conventions could provide)?


Solution

  • The naming conventations of GMP library are that rop means an result operand or output operand. while op is an input operand. Notice, that you may have multiple rops per one function in this manner.

    The GMP's API functions are designed, so that rops are always placed before ops. Regarding to its documentation, §3.4 Variable Conventions:

    GMP functions generally have output arguments before input arguments. This notation is by analogy with the assignment operator.

    For instance, to compute square root of big integer, you would function declared with prototype as:

    void mpz_sqrt (mpz t rop, const mpz t op);
    

    where the rop stores result of sqrt(op).