<commit_before>/*
    Copyright (C) 2020 <NAME>

    This file is part of FLINT.

    FLINT is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.  See <https://www.gnu.org/licenses/>.
*/

#include "fq.h"

void fq_set_fmpz_mod_poly(fq_t a, const fmpz_mod_poly_t b, const fq_ctx_t ctx)
{
    slong i, len = b->length;

    FLINT_ASSERT(fmpz_equal(&b->p, fq_ctx_prime(ctx)));

    if (len <= 2*(ctx->modulus->length - 1))
    {
        fmpz_poly_fit_length(a, len);

        for (i = 0; i < len; i++)
            fmpz_set(a->coeffs + i, b->coeffs + i);

        _fmpz_poly_set_length(a, len);

        fq_reduce(a, ctx);
    }
    else
    {
        fmpz_mod_poly_t q, r;
        fmpz_mod_poly_init(q, ctx->ctxp);
        fmpz_mod_poly_init(r, ctx->ctxp);
        fmpz_mod_poly_divrem(q, r, b, fq_ctx_modulus(ctx), ctx->ctxp);
        fmpz_mod_poly_get_fmpz_poly(a, r, ctx->ctxp);
        fmpz_mod_poly_clear(q, ctx->ctxp);
        fmpz_mod_poly_clear(r, ctx->ctxp);
    }
}
<commit_msg>ensure library compiles with asserts<commit_after>/*
    Copyright (C) 2020 <NAME>

    This file is part of FLINT.

    FLINT is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.  See <https://www.gnu.org/licenses/>.
*/

#include "fq.h"

void fq_set_fmpz_mod_poly(fq_t a, const fmpz_mod_poly_t b, const fq_ctx_t ctx)
{
    slong i, len = b->length;

    if (len <= 2*(ctx->modulus->length - 1))
    {
        fmpz_poly_fit_length(a, len);

        for (i = 0; i < len; i++)
            fmpz_set(a->coeffs + i, b->coeffs + i);

        _fmpz_poly_set_length(a, len);

        fq_reduce(a, ctx);
    }
    else
    {
        fmpz_mod_poly_t q, r;
        fmpz_mod_poly_init(q, ctx->ctxp);
        fmpz_mod_poly_init(r, ctx->ctxp);
        fmpz_mod_poly_divrem(q, r, b, fq_ctx_modulus(ctx), ctx->ctxp);
        fmpz_mod_poly_get_fmpz_poly(a, r, ctx->ctxp);
        fmpz_mod_poly_clear(q, ctx->ctxp);
        fmpz_mod_poly_clear(r, ctx->ctxp);
    }
}

{'fraction_non_alphanumeric': 0.12200342465753425, 'fraction_numerical': 0.007705479452054794, 'mean_word_length': 2.6803149606299215, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 30, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1034799', 'n_tokens_mistral': 952, 'n_tokens_neox': 919, 'n_words': 226}