1 /* This file is part of the gf2x library.
2 
3    Copyright 2007, 2008, 2009, 2010, 2013, 2015
4    Richard Brent, Pierrick Gaudry, Emmanuel Thome', Paul Zimmermann
5 
6    This program is free software; you can redistribute it and/or modify it
7    under the terms of either:
8     - If the archive contains a file named toom-gpl.c (not a trivial
9     placeholder), the GNU General Public License as published by the Free
10     Software Foundation; either version 3 of the License, or (at your
11     option) any later version.
12     - If the archive contains a file named toom-gpl.c which is a trivial
13     placeholder, the GNU Lesser General Public License as published by
14     the Free Software Foundation; either version 2.1 of the License, or
15     (at your option) any later version.
16 
17    This program is distributed in the hope that it will be useful, but WITHOUT
18    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19    FITNESS FOR A PARTICULAR PURPOSE.  See the license text for more details.
20 
21    You should have received a copy of the GNU General Public License as
22    well as the GNU Lesser General Public License along with this program;
23    see the files COPYING and COPYING.LIB.  If not, write to the Free
24    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25    02110-1301, USA.
26 */
27 
28 
29 #ifndef GF2X_TERNARY_FFT_H_
30 #define GF2X_TERNARY_FFT_H_
31 
32 #define GF2X_TERNARY_FFT_MINIMUM_SIZE 28
33 
34 /* The section below is automatically generated */
35 /* inline: init_empty order */
36 
37 #ifndef GF2X_FFT_EXPORTED
38 #define GF2X_FFT_EXPORTED
39 #endif
40 
41 struct gf2x_ternary_fft_info;
42 // gf2x_ternary_fft_info_t is defined after the struct fields.
43 // typedef struct gf2x_ternary_fft_info gf2x_ternary_fft_info_t[1];
44 typedef struct gf2x_ternary_fft_info * gf2x_ternary_fft_info_ptr;
45 typedef const struct gf2x_ternary_fft_info * gf2x_ternary_fft_info_srcptr;
46 
47 /* gf2x_ternary_fft_info is an implementation-defined structure that holds important
48  * auxiliary data, used for dealing with transforms. This structure may
49  * or may not consist of plain-old datatypes only, so that it only
50  * possible to copy it with care (see below).
51  *
52  * C code should use gf2x_ternary_fft_info_t preferrably, as it provides transparent
53  * conversion to a pointer, and yet defines storage as well (à la GMP).
54  *
55  * C++ code should use gf2x_ternary_fft_info.  When the header is included from C++
56  * code, the api below is also exported as member functions of gf2x_ternary_fft_info.
57  * The info type is default-constructible in all cases, but not always
58  * trivially copyable.
59  *
60  * gf2x_ternary_fft_info_ptr and gf2x_ternary_fft_info_srcptr are auxiliary types used in C
61  * prototypes. C++ code should prefer references and const references to
62  * gf2x_ternary_fft_info.
63  */
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 extern int gf2x_ternary_fft_info_init(
70         gf2x_ternary_fft_info_ptr p,
71         size_t bits_a,
72         size_t bits_b) GF2X_FFT_EXPORTED;
73 /* Basic constructor. Used to multiply polynomials with the given number
74  * of bits.
75  *
76  * Extra tuning may be done with gf2x_ternary_fft_info_adjust
77  *
78  * Returns 0 if everything went well, and a negative number on error
79  */
80 
81 extern int gf2x_ternary_fft_info_init_mp(
82         gf2x_ternary_fft_info_ptr p,
83         size_t bits_a,
84         size_t bits_b) GF2X_FFT_EXPORTED;
85 /* Used to compute middle products of polynomials with the given number
86  * of bits. That is, the result MP(a, b) consists of coefficients of
87  * degrees MIN(bits_a, bits_b)-1 to MAX(bits_a, bits_b)-1 (inclusive),
88  * forming a result with MAX(bits_a, bits_b)-MIN(bits_a, bits_b)+1
89  * coefficients.
90  *
91  * Extra tuning may be done with gf2x_ternary_fft_info_adjust
92  *
93  * Returns 0 if everything went well, and a negative number on error
94  */
95 
96 static inline void gf2x_ternary_fft_info_init_empty(
97         gf2x_ternary_fft_info_ptr p);
98 /* This is not really a constructor. Most often we expect this function
99  * to be a noop, or at most an inline. It is just meant to provide some
100  * default-initialization, so that info_clear does not choke. Note that
101  *
102  * gf2x_ternary_fft_info_adjust on an empty-initialized info structure is likely to
103  * fail.
104  */
105 
106 /* Adjust the fft structure with one of the GF2X_FFT_ADJUST_* tweaks, and
107  * an extra parameter.
108  *
109  * This must be done right after the info_init (or info_init_mp) call, as
110  * this might invalidate all transforms.
111  *
112  * Returns 0 if everything went well, and a negative number on error
113  * (maybe if the extra argument was incorrect).
114  *
115  * Note that adjustments that happen to exist but are valid for other fft
116  * engines are simply ignored.
117  */
118 extern int gf2x_ternary_fft_info_adjust(
119         gf2x_ternary_fft_info_ptr p,
120         int adjust_kind,
121         long val) GF2X_FFT_EXPORTED;
122 
123 extern void gf2x_ternary_fft_info_clear(
124         gf2x_ternary_fft_info_ptr p) GF2X_FFT_EXPORTED;
125 /* Destructor for the info type. */
126 
127 extern int gf2x_ternary_fft_info_copy(
128         gf2x_ternary_fft_info_ptr p,
129         gf2x_ternary_fft_info_srcptr other) GF2X_FFT_EXPORTED;
130 /* Copy constructor. Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY.*/
131 
132 static inline int gf2x_ternary_fft_info_order(
133         gf2x_ternary_fft_info_srcptr p);
134 /* Return the "order", whatever that means for the underlying info type.  */
135 
136 extern void gf2x_ternary_fft_info_get_alloc_sizes(
137         gf2x_ternary_fft_info_srcptr p,
138         size_t sizes[3]) GF2X_FFT_EXPORTED;
139 /* Fill the sizes array with three byte counts:
140  *     sizes[0] : equivalent to gf2x_ternary_fft_transform_size(p) * sizeof(gf2x_ternary_fft_elt)
141  *     sizes[1] : number of bytes of temp space that must be passed to each
142  *                gf2x_ternary_fft_dft or gf2x_ternary_fft_ift call.
143  *     sizes[2] : number of bytes of temp space that must be passed to each
144  *                gf2x_ternary_fft_compose, gf2x_ternary_fft_addcompose, or gf2x_ternary_fft_addcompose_n call.
145  *                Note that the addcompose variants need two temp
146  *                buffers, of sizes sizes[2] and sizes[1], respectively.
147  */
148 
149 extern char * gf2x_ternary_fft_info_explain(
150         gf2x_ternary_fft_info_srcptr p) GF2X_FFT_EXPORTED;
151 /* Returns a malloc()ed string that gives the description of what the
152  * transform type is doing. The returned pointer may also be NULL if the
153  * implementation does not provide that information. It should be freed
154  * by the caller eventually.
155  */
156 
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 /* End of automatically generated section */
162 
163 typedef unsigned long gf2x_ternary_fft_elt;
164 /* The section below is automatically generated */
165 /* inline: export import prepare check */
166 
167 typedef gf2x_ternary_fft_elt * gf2x_ternary_fft_ptr;
168 typedef const gf2x_ternary_fft_elt * gf2x_ternary_fft_srcptr;
169 /* A transform has type gf2x_ternary_fft_ptr. It is made of a series of gf2x_ternary_fft_elt
170  * objects. */
171 
172 #ifdef __cplusplus
173 extern "C" {
174 #endif
175 
176 extern size_t gf2x_ternary_fft_transform_size(
177         gf2x_ternary_fft_info_srcptr o) GF2X_FFT_EXPORTED;
178 /* Number of gf2x_ternary_fft_elt objects it takes to allocate one transform. */
179 
180 extern gf2x_ternary_fft_ptr gf2x_ternary_fft_alloc(
181         gf2x_ternary_fft_info_srcptr o,
182         size_t n) GF2X_FFT_EXPORTED;
183 /* Allocate space for n transforms. Equivalent to (gf2x_ternary_fft_ptr) malloc(n *
184  * gf2x_ternary_fft_transform_size(p) * sizeof(gf2x_ternary_fft_elt)); */
185 
186 extern void gf2x_ternary_fft_free(
187         gf2x_ternary_fft_info_srcptr o,
188         gf2x_ternary_fft_ptr ptr,
189         size_t n) GF2X_FFT_EXPORTED;
190 /* Free space for n transforms. */
191 
192 extern gf2x_ternary_fft_ptr gf2x_ternary_fft_get(
193         gf2x_ternary_fft_info_srcptr o,
194         gf2x_ternary_fft_ptr ptr,
195         size_t k) GF2X_FFT_EXPORTED;
196 /* Get the k-th transform. */
197 
198 extern gf2x_ternary_fft_srcptr gf2x_ternary_fft_get_const(
199         gf2x_ternary_fft_info_srcptr o,
200         gf2x_ternary_fft_srcptr ptr,
201         size_t k) GF2X_FFT_EXPORTED;
202 /* Get the k-th transform. */
203 
204 extern void gf2x_ternary_fft_zero(
205         gf2x_ternary_fft_info_srcptr o,
206         gf2x_ternary_fft_ptr ptr,
207         size_t n) GF2X_FFT_EXPORTED;
208 /* Zero n consecutive transforms. */
209 
210 extern void gf2x_ternary_fft_cpy(
211         gf2x_ternary_fft_info_srcptr o,
212         gf2x_ternary_fft_ptr y,
213         gf2x_ternary_fft_srcptr x,
214         size_t n) GF2X_FFT_EXPORTED;
215 /* Copy n consecutive transforms (named "cpy" by analogy to memcpy)/ */
216 
217 static inline void gf2x_ternary_fft_export(
218         gf2x_ternary_fft_info_srcptr o,
219         gf2x_ternary_fft_ptr ptr,
220         size_t n);
221 /* Export (serialize) n consecutive transforms in place. This is a noop
222  * if the transforms are free of any pointers, which is always the case
223  * with gf2x. */
224 
225 static inline void gf2x_ternary_fft_import(
226         gf2x_ternary_fft_info_srcptr o,
227         gf2x_ternary_fft_ptr ptr,
228         size_t n);
229 /* Import (deserialize) n consecutive transforms in place. This is a noop
230  * if the transforms are free of any pointers, which is always the case
231  * with gf2x. */
232 
233 static inline void gf2x_ternary_fft_prepare(
234         gf2x_ternary_fft_info_srcptr o,
235         gf2x_ternary_fft_ptr ptr,
236         size_t n);
237 /* Prepare n consecutive transforms in place so that they're
238  * pointer-correct, but do not set any of the internal data. It is
239  * conceivably simpler than gf2x_ternary_fft_zero. This is a noop if the transforms
240  * are free of any pointers, which is always the case with gf2x. */
241 
242 static inline int gf2x_ternary_fft_check(
243         gf2x_ternary_fft_info_srcptr o,
244         gf2x_ternary_fft_srcptr ptr,
245         size_t n,
246         int printf_diagnostics);
247 /* Checks that the n consecutive transforms are valid (in particular,
248  * pointer-correct if relevant). This might be a noop if the transforms
249  * are free of any pointers, which is always the case with gf2x. */
250 
251 #if 0 && defined(__GNU_MP__) /* we don't want a gmp dependency... */
252 extern void gf2x_ternary_fft_fill_random(
253         gf2x_ternary_fft_info_srcptr o,
254         gf2x_ternary_fft_ptr ptr,
255         size_t n,
256         gmp_randstate_t rstate) GF2X_FFT_EXPORTED;
257 /* fill n consecutive transforms with random data from the provided
258  * random state.
259  */
260 #endif
261 
262 extern void gf2x_ternary_fft_add(
263         gf2x_ternary_fft_info_srcptr o,
264         gf2x_ternary_fft_ptr tc,
265         gf2x_ternary_fft_srcptr ta,
266         gf2x_ternary_fft_srcptr tb) GF2X_FFT_EXPORTED;
267 /* Add two transforms to tc. tc==ta or tc==tb are allowed. */
268 
269 extern int gf2x_ternary_fft_dft(
270         gf2x_ternary_fft_info_srcptr o,
271         gf2x_ternary_fft_ptr tr,
272         const unsigned long * a,
273         size_t bits_a,
274         gf2x_ternary_fft_ptr temp1) GF2X_FFT_EXPORTED;
275 /* Compute the dft of the polynomial pointed to by a. Attention: the size
276  * is given in number of *bits*, not in number of unsigned longs.  temp1
277  * must point to storage of size sizes[1], with sizes[] filled as in the
278  * gf2x_ternary_fft_info_get_alloc_sizes call.
279  *
280  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
281  * allocation is needed by some implementations).
282  */
283 
284 extern int gf2x_ternary_fft_ift(
285         gf2x_ternary_fft_info_srcptr o,
286         unsigned long * c,
287         size_t bits_c,
288         gf2x_ternary_fft_ptr tr,
289         gf2x_ternary_fft_ptr temp1) GF2X_FFT_EXPORTED;
290 /* Compute the ift of the transform tr, to polynomial pointed to by c.
291  * Attention: the size is given in number of *bits*, not in number of
292  * unsigned longs.  temp1 must point to storage of size sizes[1], with
293  * sizes[] filled as in the gf2x_ternary_fft_info_get_alloc_sizes call.
294  *
295  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
296  * allocation is needed by some implementations).
297  */
298 
299 extern int gf2x_ternary_fft_compose(
300         gf2x_ternary_fft_info_srcptr o,
301         gf2x_ternary_fft_ptr tc,
302         gf2x_ternary_fft_srcptr ta,
303         gf2x_ternary_fft_srcptr tb,
304         gf2x_ternary_fft_ptr temp2) GF2X_FFT_EXPORTED;
305 /* Compose two DFTs.  temp2 must point to storage of size sizes[2], with
306  * sizes[] filled as in the gf2x_ternary_fft_info_get_alloc_sizes call.
307  *
308  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
309  * allocation is needed by some implementations).
310  */
311 
312 extern int gf2x_ternary_fft_addcompose_n(
313         gf2x_ternary_fft_info_srcptr o,
314         gf2x_ternary_fft_ptr tc,
315         gf2x_ternary_fft_srcptr * ta,
316         gf2x_ternary_fft_srcptr * tb,
317         size_t n,
318         gf2x_ternary_fft_ptr temp2,
319         gf2x_ternary_fft_ptr temp1) GF2X_FFT_EXPORTED;
320 /* Compose 2n DFTs, and add the result to tc. temp1 and temp2 must point to
321  * storage of size sizes[1] and sizes[2], respectively, with sizes[]
322  * filled as in the gf2x_ternary_fft_info_get_alloc_sizes call.
323  *
324  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
325  * allocation is needed by some implementations).
326  */
327 
328 extern int gf2x_ternary_fft_addcompose(
329         gf2x_ternary_fft_info_srcptr o,
330         gf2x_ternary_fft_ptr tc,
331         gf2x_ternary_fft_srcptr ta,
332         gf2x_ternary_fft_srcptr tb,
333         gf2x_ternary_fft_ptr temp2,
334         gf2x_ternary_fft_ptr temp1) GF2X_FFT_EXPORTED;
335 /* Compose 2 DFTs, and add the result to tc. temp1 and temp2 must point to
336  * storage of size sizes[1] and sizes[2], respectively, with sizes[]
337  * filled as in the gf2x_ternary_fft_info_get_alloc_sizes call.
338  *
339  * Returns 0 on success or GF2X_ERROR_OUT_OF_MEMORY (only minor extra
340  * allocation is needed by some implementations).
341  */
342 
343 #ifdef __cplusplus
344 }
345 #endif
346 
347 #ifdef __cplusplus
348 #include <exception>
349 #include <array>
350 #include <string>
351 #endif
352 
353 /* End of automatically generated section */
354 
355 struct gf2x_ternary_fft_info {
356     size_t bits_a;  // number of bits of operand1
357     size_t bits_b;  // number of bits of operand2
358     size_t K;       // 0 indicates fallback.
359     size_t M;
360     size_t * perm;
361     size_t mp_shift;
362     int split;  // boolean
363     /* The section below is automatically generated */
364     /* pod: no */
365 #ifdef __cplusplus
366 
367     // a C++ compilation unit that (odr-) uses this interface must include a
368     // definition like
369     //
370     // constexpr const char * gf2x_ternary_fft_info::name;
371     //
372     // Note that libgf2x-fft has no C++ compilation unit, so we request
373     // the user to do this extra bit of work.
374     //
375     // Note also that as per C++11 9.4.2.3, this is only necessary if the
376     // member is odr-used.
377     static constexpr const char * name = "gf2x_ternary_fft";
378 
379     class ctor_fails: public std::exception
380     {
whatgf2x_ternary_fft_info381       virtual const char* what() const throw() {
382         return "contructor failed for gf2x_ternary_fft";
383       }
384     };
385 
386     typedef gf2x_ternary_fft_elt elt;
387     typedef gf2x_ternary_fft_ptr ptr;
388     typedef gf2x_ternary_fft_srcptr srcptr;
389 
gf2x_ternary_fft_infogf2x_ternary_fft_info390     inline gf2x_ternary_fft_info()
391     {
392         gf2x_ternary_fft_info_init_empty(this);
393     }
gf2x_ternary_fft_infogf2x_ternary_fft_info394     inline gf2x_ternary_fft_info(size_t nF, size_t nG)
395     {
396         if (gf2x_ternary_fft_info_init(this, nF, nG) < 0)
397             throw ctor_fails();
398     }
~gf2x_ternary_fft_infogf2x_ternary_fft_info399     inline ~gf2x_ternary_fft_info() {
400         gf2x_ternary_fft_info_clear(this);
401     }
gf2x_ternary_fft_infogf2x_ternary_fft_info402     inline gf2x_ternary_fft_info(gf2x_ternary_fft_info const & o) {
403         gf2x_ternary_fft_info_copy(this, &o);
404     }
405     inline gf2x_ternary_fft_info& operator=(gf2x_ternary_fft_info const & o) {
406         gf2x_ternary_fft_info_clear(this);
407         gf2x_ternary_fft_info_copy(this, &o);
408         return *this;
409     }
410     /* Use named constructor idiom for the variants */
mul_infogf2x_ternary_fft_info411     inline static gf2x_ternary_fft_info mul_info(size_t nF, size_t nG) {
412         gf2x_ternary_fft_info a;
413         if (gf2x_ternary_fft_info_init(&a, nF, nG) < 0)
414             throw ctor_fails();
415         return a;
416     }
mp_infogf2x_ternary_fft_info417     inline static gf2x_ternary_fft_info mp_info(size_t nF, size_t nG) {
418         gf2x_ternary_fft_info a;
419         if (gf2x_ternary_fft_info_init_mp(&a, nF, nG) < 0)
420             throw ctor_fails();
421         return a;
422     }
adjustgf2x_ternary_fft_info423     inline int adjust(int adjust_kind, long val) {
424         return gf2x_ternary_fft_info_adjust(this, adjust_kind, val);
425     }
ordergf2x_ternary_fft_info426     inline int order() const {
427         return gf2x_ternary_fft_info_order(this);
428     }
get_alloc_sizesgf2x_ternary_fft_info429     inline std::array<size_t, 3> get_alloc_sizes() const {
430         std::array<size_t, 3> sizes;
431         gf2x_ternary_fft_info_get_alloc_sizes(this, &sizes[0]);
432         return sizes;
433     }
434     /* This is equal to transform_size() * sizeof(elt) */
size0_bytesgf2x_ternary_fft_info435     inline size_t size0_bytes() const { return get_alloc_sizes()[0]; }
size1_bytesgf2x_ternary_fft_info436     inline size_t size1_bytes() const { return get_alloc_sizes()[1]; }
size2_bytesgf2x_ternary_fft_info437     inline size_t size2_bytes() const { return get_alloc_sizes()[2]; }
transform_sizegf2x_ternary_fft_info438     inline size_t transform_size() const { return gf2x_ternary_fft_transform_size(this); }
439     inline ptr alloc(size_t n = 1) const { return gf2x_ternary_fft_alloc(this, n); }
440     inline void free(ptr x, size_t n = 1) const { gf2x_ternary_fft_free(this, x, n); }
getgf2x_ternary_fft_info441     inline ptr get(ptr x, size_t k) const { return gf2x_ternary_fft_get(this, x, k); }
getgf2x_ternary_fft_info442     inline srcptr get(srcptr x, size_t k) const { return gf2x_ternary_fft_get_const(this, x, k); }
443     inline void zero(ptr x, size_t n = 1) const { gf2x_ternary_fft_zero(this, x, n); }
444     inline void to_export(ptr x, size_t n = 1) const { gf2x_ternary_fft_export(this, x, n); }
445     inline void to_import(ptr x, size_t n = 1) const { gf2x_ternary_fft_import(this, x, n); }
446     inline void prepare(ptr x, size_t n = 1) const { gf2x_ternary_fft_prepare(this, x, n); }
checkgf2x_ternary_fft_info447     inline bool check(srcptr x, size_t n, bool printf_diagnostics) const { return gf2x_ternary_fft_check(this, x, n, printf_diagnostics); }
checkgf2x_ternary_fft_info448     inline bool check(srcptr x, bool printf_diagnostics) const { return gf2x_ternary_fft_check(this, x, 1, printf_diagnostics); }
449 #if 0 && defined(__GNU_MP__) /* we don't want a gmp dependency... */
450     inline void fill_random(ptr x, size_t n, gmp_randstate_t rstate) const {
451         gf2x_ternary_fft_fill_random(x, n, rstate);
452     }
453     inline void fill_random(ptr x, gmp_randstate_t rstate) const {
454         gf2x_ternary_fft_fill_random(x, 1, rstate);
455     }
456 #endif
457 
dftgf2x_ternary_fft_info458     inline int dft(ptr x, const unsigned long * F, size_t nF, ptr temp1) const {
459         return gf2x_ternary_fft_dft(this, x, F, nF, temp1);
460     }
composegf2x_ternary_fft_info461     inline int compose(ptr y, srcptr x1, srcptr x2, ptr temp2) const
462     {
463         return gf2x_ternary_fft_compose(this, y, x1, x2, temp2);
464     }
addcomposegf2x_ternary_fft_info465     inline int addcompose(ptr y, srcptr x1, srcptr x2, ptr temp2, ptr temp1) const
466     {
467         return gf2x_ternary_fft_addcompose(this, y, x1, x2, temp2, temp1);
468     }
addcompose_ngf2x_ternary_fft_info469     inline int addcompose_n(ptr y, srcptr * x1, srcptr * x2, size_t n, ptr temp2, ptr temp1) const
470     {
471         return gf2x_ternary_fft_addcompose_n(this, y, x1, x2, n, temp2, temp1);
472     }
addgf2x_ternary_fft_info473     inline void add(ptr y, srcptr x1, srcptr x2) const
474     {
475         gf2x_ternary_fft_add(this, y, x1, x2);
476     }
477     inline void cpy(ptr y, srcptr x, size_t n = 1) const
478     {
479         gf2x_ternary_fft_cpy(this, y, x, n);
480     }
iftgf2x_ternary_fft_info481     inline int ift(unsigned long * H, size_t Hl, ptr h, ptr temp1) const
482     {
483         return gf2x_ternary_fft_ift(this, H, Hl, h, temp1);
484     }
explaingf2x_ternary_fft_info485     std::string explain() const { char * x = gf2x_ternary_fft_info_explain(this); std::string s = x; ::free(x); return s; }
486 #endif
487 
488     /* End of automatically generated section */
489 };
490 /* The section below is automatically generated */
491 /* Now that gf2x_ternary_fft_info is declared completely, we may declare the 1-sized
492  * array */
493 typedef struct gf2x_ternary_fft_info gf2x_ternary_fft_info_t[1];
494 /* End of automatically generated section */
495 
496 #ifdef __cplusplus
497 extern "C" {
498 #endif
499 
gf2x_ternary_fft_info_order(gf2x_ternary_fft_info_srcptr o)500 static inline int gf2x_ternary_fft_info_order(gf2x_ternary_fft_info_srcptr o) { return ((o)->K * ((o)->split ? -1 : 1)); }
gf2x_ternary_fft_info_init_empty(gf2x_ternary_fft_info_t t)501 static inline void gf2x_ternary_fft_info_init_empty(gf2x_ternary_fft_info_t t)
502 {
503     t->bits_a = 0;
504     t->bits_b = 0;
505     t->K = 0;
506     t->M = 0;
507     t->perm = NULL;
508     t->mp_shift = 0;
509     t->split = 0;
510 }
511 
gf2x_ternary_fft_export(gf2x_ternary_fft_info_srcptr o GF2X_MAYBE_UNUSED,gf2x_ternary_fft_ptr ptr GF2X_MAYBE_UNUSED,size_t n GF2X_MAYBE_UNUSED)512 static inline void gf2x_ternary_fft_export(
513         gf2x_ternary_fft_info_srcptr o GF2X_MAYBE_UNUSED,
514         gf2x_ternary_fft_ptr ptr GF2X_MAYBE_UNUSED,
515         size_t n GF2X_MAYBE_UNUSED) {}
gf2x_ternary_fft_import(gf2x_ternary_fft_info_srcptr o GF2X_MAYBE_UNUSED,gf2x_ternary_fft_ptr ptr GF2X_MAYBE_UNUSED,size_t n GF2X_MAYBE_UNUSED)516 static inline void gf2x_ternary_fft_import(
517         gf2x_ternary_fft_info_srcptr o GF2X_MAYBE_UNUSED,
518         gf2x_ternary_fft_ptr ptr GF2X_MAYBE_UNUSED,
519         size_t n GF2X_MAYBE_UNUSED) {}
gf2x_ternary_fft_prepare(gf2x_ternary_fft_info_srcptr o GF2X_MAYBE_UNUSED,gf2x_ternary_fft_ptr ptr GF2X_MAYBE_UNUSED,size_t n GF2X_MAYBE_UNUSED)520 static inline void gf2x_ternary_fft_prepare(
521         gf2x_ternary_fft_info_srcptr o GF2X_MAYBE_UNUSED,
522         gf2x_ternary_fft_ptr ptr GF2X_MAYBE_UNUSED,
523         size_t n GF2X_MAYBE_UNUSED) {}
gf2x_ternary_fft_check(gf2x_ternary_fft_info_srcptr o GF2X_MAYBE_UNUSED,gf2x_ternary_fft_srcptr ptr GF2X_MAYBE_UNUSED,size_t n GF2X_MAYBE_UNUSED,int printf_diagnostics GF2X_MAYBE_UNUSED)524 static inline int gf2x_ternary_fft_check(
525         gf2x_ternary_fft_info_srcptr o GF2X_MAYBE_UNUSED,
526         gf2x_ternary_fft_srcptr ptr GF2X_MAYBE_UNUSED,
527         size_t n GF2X_MAYBE_UNUSED,
528         int printf_diagnostics GF2X_MAYBE_UNUSED) { return 1; }
529 #ifdef __cplusplus
530 }
531 #endif
532 
533 #endif	/* GF2X_TERNARY_FFT_H_ */
534