/src/gmp/mpn/toom_eval_dgr3_pm1.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* mpn_toom_eval_dgr3_pm1 -- Evaluate a degree 3 polynomial in +1 and -1 |
2 | | |
3 | | Contributed to the GNU project by Niels Möller |
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 WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. |
8 | | |
9 | | Copyright 2009 Free Software Foundation, Inc. |
10 | | |
11 | | This file is part of the GNU MP Library. |
12 | | |
13 | | The GNU MP Library is free software; you can redistribute it and/or modify |
14 | | it under the terms of either: |
15 | | |
16 | | * the GNU Lesser General Public License as published by the Free |
17 | | Software Foundation; either version 3 of the License, or (at your |
18 | | option) any later version. |
19 | | |
20 | | or |
21 | | |
22 | | * the GNU General Public License as published by the Free Software |
23 | | Foundation; either version 2 of the License, or (at your option) any |
24 | | later version. |
25 | | |
26 | | or both in parallel, as here. |
27 | | |
28 | | The GNU MP Library is distributed in the hope that it will be useful, but |
29 | | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
30 | | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
31 | | for more details. |
32 | | |
33 | | You should have received copies of the GNU General Public License and the |
34 | | GNU Lesser General Public License along with the GNU MP Library. If not, |
35 | | see https://www.gnu.org/licenses/. */ |
36 | | |
37 | | |
38 | | #include "gmp-impl.h" |
39 | | |
40 | | int |
41 | | mpn_toom_eval_dgr3_pm1 (mp_ptr xp1, mp_ptr xm1, |
42 | | mp_srcptr xp, mp_size_t n, mp_size_t x3n, mp_ptr tp) |
43 | 0 | { |
44 | 0 | int neg; |
45 | |
|
46 | 0 | ASSERT (x3n > 0); |
47 | 0 | ASSERT (x3n <= n); |
48 | |
|
49 | 0 | xp1[n] = mpn_add_n (xp1, xp, xp + 2*n, n); |
50 | 0 | tp[n] = mpn_add (tp, xp + n, n, xp + 3*n, x3n); |
51 | |
|
52 | 0 | neg = (mpn_cmp (xp1, tp, n + 1) < 0) ? ~0 : 0; |
53 | |
|
54 | | #if HAVE_NATIVE_mpn_add_n_sub_n |
55 | | if (neg) |
56 | | mpn_add_n_sub_n (xp1, xm1, tp, xp1, n + 1); |
57 | | else |
58 | | mpn_add_n_sub_n (xp1, xm1, xp1, tp, n + 1); |
59 | | #else |
60 | 0 | if (neg) |
61 | 0 | mpn_sub_n (xm1, tp, xp1, n + 1); |
62 | 0 | else |
63 | 0 | mpn_sub_n (xm1, xp1, tp, n + 1); |
64 | |
|
65 | 0 | mpn_add_n (xp1, xp1, tp, n + 1); |
66 | 0 | #endif |
67 | |
|
68 | 0 | ASSERT (xp1[n] <= 3); |
69 | 0 | ASSERT (xm1[n] <= 1); |
70 | |
|
71 | 0 | return neg; |
72 | 0 | } |