diff options
Diffstat (limited to 'gmp/mpn/generic/toom22_mul.c')
-rw-r--r-- | gmp/mpn/generic/toom22_mul.c | 53 |
1 files changed, 12 insertions, 41 deletions
diff --git a/gmp/mpn/generic/toom22_mul.c b/gmp/mpn/generic/toom22_mul.c index 36ac29b72d..6407bbeb96 100644 --- a/gmp/mpn/generic/toom22_mul.c +++ b/gmp/mpn/generic/toom22_mul.c @@ -7,33 +7,22 @@ SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. -Copyright 2006-2010, 2012 Free Software Foundation, Inc. +Copyright 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of either: - - * the GNU Lesser General Public License as published by the Free - Software Foundation; either version 3 of the License, or (at your - option) any later version. - -or - - * the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any - later version. - -or both in parallel, as here. +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 3 of the License, or (at your +option) any later version. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. -You should have received copies of the GNU General Public License and the -GNU Lesser General Public License along with the GNU MP Library. If not, -see https://www.gnu.org/licenses/. */ +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp.h" @@ -52,7 +41,7 @@ see https://www.gnu.org/licenses/. */ vinf= a1 * b1 # A(inf)*B(inf) */ -#if TUNE_PROGRAM_BUILD || WANT_FAT_BINARY +#if TUNE_PROGRAM_BUILD #define MAYBE_mul_toom22 1 #else #define MAYBE_mul_toom22 \ @@ -62,36 +51,18 @@ see https://www.gnu.org/licenses/. */ #define TOOM22_MUL_N_REC(p, a, b, n, ws) \ do { \ if (! MAYBE_mul_toom22 \ - || BELOW_THRESHOLD (n, MUL_TOOM22_THRESHOLD)) \ + || BELOW_THRESHOLD (n, MUL_KARATSUBA_THRESHOLD)) \ mpn_mul_basecase (p, a, n, b, n); \ else \ mpn_toom22_mul (p, a, n, b, n, ws); \ } while (0) -/* Normally, this calls mul_basecase or toom22_mul. But when when the fraction - MUL_TOOM33_THRESHOLD / MUL_TOOM22_THRESHOLD is large, an initially small - relative unbalance will become a larger and larger relative unbalance with - each recursion (the difference s-t will be invariant over recursive calls). - Therefore, we need to call toom32_mul. FIXME: Suppress depending on - MUL_TOOM33_THRESHOLD / MUL_TOOM22_THRESHOLD and on MUL_TOOM22_THRESHOLD. */ -#define TOOM22_MUL_REC(p, a, an, b, bn, ws) \ - do { \ - if (! MAYBE_mul_toom22 \ - || BELOW_THRESHOLD (bn, MUL_TOOM22_THRESHOLD)) \ - mpn_mul_basecase (p, a, an, b, bn); \ - else if (4 * an < 5 * bn) \ - mpn_toom22_mul (p, a, an, b, bn, ws); \ - else \ - mpn_toom32_mul (p, a, an, b, bn, ws); \ - } while (0) - void mpn_toom22_mul (mp_ptr pp, mp_srcptr ap, mp_size_t an, mp_srcptr bp, mp_size_t bn, mp_ptr scratch) { - const int __gmpn_cpuvec_initialized = 1; mp_size_t n, s, t; int vm1_neg; mp_limb_t cy, cy2; @@ -179,8 +150,8 @@ mpn_toom22_mul (mp_ptr pp, /* vm1, 2n limbs */ TOOM22_MUL_N_REC (vm1, asm1, bsm1, n, scratch_out); - if (s > t) TOOM22_MUL_REC (vinf, a1, s, b1, t, scratch_out); - else TOOM22_MUL_N_REC (vinf, a1, b1, s, scratch_out); + /* vinf, s+t limbs */ + mpn_mul (vinf, a1, s, b1, t); /* v0, 2n limbs */ TOOM22_MUL_N_REC (v0, ap, bp, n, scratch_out); |