/* put in {c, 2n} where n = 2k+r the value of {v0,2k} (already in place) + B^k * [{v1, 2k+1} - {t1, 2k+1}] + B^(2k) * [{t2, 2k+1} - {v0+vinf, 2k}] + B^(3k) * [{t1, 2k+1} - {t2, 2k+1}] + B^(4k) * {vinf,2r} (high 2r-1 limbs already in place) where {t1, 2k+1} = (3*{v0,2k}+2*sa*{vm1,2k+1}+{v2,2k+1})/6-2*{vinf,2r} {t2, 2k+1} = ({v1, 2k+1} + sa * {vm1, 2k+1})/2 (sa is the sign of {vm1, 2k+1}). {vinf, 2r} stores the content of {v0, 2r} + {vinf, 2r}, with carry in cinf0. vinf0 is the low limb of vinf. ws is temporary space, and should have at least 2r limbs. Think about: The evaluated point a-b+c stands a good chance of having a zero carry limb, a+b+c would have a 1/4 chance, and 4*a+2*b+c a 1/8 chance, roughly. Perhaps this could be tested and stripped. Doing so before recursing would be better than stripping at the start of mpn_toom3_mul_n/sqr_n, since then the recursion could be based on the new size. Although in truth the kara vs toom3 crossover is never so exact that one limb either way makes a difference. A small value like 1 or 2 for the carry could perhaps also be handled with an add_n or addlsh1_n. Would that be faster than an extra limb on a (recursed) multiply/square? */ static void toom3_interpolate (mp_ptr c, mp_srcptr v1, mp_ptr v2, mp_ptr vm1, mp_ptr vinf, mp_size_t k, mp_size_t r, int sa, mp_limb_t vinf0, mp_limb_t cinf0, mp_ptr ws) { mp_limb_t cy, saved; unsigned long twok = k + k; unsigned long kk1 = twok + 1; unsigned long twor = r + r; mp_ptr c1, c2, c3, c4, c5; mp_limb_t cout; /* final carry, should be zero at the end */ c1 = c + k; c2 = c1 + k; c3 = c2 + k; c4 = c3 + k; c5 = c4 + k; #define v0 (c) /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 |vm1| hi(vinf) v1 v2+2vm1 vinf +lo(v0) */ ASSERT_NOCARRY (mpn_divexact_by3 (v2, v2, kk1)); /* v2 <- v2 / 3 */ #ifdef HAVE_NATIVE_mpn_rsh1add_n mpn_rsh1add_n (v2, v2, v0, twok); /* v2 <- (lo(v2)+v0) / 2, exact */ cy = v2[twok] & 1; /* add high limb of v2 divided by 2 */ v2[twok] >>= 1; MPN_INCR_U (v2 + twok - 1, 2, cy << (GMP_NUMB_BITS - 1)); #else v2[twok] += mpn_add_n (v2, v2, v0, twok); mpn_rshift (v2, v2, kk1, 1); #endif /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 |vm1| hi(vinf) v1 (3v0+2vm1+v2) vinf /6 +lo(v0) */ /* vm1 <- t2 := (v1 + sa*vm1) / 2 t2 = a0*b0+a0*b2+a1*b1+a2*b0+a2*b2 >= 0 No carry comes out from {v1, kk1} +/- {vm1, kk1}, and the division by two is exact */ if (sa >= 0) { #ifdef HAVE_NATIVE_mpn_rsh1add_n mpn_rsh1add_n (vm1, v1, vm1, kk1); #else mpn_add_n (vm1, vm1, v1, kk1); mpn_rshift (vm1, vm1, kk1, 1); #endif } else { #ifdef HAVE_NATIVE_mpn_rsh1sub_n mpn_rsh1sub_n (vm1, v1, vm1, kk1); #else mpn_sub_n (vm1, v1, vm1, kk1); mpn_rshift (vm1, vm1, kk1, 1); #endif } /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 t2 hi(vinf) v1 t1 vinf+lo(v0) */ /* subtract 2*vinf to v2, result is t1 := a0*b0+a0*b2+a1*b1+a1*b2+a2*b0+a2*b1+a2*b2 >= 0 */ saved = c4[0]; c4[0] = vinf0; #ifdef HAVE_NATIVE_mpn_sublsh1_n cy = mpn_sublsh1_n (v2, v2, c4, twor); #else cy = mpn_lshift (ws, c4, twor, 1); cy += mpn_sub_n (v2, v2, ws, twor); #endif MPN_DECR_U (v2 + twor, kk1 - twor, cy); c4[0] = saved; /* subtract {t2, 2k+1} in {c+3k, 2k+1} i.e. in {t2+k, 2k+1}: by chunks of k limbs from right to left to avoid overlap */ #define t2 (vm1) /* a borrow may occur in one of the 2 following __GMPN_SUB_1 calls, but since the final result is nonnegative, it will be compensated later on */ __GMPN_SUB_1 (cout, c5, c5, twor - k, t2[twok]); cy = mpn_sub_n (c4, c4, t2 + k, k); __GMPN_SUB_1 (cout, c5, c5, twor - k, cy); cy = mpn_sub_n (c3, c3, t2, k); __GMPN_SUB_1 (cout, c4, c4, twor, cy); /* don't forget to add vinf0 in {c+4k, ...} */ __GMPN_ADD_1 (cout, c4, c4, twor, vinf0); /* c c+k c+2k c+3k c+4k+1 t t+2k+1 t+4k+2 v0 t2 hi(vinf) v1 t1 vinf -t2 +lo(v0) */ /* c c+k c+2k c+3k c+4k t t+2k+1 t+4k+2 v0 t2 vinf v1 t1 vinf -t2 +lo(v0) */ /* subtract v0+vinf in {c+2k, ...} */ cy = cinf0 + mpn_sub_n (c2, c2, vinf, twor); if (twor < twok) { __GMPN_SUB_1 (cy, c2 + twor, c2 + twor, twok - twor, cy); cy += mpn_sub_n (c2 + twor, c2 + twor, v0 + twor, twok - twor); } __GMPN_SUB_1 (cout, c4, c4, twor, cy); /* 2n-4k = 2r */ /* c c+k c+2k c+3k c+4k t t+2k+1 t+4k+2 v0 t2 vinf v1 t1 vinf -v0 -t2 +lo(v0) -vinf */ /* subtract t1 in {c+k, ...} */ cy = mpn_sub_n (c1, c1, v2, kk1); __GMPN_SUB_1 (cout, c3 + 1, c3 + 1, twor + k - 1, cy); /* 2n-(3k+1)=k+2r-1 */ /* c c+k c+2k c+3k c+4k t t+2k+1 t+4k+2 v0 t2 vinf v1 t1 vinf -t1 -v0 -t2 -vinf */ /* add t1 in {c+3k, ...} */ cy = mpn_add_n (c3, c3, v2, kk1); __GMPN_ADD_1 (cout, c5 + 1, c5 + 1, twor - k - 1, cy); /* 2n-(5k+1) = 2r-k-1 */ /* c c+k c+2k c+3k c+4k t t+2k+1 t+4k+2 v0 t2 t1 vinf v1 t1 vinf -t1 -v0 -t2 -vinf */ /* add v1 in {c+k, ...} */ cy = mpn_add_n (c1, c1, v1, kk1); __GMPN_ADD_1 (cout, c3 + 1, c3 + 1, twor + k - 1, cy); /* 2n-(3k+1) = 2r+k-1 */ /* c c+k c+2k c+3k c+4k t t+2k+1 t+4k+2 v0 v1 t2 t1 vinf v1 t1 vinf -t1 -v0 -t2 -vinf */ #undef v0 #undef t2 }
void mpn_toom3_mul (mp_ptr c, mp_srcptr a, mp_size_t an, mp_srcptr b, mp_size_t bn, mp_ptr t) { mp_size_t k, k1, kk1, r, r2, twok, rr2; mp_limb_t cy, cc, saved, vinf0, c20, c21; mp_ptr trec; int sa, sb; mp_ptr c1, c2, c3, c4, t1, t2, t3, t4; ASSERT(GMP_NUMB_BITS >= 6); k = (an + 2) / 3; /* ceil(an/3) */ ASSERT(bn > 2*k); ASSERT(an >= 20); twok = 2 * k; k1 = k + 1; kk1 = k + k1; r = an - twok; /* last chunk */ r2 = bn - twok; /* last chunk */ rr2 = r + r2; c1 = c + k; c2 = c1 + k; c3 = c2 + k; c4 = c3 + k; t1 = t + k; t2 = t1 + k; t3 = t2 + k; t4 = t3 + k; trec = t + 4 * k + 4; /* put a0+a2 in {t, k+1}, and b0+b2 in {t1 + 1, k+1}; put a0+a1+a2 in {t2 + 2, k+1} and b0+b1+b2 in {t3 + 3,k+1} */ cy = mpn_add_n (t, a, a + twok, r); cc = mpn_add_n (t1 + 1, b, b + twok, r2); if (r < k) { __GMPN_ADD_1 (cy, t + r, a + r, k - r, cy); } if (r2 < k) { __GMPN_ADD_1 (cc, t1 + 1 + r2, b + r2, k - r2, cc); } t3[2] = (t1[0] = cy) + mpn_add_n (t2 + 2, t, a + k, k); t4[3] = (t2[1] = cc) + mpn_add_n (t3 + 3, t1 + 1, b + k, k); /* compute v1 := (a0+a1+a2)*(b0+b1+b2) in {c2, 2k+1}; since v1 < 9*B^(2k), v1 uses only 2k+1 words if GMP_NUMB_BITS >= 4 */ TOOM3_MUL_REC (c2, t2 + 2, t3 + 3, k1, trec); /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v1 */ /* put |a0-a1+a2| in {t2 + 2, k+1} and |b0-b1+b2| in {t3 + 3,k+1} */ /* sa = sign(a0-a1+a2) */ /* sb = sign(b0-b1+b2) */ sa = (t[k] != 0) ? 1 : mpn_cmp (t, a + k, k); t3[2] = (sa >= 0) ? t[k] - mpn_sub_n (t2 + 2, t, a + k, k) : mpn_sub_n (t2 + 2, a + k, t, k); /* b0+b2 is in {c+k+1, k+1} now */ sb = (t2[1] != 0) ? 1 : mpn_cmp (t1 + 1, b + k, k); t4[3] = (sb >= 0) ? t2[1] - mpn_sub_n (t3 + 3, t1 + 1, b + k, k) : mpn_sub_n (t3 + 3, b + k, t1 + 1, k); sa *= sb; /* sign of vm1 */ /* compute vm1 := (a0-a1+a2)*(b0-b1+b2) in {t, 2k+1}; since |vm1| < 4*B^(2k), vm1 uses only 2k+1 limbs */ TOOM3_MUL_REC (t, t2 + 2, t3 + 3, k1, trec); /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v1 {t, 2k+1} {t+2k+1, 2k + 1} vm1 */ c20 = c2[0]; /* save c2[0] and c2[1] giving space 2k+2 at c */ c21 = c2[1]; /* compute a0+2a1+4a2 in {c, k+1} and b0+2b1+4b2 in {c1 + 1, k+1} */ #if HAVE_NATIVE_mpn_addlsh1_n c1[0] = mpn_addlsh1_n (c, a + k, a + twok, r); c2[1] = mpn_addlsh1_n (c1 + 1, b + k, b + twok, r2); if (r < k) { __GMPN_ADD_1 (c1[0], c + r, a + k + r, k - r, c1[0]); } if (r2 < k) {__GMPN_ADD_1 (c2[1], c1 + 1 + r2, b + k + r2, k - r2, c2[1]); } c1[0] = 2 * c1[0] + mpn_addlsh1_n (c, a, c, k); c2[1] = 2 * c2[1] + mpn_addlsh1_n (c1 + 1, b, c1 + 1, k); #else c[r] = mpn_lshift1 (c, a + twok, r); c1[r2 + 1] = mpn_lshift1 (c1 + 1, b + twok, r2); if (r < k) { MPN_ZERO(c + r + 1, k - r); } if (r2 < k) { MPN_ZERO(c1 + r2 + 2, k - r2); } c1[0] += mpn_add_n (c, c, a + k, k); c2[1] += mpn_add_n (c1 + 1, c1 + 1, b + k, k); mpn_double (c, k1); mpn_double (c1 + 1, k1); c1[0] += mpn_add_n (c, c, a, k); c2[1] += mpn_add_n (c1 + 1, c1 + 1, b, k); #endif #define v2 (t+2*k+1) /* compute v2 := (a0+2a1+4a2)*(b0+2b1+4b2) in {t+2k+1, 2k+1} v2 < 49*B^k so v2 uses at most 2k+1 limbs if GMP_NUMB_BITS >= 6 */ TOOM3_MUL_REC (v2, c, c1 + 1, k1, trec); /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v1 {t, 2k+1} {t+2k+1, 2k + 1} vm1 v2 */ c2[0] = c20; /* restore c2[0] and c2[1] */ c2[1] = c21; /* compute v0 := a0*b0 in {c, 2k} */ TOOM3_MUL_REC (c, a, b, k, trec); /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v0 v1 {t, 2k+1} {t+2k+1, 2k + 1} vm1 v2 */ #define vinf (c+4*k) /* compute vinf := a2*b2 in {c4, r + r2}, */ saved = c4[0]; if (r == r2) TOOM3_MUL_REC (c4, a + twok, b + twok, r, trec); else if (r > r2) mpn_mul(c4, a + twok, r, b + twok, r2); else mpn_mul(c4, b + twok, r2, a + twok, r); vinf0 = c4[0]; c4[0] = saved; /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v0 v1 {-}vinf {t, 2k+1} {t+2k+1, 2k + 1} vm1 v2 vinf0 = {-} */ mpn_toom3_interpolate (c, c2, v2, t, vinf, k, rr2, sa, vinf0, t4+2); #undef v2 #undef vinf }
void mpn_toom_interpolate_5pts (mp_ptr c, mp_ptr v2, mp_ptr vm1, mp_size_t k, mp_size_t twor, int sa, mp_limb_t vinf0, mp_ptr ws) { mp_limb_t cy, saved; mp_size_t twok = k + k; mp_size_t kk1 = twok + 1; mp_ptr c1, v1, c3, vinf, c5; mp_limb_t cout; /* final carry, should be zero at the end */ c1 = c + k; v1 = c1 + k; c3 = v1 + k; vinf = c3 + k; c5 = vinf + k; #define v0 (c) /* (1) v2 <- v2-vm1 < v2+|vm1|, (16 8 4 2 1) - (1 -1 1 -1 1) = thus 0 <= v2 < 50*B^(2k) < 2^6*B^(2k) (15 9 3 3 0) */ if (sa <= 0) mpn_add_n (v2, v2, vm1, kk1); else mpn_sub_n (v2, v2, vm1, kk1); /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 v1 hi(vinf) |vm1| v2-vm1 EMPTY */ ASSERT_NOCARRY (mpn_divexact_by3 (v2, v2, kk1)); /* v2 <- v2 / 3 */ /* (5 3 1 1 0)*/ /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 v1 hi(vinf) |vm1| (v2-vm1)/3 EMPTY */ /* (2) vm1 <- tm1 := (v1 - sa*vm1) / 2 [(1 1 1 1 1) - (1 -1 1 -1 1)] / 2 = tm1 >= 0 (0 1 0 1 0) No carry comes out from {v1, kk1} +/- {vm1, kk1}, and the division by two is exact */ if (sa <= 0) { #ifdef HAVE_NATIVE_mpn_rsh1add_n mpn_rsh1add_n (vm1, v1, vm1, kk1); #else mpn_add_n (vm1, v1, vm1, kk1); mpn_rshift (vm1, vm1, kk1, 1); #endif } else { #ifdef HAVE_NATIVE_mpn_rsh1sub_n mpn_rsh1sub_n (vm1, v1, vm1, kk1); #else mpn_sub_n (vm1, v1, vm1, kk1); mpn_rshift (vm1, vm1, kk1, 1); #endif } /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 v1 hi(vinf) tm1 (v2-vm1)/3 EMPTY */ /* (3) v1 <- t1 := v1 - v0 (1 1 1 1 1) - (0 0 0 0 1) = (1 1 1 1 0) t1 >= 0 */ vinf[0] -= mpn_sub_n (v1, v1, c, twok); /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 v1-v0 hi(vinf) tm1 (v2-vm1)/3 EMPTY */ /* (4) v2 <- t2 := ((v2-vm1)/3-t1)/2 = (v2-vm1-3*t1)/6 t2 >= 0 [(5 3 1 1 0) - (1 1 1 1 0)]/2 = (2 1 0 0 0) */ #ifdef HAVE_NATIVE_mpn_rsh1sub_n mpn_rsh1sub_n (v2, v2, v1, kk1); #else mpn_sub_n (v2, v2, v1, kk1); mpn_rshift (v2, v2, kk1, 1); #endif /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 v1-v0 hi(vinf) tm1 (v2-vm1-3t1)/6 EMPTY */ /* (5) v1 <- t1-tm1 (1 1 1 1 0) - (0 1 0 1 0) = (1 0 1 0 0) result is v1 >= 0 */ mpn_sub_n (v1, v1, vm1, kk1); /* {c,2k} {c+2k,2k+1} {c+4k+1,2r-1} {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 v1-v0-tm1 hi(vinf) tm1 (v2-vm1-3t1)/6 EMPTY */ /* (6) v2 <- v2 - 2*vinf, (2 1 0 0 0) - 2*(1 0 0 0 0) = (0 1 0 0 0) result is v2 >= 0 */ saved = vinf[0]; /* Remember v1's highest byte (will be overwritten). */ vinf[0] = vinf0; /* Set the right value for vinf0 */ #ifdef HAVE_NATIVE_mpn_sublsh1_n cy = mpn_sublsh1_n (v2, v2, vinf, twor); #else cy = mpn_lshift (ws, vinf, twor, 1); cy += mpn_sub_n (v2, v2, ws, twor); #endif MPN_DECR_U (v2 + twor, kk1 - twor, cy); /* (7) v1 <- v1 - vinf, (1 0 1 0 0) - (1 0 0 0 0) = (0 0 1 0 0) result is >= 0 */ cy = mpn_sub_n (v1, v1, vinf, twor); /* vinf is at most twor long. */ vinf[0] = saved; MPN_DECR_U (v1 + twor, kk1 - twor, cy); /* Treat the last bytes. */ __GMPN_ADD_1 (cout, vinf, vinf, twor, vinf0); /* Add vinf0, propagate carry. */ /* (8) vm1 <- vm1-t2 (0 1 0 1 0) - (0 1 0 0 0) = (0 0 0 1 0) vm1 >= 0 */ mpn_sub_n (vm1, vm1, v2, kk1); /* No overlapping here. */ /********************* Beginning the final phase **********************/ /* {c,2k} {c+2k,2k } {c+4k ,2r } {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 t1 hi(t1)+vinf tm1 (v2-vm1-3t1)/6 EMPTY */ /* (9) add t2 in {c+3k, ...} */ cy = mpn_add_n (c3, c3, v2, kk1); __GMPN_ADD_1 (cout, c5 + 1, c5 + 1, twor - k - 1, cy); /* 2n-(5k+1) = 2r-k-1 */ /* {c,2k} {c+2k,2k } {c+4k ,2r } {t,2k+1} {t+2k+1,2k+1} {t+4k+2,2r} v0 t1 hi(t1)+vinf tm1 (v2-vm1-3t1)/6 EMPTY */ /* c c+k c+2k c+3k c+4k t t+2k+1 t+4k+2 v0 t1 vinf tm1 t2 +t2 */ /* add vm1 in {c+k, ...} */ cy = mpn_add_n (c1, c1, vm1, kk1); __GMPN_ADD_1 (cout, c3 + 1, c3 + 1, twor + k - 1, cy); /* 2n-(3k+1) = 2r+k-1 */ /* c c+k c+2k c+3k c+4k t t+2k+1 t+4k+2 v0 t1 vinf tm1 t2 +tm1 +t2 */ #undef v0 #undef t2 }
void mpn_toom3_sqr_n (mp_ptr c, mp_srcptr a, mp_size_t n, mp_ptr t) { mp_size_t k, k1, kk1, r, twok, rr2; mp_limb_t cy, cc, saved, vinf0; mp_ptr trec; int sa; mp_ptr c1, c2, c3, c4, c5, t1, t2, t3, t4; ASSERT(GMP_NUMB_BITS >= 6); k = (n + 2) / 3; /* ceil(n/3) */ ASSERT(GMP_NUMB_BITS >= 6); ASSERT(n >= 17); /* so that r <> 0 and 5k+3 <= 2n */ twok = 2 * k; k1 = k + 1; kk1 = k + k1; r = n - twok; /* last chunk */ rr2 = 2*r; c1 = c + k; c2 = c1 + k; c3 = c2 + k; c4 = c3 + k; c5 = c4 + k; t1 = t + k; t2 = t1 + k; t3 = t2 + k; t4 = t3 + k; trec = t + 4 * k + 3; /* put a0+a2 in {c, k+1} put a0+a1+a2 in {t2 + 1, k+1} */ cy = mpn_add_n (c, a, a + twok, r); if (r < k) { __GMPN_ADD_1 (cy, c + r, a + r, k - r, cy); } t3[1] = (c1[0] = cy) + mpn_add_n (t2 + 1, c, a + k, k); /* compute v1 := (a0+a1+a2)^2 in {c2, 2k+1}; since v1 < 9*B^(2k), v1 uses only 2k+1 words if GMP_NUMB_BITS >= 4 */ TOOM3_SQR_REC (c2, t2 + 1, k1, trec); /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v1 */ /* put |a0-a1+a2| in {c,k+1} */ sa = (c[k] != 0) ? 1 : mpn_cmp (c, a + k, k); c[k] = (sa >= 0) ? c[k] - mpn_sub_n (c, c, a + k, k) : mpn_sub_n (c, a + k, c, k); /* compute vm1 := (a0-a1+a2)^2 in {t, 2k+1}; since |vm1| < 4*B^(2k), vm1 uses only 2k+1 limbs */ TOOM3_SQR_REC (t, c, k1, trec); /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v1 {t, 2k+1} {t+2k+1, 2k + 1} vm1 */ /* compute a0+2a1+4a2 in {c, k+1} */ #if HAVE_NATIVE_mpn_addlsh1_n c1[0] = mpn_addlsh1_n (c, a + k, a + twok, r); if (r < k) { __GMPN_ADD_1 (c1[0], c + r, a + k + r, k - r, c1[0]); } c1[0] = 2 * c1[0] + mpn_addlsh1_n (c, a, c, k); #else c[r] = mpn_lshift1 (c, a + twok, r); if (r < k) { MPN_ZERO(c + r + 1, k - r); } c1[0] += mpn_add_n (c, c, a + k, k); mpn_double (c, k1); c1[0] += mpn_add_n (c, c, a, k); #endif #define v2 (t+2*k+1) /* compute v2 := (a0+2a1+4a2)^2 in {t+2k+1, 2k+1} v2 < 49*B^k so v2 uses at most 2k+1 limbs if GMP_NUMB_BITS >= 6 */ TOOM3_SQR_REC (v2, c, k1, trec); /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v1 {t, 2k+1} {t+2k+1, 2k + 1} vm1 v2 */ /* compute v0 := a0^2 in {c, 2k} */ TOOM3_SQR_REC (c, a, k, trec); /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v0 v1 {t, 2k+1} {t+2k+1, 2k + 1} vm1 v2 */ #define vinf (c+4*k) /* compute vinf := a2*b2 in {c4, r + r2}, */ saved = c4[0]; TOOM3_SQR_REC (c4, a + twok, r, trec); vinf0 = c4[0]; c4[0] = saved; /* {c,2k} {c+2k,2k+1} {c+4k+1,r+r2-1} v0 v1 {-}vinf {t, 2k+1} {t+2k+1, 2k + 1} vm1 v2 vinf0 = {-} */ mpn_toom3_interpolate (c, c2, v2, t, vinf, k, rr2, 1, vinf0, t4+2); #undef v2 #undef vinf }