PBC follows GMP in several respects:
- Output arguments generally precede input arguments.
- The same variable can be used as input and output in one call.
- Before a variable may be used it must be initialized exactly once. When no longer needed it must be cleared. For efficiency, unnecessary initializating and clearing should be avoided.
- PBC variables ending with
_tbehave the same as GMP variables in function calls: effectively as call-by references. In other words, as in GMP, if a function that modifies an input variable, that variable remains modified when control return is returned to the caller. - Like GMP, variables automatically allocate memory when
needed. By default.
malloc()and friends are called but this can be changed. - The
element_ttype is small (but certain other types are not). - PBC functions are mostly reentrant.
Recall GMP has the mpz_t type
for integers, mpq_t for rationals
and so on. In contrast, PBC uses the element_t data type for elements of different
algebraic structures, such as elliptic curve groups, polynomial
rings and finite fields. Many functions assume the inputs come
from the same algebraic structure and trouble can arise if for
example one attempts to add a polynomial to a point on an
elliptic curve.
The algebraic structure that an element_t variable belongs to is specified in
an initialization call.