Lehmer extended GCD

238 Views Asked by At

There is a C-library of long arithmetic, FLINT.
It has a function:
void fmpz_xgcd_partial ( fmpz_t co2 , fmpz_t co1 , fmpz_t r2 , fmpz_t r1 , const fmpz_t L ).
Here is its description from the documentation:

This function is an implementation of Lehmer extended GCD with early termination, as used in the qfb module. It terminates early when remainders fall below the specified bound. The initial values r1 and r2 are treated as successive remainders in the Euclidean algorithm and are replaced with the last two remainders computed. The values co1 and co2 are the last two cofactors and satisfy the identity co2*r1 - co1*r2 == +/- r2_orig upon termination, where r2_orig is the starting value of r2 supplied, and r1 and r2 are the final values.

My question: how to calculate extended GCD(with Bezout coefficients) of two numbers by using this function?
Thank you!