int padic_log_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx) { if (padic_val(op) < 0) { return 0; } else { fmpz_t x; int ans; fmpz_init(x); padic_get_fmpz(x, op, ctx); fmpz_sub_ui(x, x, 1); if (fmpz_is_zero(x)) { padic_zero(rop); ans = 1; } else { fmpz_t t; long v; fmpz_init(t); v = fmpz_remove(t, x, ctx->p); fmpz_clear(t); if (v >= 2 || (*(ctx->p) != 2L && v >= 1)) { if (v >= ctx->N) { padic_zero(rop); } else { _padic_log_balanced(padic_unit(rop), x, v, ctx->p, ctx->N); padic_val(rop) = 0; padic_reduce(rop, ctx); } ans = 1; } else { ans = 0; } } fmpz_clear(x); return ans; } }
void qadic_trace(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) { const slong N = padic_prec(rop); if (qadic_is_zero(op) || op->val >= N) { padic_zero(rop); } else { fmpz_t pN; int alloc; alloc = _padic_ctx_pow_ui(pN, N - op->val, &ctx->pctx); _qadic_trace(padic_unit(rop), op->coeffs, op->length, ctx->a, ctx->j, ctx->len, pN); padic_val(rop) = op->val; _padic_canonicalise(rop, &ctx->pctx); if (alloc) fmpz_clear(pN); } }
void padic_teichmuller(padic_t rop, const padic_t op, const padic_ctx_t ctx) { if (padic_val(op) < 0) { flint_printf("Exception (padic_teichmuller). op is not a p-adic integer.\n"); abort(); } if (padic_is_zero(op) || padic_val(op) > 0 || padic_prec(rop) <= 0) { padic_zero(rop); } else { _padic_teichmuller(padic_unit(rop), padic_unit(op), ctx->p, padic_prec(rop)); padic_val(rop) = 0; } }
void qadic_norm_resultant(padic_t rop, const qadic_t op, const qadic_ctx_t ctx) { const slong N = padic_prec(rop); const slong d = qadic_ctx_degree(ctx); /* N(p^v u) = p^{dv} N(u) */ if (qadic_is_zero(op) || d * op->val >= N) { padic_zero(rop); } else { _qadic_norm_resultant(padic_unit(rop), op->coeffs, op->length, ctx->a, ctx->j, ctx->len, (&ctx->pctx)->p, N - d * op->val); padic_val(rop) = d * op->val; } }
int main(void) { long l, len = 20; long runs[] = { 100000000, 1000000, 1000000, 1000000, 100000, 100000, 10000, 10000, 10000, 1000, 100, 100, 10, 1, 1, 1, 1, 1, 1, 1 }; long N[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, WORD(1) << 11, WORD(1) << 12, WORD(1) << 13, WORD(1) << 14, WORD(1) << 15, WORD(1) << 16, WORD(1) << 17, WORD(1) << 18, WORD(1) << 19 }; long T[20] = {0}; flint_printf("Benchmark for p-adic exponential (rectangular).\n"); fflush(stdout); for (l = 0; l < FLINT_MIN(17, len); l++) { FLINT_TEST_INIT(state); long n = N[l], r; clock_t c0, c1; long double cputime; fmpz_t p; padic_ctx_t ctx; padic_t d, z; fmpz_init_set_ui(p, 17); padic_ctx_init(ctx, p, n, n, PADIC_VAL_UNIT); padic_init(d); padic_init(z); if (n > 1) { fmpz_t f = {WORD(3)}, pow; fmpz_init(pow); fmpz_pow_ui(pow, p, n - 1); fmpz_pow_ui(padic_unit(d), f, 3 * n); fmpz_mod(padic_unit(d), padic_unit(d), pow); padic_val(d) = 1; fmpz_clear(pow); } c0 = clock(); for (r = runs[l]; (r); r--) { padic_exp_rectangular(z, d, ctx); padic_zero(z); } c1 = clock(); cputime = (long double) (c1 - c0) / (long double) CLOCKS_PER_SEC; T[l] = (slong) (cputime * (1000000000 / runs[l])); flint_printf("%2ld, %4XYXYXYXY, %9ld, %wd\n", l, cputime, runs[l], T[l]); padic_clear(d); padic_clear(z); fmpz_clear(p); padic_ctx_clear(ctx); flint_randclear(state); } flint_printf("Output as a list:\n"); for (l = 0; l < len; l++) flint_printf("%wd, ", T[l]); flint_printf("\n"); }
int main(void) { long l, len = 20; long runs[] = { 1000000, 1000000, 1000000, 1000000, 100000, 100000, 100000, 100000, 10000, 10000, 10000, 1000, 1000, 100, 100, 10, 10, 1, 1, 1 }; long N[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, WORD(1) << 11, WORD(1) << 12, WORD(1) << 13, WORD(1) << 14, WORD(1) << 15, WORD(1) << 16, WORD(1) << 17, WORD(1) << 18, WORD(1) << 19 }; long T[20] = {0}; flint_printf("Benchmark for p-adic Teichmuller.\n"); fflush(stdout); for (l = 0; l < len; l++) { FLINT_TEST_INIT(state); long n = N[l], r; clock_t c0, c1; long double cputime; fmpz_t p; padic_ctx_t ctx; padic_t c, z; fmpz_init_set_ui(p, 17); padic_ctx_init(ctx, p, n, n, PADIC_VAL_UNIT); padic_init(c); padic_init(z); fmpz_set_ui(padic_unit(c), 3); c0 = clock(); for (r = runs[l]; (r); r--) { padic_teichmuller(z, c, ctx); padic_zero(z); } c1 = clock(); cputime = (long double) (c1 - c0) / (long double) CLOCKS_PER_SEC; T[l] = (slong) (cputime * (1000000000 / runs[l])); flint_printf("%2ld, %4XYXYXYXY, %7ld, %wd\n", l, cputime, runs[l], T[l]); padic_clear(c); padic_clear(z); fmpz_clear(p); padic_ctx_clear(ctx); flint_randclear(state); } flint_printf("Output as a list:\n"); for (l = 0; l < len; l++) flint_printf("%wd, ", T[l]); flint_printf("\n"); }