void my_mpz_mul (mpz_t r, mpz_srcptr a, mpz_srcptr b) { mp_limb_t *tp; mp_size_t tn, an, bn; an = mpz_size (a); bn = mpz_size (b); assert (an > 0); assert (bn > 0); tn = an + bn; tp = mpz_limbs_write (r, tn); if (an > bn) mpn_mul (tp, mpz_limbs_read (a), an, mpz_limbs_read (b), bn); else mpn_mul (tp, mpz_limbs_read (b), bn, mpz_limbs_read (a), an); if (mpz_sgn (a) != mpz_sgn(b)) tn = - tn; mpz_limbs_finish (r, tn); }
void mpz_set_n (mpz_t r, const mp_limb_t *xp, mp_size_t xn) { mpn_copyi (mpz_limbs_write (r, xn), xp, xn); mpz_limbs_finish (r, xn); }