ยปCore Development>Code coverage>Modules/_decimal/libmpdec/fnt.c

Python code coverage for Modules/_decimal/libmpdec/fnt.c

#countcontent
1n/a/*
2n/a * Copyright (c) 2008-2016 Stefan Krah. All rights reserved.
3n/a *
4n/a * Redistribution and use in source and binary forms, with or without
5n/a * modification, are permitted provided that the following conditions
6n/a * are met:
7n/a *
8n/a * 1. Redistributions of source code must retain the above copyright
9n/a * notice, this list of conditions and the following disclaimer.
10n/a *
11n/a * 2. Redistributions in binary form must reproduce the above copyright
12n/a * notice, this list of conditions and the following disclaimer in the
13n/a * documentation and/or other materials provided with the distribution.
14n/a *
15n/a * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
16n/a * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17n/a * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18n/a * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19n/a * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20n/a * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21n/a * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22n/a * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23n/a * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24n/a * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25n/a * SUCH DAMAGE.
26n/a */
27n/a
28n/a
29n/a#include "mpdecimal.h"
30n/a#include <stdio.h>
31n/a#include <stdlib.h>
32n/a#include <assert.h>
33n/a#include "bits.h"
34n/a#include "difradix2.h"
35n/a#include "numbertheory.h"
36n/a#include "fnt.h"
37n/a
38n/a
39n/a/* Bignum: Fast transform for medium-sized coefficients. */
40n/a
41n/a
42n/a/* forward transform, sign = -1 */
43n/aint
44n/astd_fnt(mpd_uint_t *a, mpd_size_t n, int modnum)
45n/a{
46n/a struct fnt_params *tparams;
47n/a
48n/a assert(ispower2(n));
49n/a assert(n >= 4);
50n/a assert(n <= 3*MPD_MAXTRANSFORM_2N);
51n/a
52n/a if ((tparams = _mpd_init_fnt_params(n, -1, modnum)) == NULL) {
53n/a return 0;
54n/a }
55n/a fnt_dif2(a, n, tparams);
56n/a
57n/a mpd_free(tparams);
58n/a return 1;
59n/a}
60n/a
61n/a/* reverse transform, sign = 1 */
62n/aint
63n/astd_inv_fnt(mpd_uint_t *a, mpd_size_t n, int modnum)
64n/a{
65n/a struct fnt_params *tparams;
66n/a
67n/a assert(ispower2(n));
68n/a assert(n >= 4);
69n/a assert(n <= 3*MPD_MAXTRANSFORM_2N);
70n/a
71n/a if ((tparams = _mpd_init_fnt_params(n, 1, modnum)) == NULL) {
72n/a return 0;
73n/a }
74n/a fnt_dif2(a, n, tparams);
75n/a
76n/a mpd_free(tparams);
77n/a return 1;
78n/a}
79n/a
80n/a
81n/a