1 /*
2     Copyright (C) 2017 Luca De Feo
3 
4     This file is part of FLINT.
5 
6     FLINT is free software: you can redistribute it and/or modify it under
7     the terms of the GNU Lesser General Public License (LGPL) as published
8     by the Free Software Foundation; either version 2.1 of the License, or
9     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
10 */
11 
12 #ifndef FQ_ZECH_EMBED_H
13 #define FQ_ZECH_EMBED_H
14 
15 #ifdef FQ_ZECH_EMBED_INLINES_C
16 #define FQ_ZECH_EMBED_INLINE FLINT_DLL
17 #define FQ_EMBED_TEMPLATES_INLINE FLINT_DLL
18 #else
19 #define FQ_ZECH_EMBED_INLINE static __inline__
20 #define FQ_EMBED_TEMPLATES_INLINE static __inline__
21 #endif
22 
23 #include "fq_zech.h"
24 #include "fq_nmod_embed.h"
25 
26 #define T fq_zech
27 #define B nmod
28 #include "fq_embed_templates.h"
29 
30 FQ_EMBED_TEMPLATES_INLINE
TEMPLATE(T,modulus_pow_series_inv)31 void TEMPLATE(T, modulus_pow_series_inv)(TEMPLATE(B, poly_t) res,
32                                          const TEMPLATE(T, ctx_t) ctx,
33                                          slong trunc)
34 {
35     TEMPLATE(B, poly_reverse)(res,
36                               TEMPLATE(T, ctx_modulus)(ctx),
37                               TEMPLATE(T, ctx_degree)(ctx) + 1);
38     TEMPLATE(B, poly_inv_series)(res, res, trunc);
39 }
40 
41 #undef B
42 #undef T
43 
fq_zech_modulus_derivative_inv(fq_zech_t m_prime,fq_zech_t m_prime_inv,const fq_zech_ctx_t ctx)44 FQ_ZECH_EMBED_INLINE void fq_zech_modulus_derivative_inv(fq_zech_t m_prime,
45                                                          fq_zech_t m_prime_inv,
46                                                          const fq_zech_ctx_t ctx)
47 {
48     fq_nmod_t m_nmod, m_inv_nmod;
49     fq_nmod_init(m_nmod, ctx->fq_nmod_ctx);
50     fq_nmod_init(m_inv_nmod, ctx->fq_nmod_ctx);
51 
52     fq_nmod_modulus_derivative_inv(m_nmod, m_inv_nmod, ctx->fq_nmod_ctx);
53 
54     fq_zech_set_fq_nmod(m_prime, m_nmod, ctx);
55     fq_zech_set_fq_nmod(m_prime_inv, m_inv_nmod, ctx);
56 
57     fq_nmod_clear(m_nmod, ctx->fq_nmod_ctx);
58     fq_nmod_clear(m_inv_nmod, ctx->fq_nmod_ctx);
59 }
60 
61 #endif
62