1/* mpn_mulmid_n -- balanced middle product 2 3 Contributed by David Harvey. 4 5 THE FUNCTION IN THIS FILE IS INTERNAL WITH A MUTABLE INTERFACE. IT IS ONLY 6 SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST 7 GUARANTEED THAT IT'LL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. 8 9Copyright 2011 Free Software Foundation, Inc. 10 11This file is part of the GNU MP Library. 12 13The GNU MP Library is free software; you can redistribute it and/or modify 14it under the terms of either: 15 16 * the GNU Lesser General Public License as published by the Free 17 Software Foundation; either version 3 of the License, or (at your 18 option) any later version. 19 20or 21 22 * the GNU General Public License as published by the Free Software 23 Foundation; either version 2 of the License, or (at your option) any 24 later version. 25 26or both in parallel, as here. 27 28The GNU MP Library is distributed in the hope that it will be useful, but 29WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 30or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31for more details. 32 33You should have received copies of the GNU General Public License and the 34GNU Lesser General Public License along with the GNU MP Library. If not, 35see https://www.gnu.org/licenses/. */ 36 37 38#include "gmp-impl.h" 39 40 41void 42mpn_mulmid_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n) 43{ 44 ASSERT (n >= 1); 45 ASSERT (! MPN_OVERLAP_P (rp, n + 2, ap, 2*n - 1)); 46 ASSERT (! MPN_OVERLAP_P (rp, n + 2, bp, n)); 47 48 if (n < MULMID_TOOM42_THRESHOLD) 49 { 50 mpn_mulmid_basecase (rp, ap, 2*n - 1, bp, n); 51 } 52 else 53 { 54 mp_ptr scratch; 55 TMP_DECL; 56 TMP_MARK; 57 scratch = TMP_ALLOC_LIMBS (mpn_toom42_mulmid_itch (n)); 58 mpn_toom42_mulmid (rp, ap, bp, n, scratch); 59 TMP_FREE; 60 } 61} 62