/usr/include/flint/padic_poly.h is in libflint-dev 2.4.4-2.
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 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | /*============================================================================
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) 2011, 2012 Sebastian Pancratz
******************************************************************************/
#ifndef PADIC_POLY_H
#define PADIC_POLY_H
#include <limits.h>
#include <gmp.h>
#include "fmpz.h"
#include "fmpq.h"
#include "padic.h"
#include "fmpz_vec.h"
#include "fmpz_poly.h"
#include "fmpq_poly.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Type definitions ********************************************************/
typedef struct
{
fmpz *coeffs;
slong alloc;
slong length;
slong val;
slong N;
} padic_poly_struct;
typedef padic_poly_struct padic_poly_t[1];
/* Helper functions ********************************************************/
/*
Returns the minimum $p$-adic valuation of \code{(vec, len)},
assuming this fits into a \code{signed long}.
If \code{len} is zero, returns $0$.
*/
static __inline__ slong _fmpz_vec_ord_p(const fmpz *vec, slong len, const fmpz_t p)
{
if (len == 0)
{
return 0;
}
else
{
fmpz_t t;
slong i, min = WORD_MAX, v;
fmpz_init(t);
for (i = 0; (min > 0) && (i < len); i++)
{
if (!fmpz_is_zero(vec + i))
{
v = fmpz_remove(t, vec + i, p);
min = FLINT_MIN(min, v);
}
}
fmpz_clear(t);
return (min < WORD_MAX) ? min : 0;
}
}
/* Memory management *******************************************************/
void padic_poly_init(padic_poly_t poly);
void padic_poly_init2(padic_poly_t poly, slong alloc, slong prec);
void padic_poly_clear(padic_poly_t poly);
void padic_poly_realloc(padic_poly_t f, slong alloc, const fmpz_t p);
void padic_poly_fit_length(padic_poly_t f, slong len);
static __inline__
void _padic_poly_set_length(padic_poly_t poly, slong len)
{
if (poly->length > len)
{
slong i;
for (i = len; i < poly->length; i++)
_fmpz_demote(poly->coeffs + i);
}
poly->length = len;
}
void _padic_poly_normalise(padic_poly_t f);
void _padic_poly_canonicalise(fmpz *poly, slong *v, slong len, const fmpz_t p);
void padic_poly_canonicalise(padic_poly_t poly, const fmpz_t p);
void padic_poly_reduce(padic_poly_t f, const padic_ctx_t ctx);
static __inline__
void padic_poly_truncate(padic_poly_t poly, slong n, const fmpz_t p)
{
if (poly->length > n)
{
slong i;
for (i = n; i < poly->length; i++)
_fmpz_demote(poly->coeffs + i);
poly->length = n;
_padic_poly_normalise(poly);
padic_poly_canonicalise(poly, p);
}
}
/* Polynomial parameters ***************************************************/
static __inline__ slong padic_poly_degree(const padic_poly_t poly)
{
return poly->length - 1;
}
static __inline__ slong padic_poly_length(const padic_poly_t poly)
{
return poly->length;
}
static __inline__ slong padic_poly_val(const padic_poly_t poly)
{
return poly->val;
}
#define padic_poly_val(poly) ((poly)->val)
#define padic_poly_prec(poly) ((poly)->N)
/* Randomisation ***********************************************************/
void padic_poly_randtest(padic_poly_t f, flint_rand_t state,
slong len, const padic_ctx_t ctx);
void padic_poly_randtest_not_zero(padic_poly_t f, flint_rand_t state,
slong len, const padic_ctx_t ctx);
void padic_poly_randtest_val(padic_poly_t f, flint_rand_t state,
slong val, slong len, const padic_ctx_t ctx);
/* Assignment and basic manipulation ***************************************/
void padic_poly_set(padic_poly_t f, const padic_poly_t g,
const padic_ctx_t ctx);
void padic_poly_set_padic(padic_poly_t poly, const padic_t x,
const padic_ctx_t ctx);
void padic_poly_set_si(padic_poly_t poly, slong x, const padic_ctx_t ctx);
void padic_poly_set_ui(padic_poly_t poly, ulong x, const padic_ctx_t ctx);
void padic_poly_set_fmpz(padic_poly_t poly, const fmpz_t x,
const padic_ctx_t ctx);
void padic_poly_set_fmpq(padic_poly_t poly, const fmpq_t x,
const padic_ctx_t ctx);
void padic_poly_set_fmpz_poly(padic_poly_t rop, const fmpz_poly_t op,
const padic_ctx_t ctx);
void padic_poly_set_fmpq_poly(padic_poly_t rop,
const fmpq_poly_t op, const padic_ctx_t ctx);
int padic_poly_get_fmpz_poly(fmpz_poly_t rop, const padic_poly_t op,
const padic_ctx_t ctx);
void padic_poly_get_fmpq_poly(fmpq_poly_t rop,
const padic_poly_t op, const padic_ctx_t ctx);
static __inline__ void padic_poly_zero(padic_poly_t poly)
{
_padic_poly_set_length(poly, 0);
poly->val = 0;
}
static __inline__ void padic_poly_one(padic_poly_t poly)
{
if (padic_poly_prec(poly) > 0)
{
padic_poly_fit_length(poly, 1);
fmpz_one(poly->coeffs);
_padic_poly_set_length(poly, 1);
poly->val = 0;
}
else
{
padic_poly_zero(poly);
}
}
void padic_poly_swap(padic_poly_t poly1, padic_poly_t poly2);
/* Getting and setting coefficients ****************************************/
void padic_poly_get_coeff_padic(padic_t c, const padic_poly_t poly, slong n,
const padic_ctx_t ctx);
void padic_poly_set_coeff_padic(padic_poly_t f, slong n, const padic_t c,
const padic_ctx_t ctx);
/* Comparison **************************************************************/
int padic_poly_equal(const padic_poly_t f, const padic_poly_t g);
static __inline__ int padic_poly_is_zero(const padic_poly_t poly)
{
return poly->length == 0;
}
static __inline__ int padic_poly_is_one(const padic_poly_t poly)
{
return (poly->length == 1) && fmpz_is_one(poly->coeffs) &&
(poly->val == 0);
}
/* Addition and subtraction ************************************************/
void _padic_poly_add(fmpz *rop, slong *rval, slong N,
const fmpz *op1, slong val1, slong len1, slong N1,
const fmpz *op2, slong val2, slong len2, slong N2,
const padic_ctx_t ctx);
void padic_poly_add(padic_poly_t f,
const padic_poly_t g, const padic_poly_t h,
const padic_ctx_t ctx);
void _padic_poly_sub(fmpz *rop, slong *rval, slong N,
const fmpz *op1, slong val1, slong len1, slong N1,
const fmpz *op2, slong val2, slong len2, slong N2,
const padic_ctx_t ctx);
void padic_poly_sub(padic_poly_t f,
const padic_poly_t g, const padic_poly_t h,
const padic_ctx_t ctx);
void padic_poly_neg(padic_poly_t f, const padic_poly_t g,
const padic_ctx_t ctx);
/* Scalar multiplication and division **************************************/
void _padic_poly_scalar_mul_padic(fmpz *rop, slong *rval, slong N,
const fmpz *op, slong val, slong len,
const padic_t c, const padic_ctx_t ctx);
void padic_poly_scalar_mul_padic(padic_poly_t rop, const padic_poly_t op,
const padic_t c, const padic_ctx_t ctx);
/* Multiplication **********************************************************/
void _padic_poly_mul(fmpz *rop, slong *rval, slong N,
const fmpz *op1, slong val1, slong len1,
const fmpz *op2, slong val2, slong len2,
const padic_ctx_t ctx);
void padic_poly_mul(padic_poly_t f,
const padic_poly_t g, const padic_poly_t h,
const padic_ctx_t ctx);
/* Powering ****************************************************************/
void _padic_poly_pow(fmpz *rop, slong *rval, slong N,
const fmpz *op, slong val, slong len, ulong e,
const padic_ctx_t ctx);
void padic_poly_pow(padic_poly_t rop, const padic_poly_t op, ulong e,
const padic_ctx_t ctx);
/* Series inversion ********************************************************/
void padic_poly_inv_series(padic_poly_t Qinv, const padic_poly_t Q, slong n,
const padic_ctx_t ctx);
/* Derivative **************************************************************/
void _padic_poly_derivative(fmpz *rop, slong *rval, slong N,
const fmpz *op, slong val, slong len,
const padic_ctx_t ctx);
void padic_poly_derivative(padic_poly_t rop,
const padic_poly_t op, const padic_ctx_t ctx);
/* Shifting ****************************************************************/
void padic_poly_shift_left(padic_poly_t rop, const padic_poly_t op, slong n,
const padic_ctx_t ctx);
void padic_poly_shift_right(padic_poly_t rop, const padic_poly_t op, slong n,
const padic_ctx_t ctx);
/* Evaluation **************************************************************/
void _padic_poly_evaluate_padic(fmpz_t u, slong *v, slong N,
const fmpz *poly, slong val, slong len,
const fmpz_t a, slong b, const padic_ctx_t ctx);
void padic_poly_evaluate_padic(padic_t y, const padic_poly_t poly,
const padic_t x, const padic_ctx_t ctx);
/* Composition *************************************************************/
void _padic_poly_compose(fmpz *rop, slong *rval, slong N,
const fmpz *op1, slong val1, slong len1,
const fmpz *op2, slong val2, slong len2,
const padic_ctx_t ctx);
void padic_poly_compose(padic_poly_t rop,
const padic_poly_t op1, const padic_poly_t op2,
const padic_ctx_t ctx);
void _padic_poly_compose_pow(fmpz *rop, slong *rval, slong N,
const fmpz *op, slong val, slong len, slong k,
const padic_ctx_t ctx);
void padic_poly_compose_pow(padic_poly_t rop, const padic_poly_t op, slong k,
const padic_ctx_t ctx);
/* Input and output ********************************************************/
static __inline__ int padic_poly_debug(const padic_poly_t poly)
{
flint_printf("(alloc = %wd, length = %wd, val = %wd, N = %wd, vec = ",
poly->alloc, poly->length, poly->val, poly->N);
if (poly->coeffs)
{
flint_printf("{");
_fmpz_vec_print(poly->coeffs, poly->alloc);
flint_printf("}");
}
else
{
flint_printf("NULL");
}
flint_printf(")");
return 1;
}
int _padic_poly_fprint(FILE *file, const fmpz *poly, slong val, slong len,
const padic_ctx_t ctx);
int padic_poly_fprint(FILE *file, const padic_poly_t poly,
const padic_ctx_t ctx);
static __inline__
int _padic_poly_print(const fmpz *poly, slong val, slong len,
const padic_ctx_t ctx)
{
return _padic_poly_fprint(stdout, poly, val, len, ctx);
}
static __inline__
int padic_poly_print(const padic_poly_t poly, const padic_ctx_t ctx)
{
return padic_poly_fprint(stdout, poly, ctx);
}
int _padic_poly_fprint_pretty(FILE *file,
const fmpz *poly, slong val, slong len,
const char *var,
const padic_ctx_t ctx);
int padic_poly_fprint_pretty(FILE *file,
const padic_poly_t poly, const char *var,
const padic_ctx_t ctx);
static __inline__
int _padic_poly_print_pretty(FILE *file,
const fmpz *poly, slong val, slong len,
const char *var,
const padic_ctx_t ctx)
{
return _padic_poly_fprint_pretty(stdout, poly, val, len, var, ctx);
}
static __inline__
int padic_poly_print_pretty(const padic_poly_t poly, const char *var,
const padic_ctx_t ctx)
{
return padic_poly_fprint_pretty(stdout, poly, var, ctx);
}
/* Testing *****************************************************************/
int _padic_poly_is_canonical(const fmpz *op, slong val, slong len,
const padic_ctx_t ctx);
int padic_poly_is_canonical(const padic_poly_t op, const padic_ctx_t ctx);
int _padic_poly_is_reduced(const fmpz *op, slong val, slong len, slong N,
const padic_ctx_t ctx);
int padic_poly_is_reduced(const padic_poly_t op, const padic_ctx_t ctx);
#ifdef __cplusplus
}
#endif
#endif
|