Coverage Report

Created: 2025-03-18 06:55

/src/gmp/mpn/nussbaumer_mul.c
Line
Count
Source (jump to first uncovered line)
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-impl.h"
40
41
/* Multiply {ap,an} by {bp,bn}, and put the result in {pp, an+bn} */
42
void
43
mpn_nussbaumer_mul (mp_ptr pp,
44
        mp_srcptr ap, mp_size_t an,
45
        mp_srcptr bp, mp_size_t bn)
46
0
{
47
0
  mp_size_t rn;
48
0
  mp_ptr tp;
49
0
  TMP_DECL;
50
51
0
  ASSERT (an >= bn);
52
0
  ASSERT (bn > 0);
53
54
0
  TMP_MARK;
55
56
0
  if ((ap == bp) && (an == bn))
57
0
    {
58
0
      rn = mpn_sqrmod_bnm1_next_size (2*an);
59
0
      tp = TMP_ALLOC_LIMBS (mpn_sqrmod_bnm1_itch (rn, an));
60
0
      mpn_sqrmod_bnm1 (pp, rn, ap, an, tp);
61
0
    }
62
0
  else
63
0
    {
64
0
      rn = mpn_mulmod_bnm1_next_size (an + bn);
65
0
      tp = TMP_ALLOC_LIMBS (mpn_mulmod_bnm1_itch (rn, an, bn));
66
0
      mpn_mulmod_bnm1 (pp, rn, ap, an, bp, bn, tp);
67
0
    }
68
69
0
  TMP_FREE;
70
0
}