/* Interpolation for the algorithm Toom-Cook 8.5-way.
Contributed to the GNU project by Marco Bodrato.
THE FUNCTION IN THIS FILE IS INTERNAL WITH A MUTABLE INTERFACE. IT IS ONLY 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 2009, 2010, 2012, 2015, 2020 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.
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.
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/. */
#include"gmp-impl.h"
#if GMP_NUMB_BITS < 29 #errorNot implemented: Both sublsh_n(,,,28) should be corrected; r2 and r5 need one more LIMB. #endif
#if GMP_NUMB_BITS < 28 #errorNot implemented: divexact_by188513325 and _by182712915 will not work. #endif
/* Interpolation for Toom-8.5 (or Toom-8), using the evaluation points: infinity(8.5 only), +-8, +-4, +-2, +-1, +-1/4, +-1/2, +-1/8, 0. More precisely, we want to compute f(2^(GMP_NUMB_BITS * n)) for a polynomial f of degree 15 (or 14), given the 16 (rsp. 15) values:
All couples of the form f(n),f(-n) must be already mixed with toom_couple_handling(f(n),...,f(-n),...)
The result is stored in {pp, spt + 7*n (or 8*n)}. At entry, r8 is stored at {pp, 2n}, r6 is stored at {pp + 3n, 3n + 1}. r4 is stored at {pp + 7n, 3n + 1}. r2 is stored at {pp +11n, 3n + 1}. r0 is stored at {pp +15n, spt}.
The other values are 3n+1 limbs each (with most significant limbs small).
Negative intermediate results are stored two-complemented. Inputs are destroyed.
*/
cy = DO_mpn_sublsh_n (r7 + n + BIT_CORRECTION, pp, 2 * n, 42 - CORRECTION_BITS, wsi); #if BIT_CORRECTION
MPN_DECR_U (r1 + n, 2 * n + 1, pp[0] >> 6);
cy = DO_mpn_sublsh_n (r1 + n, pp + 1, 2 * n - 1, GMP_NUMB_BITS - 6, wsi);
cy = mpn_sub_1(r1 + 3 * n - 1, r1 + 3 * n - 1, 2, cy);
ASSERT ( BIT_CORRECTION > 0 || cy != 0 ); #else
r7[n3] -= cy;
DO_mpn_subrsh(r1 + n, 2 * n + 1, pp, 2 * n, 6, wsi); #endif
#if HAVE_NATIVE_mpn_add_n_sub_n
mpn_add_n_sub_n (r1, r7, r7, r1, n3p1); #else
mpn_sub_n (wsi, r7, r1, n3p1); /* can be negative */
mpn_add_n (r1, r1, r7, n3p1); /* if BIT_CORRECTION != 0, can give a carry. */
MP_PTR_SWAP(r7, wsi); #endif
r4[n3] -= mpn_sub_n (r4+n, r4+n, pp, 2 * n);
#if AORSMUL_FASTER_2AORSLSH
mpn_submul_1 (r5, r6, n3p1, 1028); /* can be negative */ #else
DO_mpn_sublsh_n (r5, r6, n3p1, 2, wsi); /* can be negative */
DO_mpn_sublsh_n (r5, r6, n3p1,10, wsi); /* can be negative */ #endif
mpn_submul_1 (r7, r5, n3p1, 1300); /* can be negative */ #if AORSMUL_FASTER_3AORSLSH
mpn_submul_1 (r7, r6, n3p1, 1052688); /* can be negative */ #else
DO_mpn_sublsh_n (r7, r6, n3p1, 4, wsi); /* can be negative */
DO_mpn_sublsh_n (r7, r6, n3p1,12, wsi); /* can be negative */
DO_mpn_sublsh_n (r7, r6, n3p1,20, wsi); /* can be negative */ #endif
mpn_divexact_by255x188513325(r7, r7, n3p1);
mpn_submul_1 (r5, r7, n3p1, 12567555); /* can be negative */ /* A division by 2835x64 follows. Warning: the operand can be negative! */
mpn_divexact_by2835x64(r5, r5, n3p1); if ((r5[n3] & (GMP_NUMB_MAX << (GMP_NUMB_BITS-7))) != 0)
r5[n3] |= (GMP_NUMB_MAX << (GMP_NUMB_BITS-6));
#if AORSMUL_FASTER_AORS_AORSLSH
mpn_submul_1 (r6, r7, n3p1, 4095); /* can be negative */ #else
mpn_add_n (r6, r6, r7, n3p1); /* can give a carry */
DO_mpn_sublsh_n (r6, r7, n3p1, 12, wsi); /* can be negative */ #endif #if AORSMUL_FASTER_2AORSLSH
mpn_addmul_1 (r6, r5, n3p1, 240); /* can be negative */ #else
DO_mpn_addlsh_n (r6, r5, n3p1, 8, wsi); /* can give a carry */
DO_mpn_sublsh_n (r6, r5, n3p1, 4, wsi); /* can be negative */ #endif /* A division by 255x4 follows. Warning: the operand can be negative! */
mpn_divexact_by255x4(r6, r6, n3p1); if ((r6[n3] & (GMP_NUMB_MAX << (GMP_NUMB_BITS-3))) != 0)
r6[n3] |= (GMP_NUMB_MAX << (GMP_NUMB_BITS-2));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.