2009-07-24 13:16:50 -04:00
|
|
|
/*
|
|
|
|
Copyright 2009 Jason Moxham
|
2008-06-25 03:33:36 -04:00
|
|
|
|
2009-07-24 13:16:50 -04:00
|
|
|
This file is part of the MPIR Library.
|
2008-06-25 03:33:36 -04:00
|
|
|
|
2009-07-24 13:16:50 -04:00
|
|
|
The MPIR Library is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
|
|
|
by the Free Software Foundation; either version 2.1 of the License, or (at
|
|
|
|
your option) any later version.
|
2008-06-25 03:33:36 -04:00
|
|
|
|
2009-07-24 13:16:50 -04:00
|
|
|
The MPIR Library is distributed in the hope that it will be useful, but
|
2008-06-25 03:33:36 -04:00
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2009-07-24 13:16:50 -04:00
|
|
|
along with the MPIR Library; see the file COPYING.LIB. If not, write
|
|
|
|
to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2008-06-25 03:33:36 -04:00
|
|
|
|
2009-02-12 05:24:24 -05:00
|
|
|
#include "mpir.h"
|
2008-06-25 03:33:36 -04:00
|
|
|
#include "gmp-impl.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
FIXME: Should use mpn_addmul_2 (and higher).
|
|
|
|
*/
|
|
|
|
|
2009-07-24 13:16:50 -04:00
|
|
|
// (rp,xn+yn)=(xp,xn)*(yp,yn) mod B^n
|
2008-06-25 03:33:36 -04:00
|
|
|
void
|
2009-07-24 13:16:50 -04:00
|
|
|
mpn_mullow_basecase (mp_ptr rp, mp_srcptr xp, mp_size_t xn, mp_srcptr yp,
|
|
|
|
mp_size_t yn, mp_size_t n)
|
2008-06-25 03:33:36 -04:00
|
|
|
{
|
2009-07-24 13:16:50 -04:00
|
|
|
mp_limb_t c;
|
2008-06-25 03:33:36 -04:00
|
|
|
mp_size_t i;
|
|
|
|
|
2009-07-24 13:16:50 -04:00
|
|
|
// want some sort of threshold to call mpn_mul() etc like for the mpn_mullow_n cases
|
|
|
|
ASSERT (0 < yn);
|
|
|
|
ASSERT (yn <= xn);
|
|
|
|
ASSERT (xn <= n);
|
|
|
|
ASSERT (n <= xn + yn);
|
|
|
|
ASSERT_MPN (xp, xn);
|
|
|
|
ASSERT_MPN (yp, yn);
|
|
|
|
ASSERT (!MPN_OVERLAP_P (rp, xn + yn, xp, xn));
|
|
|
|
ASSERT (!MPN_OVERLAP_P (rp, xn + yn, yp, yn));
|
|
|
|
rp[xn] = mpn_mul_1 (rp, xp, xn, yp[0]);
|
|
|
|
for (i = 1; i <= n - xn && i < yn; i++)
|
|
|
|
rp[xn + i] = mpn_addmul_1 (rp + i, xp, xn, yp[i]);
|
|
|
|
for (i = i; i > n - xn && i < yn; i++)
|
|
|
|
mpn_addmul_1 (rp + i, xp, n - i, yp[i]);
|
|
|
|
return;
|
2008-06-25 03:33:36 -04:00
|
|
|
}
|