github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/generic/nussbaumer_mul.c (about) 1 /* mpn_nussbaumer_mul -- Multiply {ap,an} and {bp,bn} using 2 Nussbaumer's negacyclic convolution. 3 4 Contributed to the GNU project by Marco Bodrato. 5 6 THE FUNCTION IN THIS FILE IS INTERNAL WITH A MUTABLE INTERFACE. IT IS ONLY 7 SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST 8 GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. 9 10 Copyright 2009 Free Software Foundation, Inc. 11 12 This file is part of the GNU MP Library. 13 14 The GNU MP Library is free software; you can redistribute it and/or modify 15 it under the terms of either: 16 17 * the GNU Lesser General Public License as published by the Free 18 Software Foundation; either version 3 of the License, or (at your 19 option) any later version. 20 21 or 22 23 * the GNU General Public License as published by the Free Software 24 Foundation; either version 2 of the License, or (at your option) any 25 later version. 26 27 or both in parallel, as here. 28 29 The GNU MP Library is distributed in the hope that it will be useful, but 30 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 31 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32 for more details. 33 34 You should have received copies of the GNU General Public License and the 35 GNU Lesser General Public License along with the GNU MP Library. If not, 36 see https://www.gnu.org/licenses/. */ 37 38 39 #include "gmp.h" 40 #include "gmp-impl.h" 41 42 /* Multiply {ap,an} by {bp,bn}, and put the result in {pp, an+bn} */ 43 void 44 mpn_nussbaumer_mul (mp_ptr pp, 45 mp_srcptr ap, mp_size_t an, 46 mp_srcptr bp, mp_size_t bn) 47 { 48 mp_size_t rn; 49 mp_ptr tp; 50 TMP_DECL; 51 52 ASSERT (an >= bn); 53 ASSERT (bn > 0); 54 55 TMP_MARK; 56 57 if ((ap == bp) && (an == bn)) 58 { 59 rn = mpn_sqrmod_bnm1_next_size (2*an); 60 tp = TMP_ALLOC_LIMBS (mpn_sqrmod_bnm1_itch (rn, an)); 61 mpn_sqrmod_bnm1 (pp, rn, ap, an, tp); 62 } 63 else 64 { 65 rn = mpn_mulmod_bnm1_next_size (an + bn); 66 tp = TMP_ALLOC_LIMBS (mpn_mulmod_bnm1_itch (rn, an, bn)); 67 mpn_mulmod_bnm1 (pp, rn, ap, an, bp, bn, tp); 68 } 69 70 TMP_FREE; 71 }