/usr/include/flint/fq_zech.h is in libflint-dev 2.5.2-17build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | /*=============================================================================
This file is part of FLINT.
FLINT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FLINT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FLINT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2013 Mike Hansen
******************************************************************************/
#ifndef FQ_ZECH_H
#define FQ_ZECH_H
#ifdef FQ_ZECH_INLINES_C
#define FQ_ZECH_INLINE FLINT_DLL
/* #define FQ_TEMPLATES_INLINE FLINT_DLL */
#else
#define FQ_ZECH_INLINE static __inline__
/* #define FQ_TEMPLATES_INLINE static __inline__ */
#endif
#include "fq_nmod.h"
/* Data types and context ****************************************************/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
mp_limb_t value;
} fq_zech_struct;
typedef fq_zech_struct fq_zech_t[1];
typedef struct
{
mp_limb_t qm1; /* q - 1 */
mp_limb_t qm1o2; /* (q - 1) / 2 or 1 when p == 2 */
mp_limb_t qm1opm1; /* (q - 1) / (p - 1) */
mp_limb_t p;
double ppre;
mp_limb_t prime_root; /* primitive root for prime subfield */
mp_limb_t *zech_log_table;
mp_limb_t *prime_field_table;
mp_limb_t *eval_table;
fq_nmod_ctx_struct *fq_nmod_ctx;
int owns_fq_nmod_ctx;
} fq_zech_ctx_struct;
typedef fq_zech_ctx_struct fq_zech_ctx_t[1];
FLINT_DLL void fq_zech_ctx_init(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var);
FLINT_DLL void fq_zech_ctx_init_fq_nmod_ctx(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn);
FLINT_DLL int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var);
FLINT_DLL void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, const fmpz_t p, slong d, const char *var);
FLINT_DLL void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx,
const nmod_poly_t modulus,
const char *var);
FLINT_DLL void fq_zech_ctx_randtest(fq_zech_ctx_t ctx, flint_rand_t state);
FLINT_DLL void fq_zech_ctx_randtest_reducible(fq_zech_ctx_t ctx, flint_rand_t state);
FLINT_DLL void fq_zech_ctx_clear(fq_zech_ctx_t ctx);
FQ_ZECH_INLINE slong
fq_zech_ctx_degree(const fq_zech_ctx_t ctx)
{
return fq_nmod_ctx_degree(ctx->fq_nmod_ctx);
}
FQ_ZECH_INLINE void
fq_zech_ctx_order(fmpz_t f, const fq_zech_ctx_t ctx)
{
fq_nmod_ctx_order(f, ctx->fq_nmod_ctx);
}
FQ_ZECH_INLINE mp_limb_t
fq_zech_ctx_order_ui(const fq_zech_ctx_t ctx)
{
return ctx->qm1 + 1;
}
#define fq_zech_ctx_prime(ctx) fq_nmod_ctx_prime(ctx->fq_nmod_ctx)
FQ_ZECH_INLINE int
fq_zech_ctx_fprint(FILE * file, const fq_zech_ctx_t ctx)
{
int r;
r = flint_fprintf(file, "Zech Representation:\n");
if (r <= 0)
return r;
return fq_nmod_ctx_fprint(file, ctx->fq_nmod_ctx);
}
FQ_ZECH_INLINE void
fq_zech_ctx_print(const fq_zech_ctx_t ctx)
{
fq_zech_ctx_fprint(stdout, ctx);
}
/* Memory managment *********************************************************/
FQ_ZECH_INLINE void
fq_zech_init(fq_zech_t rop, const fq_zech_ctx_t ctx)
{
rop->value = ctx->qm1;
}
FQ_ZECH_INLINE void
fq_zech_init2(fq_zech_t rop, const fq_zech_ctx_t ctx)
{
rop->value = ctx->qm1;
}
FQ_ZECH_INLINE void
fq_zech_clear(fq_zech_t rop, const fq_zech_ctx_t ctx)
{
}
FQ_ZECH_INLINE void
fq_zech_reduce(fq_zech_t rop, const fq_zech_ctx_t ctx)
{
mp_limb_t order = fq_zech_ctx_order_ui(ctx);
if (rop->value >= order)
{
rop->value -= order;
}
}
/* Basic arithmetic **********************************************************/
FLINT_DLL void fq_zech_add(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_sub(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_sub_one(fq_zech_t rop, const fq_zech_t op1,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_neg(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_mul(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_mul_fmpz(fq_zech_t rop, const fq_zech_t op, const fmpz_t x,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_mul_si(fq_zech_t rop, const fq_zech_t op, slong x,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_mul_ui(fq_zech_t rop, const fq_zech_t op, ulong x,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_sqr(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_inv(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx);
FLINT_DLL void _fq_zech_pow(fmpz * rop, const fmpz * op, slong len, const fmpz_t e,
const fmpz * a, const slong *j, slong lena, const fmpz_t p);
FLINT_DLL void fq_zech_pow(fq_zech_t rop, const fq_zech_t op1, const fmpz_t e,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_pow_ui(fq_zech_t rop, const fq_zech_t op1, const ulong e,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_pth_root(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx);
/* Randomisation *************************************************************/
FLINT_DLL void fq_zech_randtest(fq_zech_t rop, flint_rand_t state,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_randtest_not_zero(fq_zech_t rop, flint_rand_t state,
const fq_zech_ctx_t ctx);
/* Comparison ****************************************************************/
FQ_ZECH_INLINE int
fq_zech_equal(const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t ctx)
{
return op1->value == op2->value;
}
FQ_ZECH_INLINE int
fq_zech_is_zero(const fq_zech_t op, const fq_zech_ctx_t ctx)
{
return op->value == ctx->qm1;
}
FQ_ZECH_INLINE int
fq_zech_is_one(const fq_zech_t op, const fq_zech_ctx_t ctx)
{
return op->value == 0;
}
/* Assignments and conversions ***********************************************/
FQ_ZECH_INLINE void
fq_zech_set(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx)
{
rop->value = op->value;
}
FLINT_DLL void fq_zech_set_fmpz(fq_zech_t rop, const fmpz_t x, const fq_zech_ctx_t ctx);
FQ_ZECH_INLINE void
fq_zech_set_si(fq_zech_t rop, const slong x, const fq_zech_ctx_t ctx)
{
fmpz_t xx;
fmpz_init_set_si(xx, x);
fq_zech_set_fmpz(rop, xx, ctx);
fmpz_clear(xx);
}
FQ_ZECH_INLINE void
fq_zech_set_ui(fq_zech_t rop, const ulong x, const fq_zech_ctx_t ctx)
{
fmpz_t xx;
fmpz_init_set_ui(xx, x);
fq_zech_set_fmpz(rop, xx, ctx);
fmpz_clear(xx);
}
FQ_ZECH_INLINE void
fq_zech_swap(fq_zech_t op1, fq_zech_t op2, const fq_zech_ctx_t ctx)
{
slong temp;
temp = op2->value;
op2->value = op1->value;
op1->value = temp;
}
FQ_ZECH_INLINE void
fq_zech_zero(fq_zech_t rop, const fq_zech_ctx_t ctx)
{
rop->value = ctx->qm1;
}
FQ_ZECH_INLINE void
fq_zech_one(fq_zech_t rop, const fq_zech_ctx_t ctx)
{
rop->value = 0;
}
FQ_ZECH_INLINE void
fq_zech_gen(fq_zech_t rop, const fq_zech_ctx_t ctx)
{
rop->value = 1;
}
FLINT_DLL void fq_zech_set_fq_nmod(fq_zech_t rop, const fq_nmod_t op, const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_get_fq_nmod(fq_nmod_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx);
/* Output ********************************************************************/
FQ_ZECH_INLINE int
fq_zech_fprint_pretty(FILE * file, const fq_zech_t op, const fq_zech_ctx_t ctx)
{
return flint_fprintf(file, "%s^%wd", ctx->fq_nmod_ctx->var, op->value);
}
FQ_ZECH_INLINE void
fq_zech_print_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx)
{
fq_zech_fprint_pretty(stdout, op, ctx);
}
FQ_ZECH_INLINE int
fq_zech_fprint(FILE * file, const fq_zech_t op, const fq_zech_ctx_t ctx)
{
return flint_fprintf(file, "%wd", op->value);
}
FQ_ZECH_INLINE void
fq_zech_print(const fq_zech_t op, const fq_zech_ctx_t ctx)
{
fq_zech_fprint(stdout, op, ctx);
}
FLINT_DLL char * fq_zech_get_str(const fq_zech_t op, const fq_zech_ctx_t ctx);
FLINT_DLL char * fq_zech_get_str_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx);
/* Special functions *********************************************************/
FLINT_DLL void fq_zech_trace(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_frobenius(fq_zech_t rop, const fq_zech_t op, slong e,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_norm(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx);
/* Bit packing ******************************************************/
FLINT_DLL void fq_zech_bit_pack(fmpz_t f, const fq_zech_t op, mp_bitcnt_t bit_size,
const fq_zech_ctx_t ctx);
FLINT_DLL void fq_zech_bit_unpack(fq_zech_t rop, const fmpz_t f, mp_bitcnt_t bit_size,
const fq_zech_ctx_t ctx);
#ifdef T
#undef T
#endif
#define T fq_zech
#define CAP_T FQ_ZECH
#include "fq_templates.h"
#undef CAP_T
#undef T
#ifdef __cplusplus
}
#endif
#endif
|