mulmid_n.c revision 1.1.1.1
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 the GNU Lesser General Public License as published by
15the Free Software Foundation; either version 3 of the License, or (at your
16option) any later version.
17
18The GNU MP Library is distributed in the hope that it will be useful, but
19WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
21License for more details.
22
23You should have received a copy of the GNU Lesser General Public License
24along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
25
26
27#include "gmp.h"
28#include "gmp-impl.h"
29
30
31void
32mpn_mulmid_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n)
33{
34  ASSERT (n >= 1);
35  ASSERT (! MPN_OVERLAP_P (rp, n + 2, ap, 2*n - 1));
36  ASSERT (! MPN_OVERLAP_P (rp, n + 2, bp, n));
37
38  if (n < MULMID_TOOM42_THRESHOLD)
39    {
40      mpn_mulmid_basecase (rp, ap, 2*n - 1, bp, n);
41    }
42  else
43    {
44      mp_ptr scratch;
45      TMP_DECL;
46      TMP_MARK;
47      scratch = TMP_ALLOC_LIMBS (mpn_toom42_mulmid_itch (n));
48      mpn_toom42_mulmid (rp, ap, bp, n, scratch);
49      TMP_FREE;
50    }
51}
52