Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fmpz_mod_poly for modulus 1 #2115

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/fmpz_mod_poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,7 @@ int fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t FLINT_
return poly->length == 1 && poly->coeffs[0] == WORD(1);
}

FMPZ_MOD_POLY_INLINE
int fmpz_mod_poly_is_gen(const fmpz_mod_poly_t op, const fmpz_mod_ctx_t FLINT_UNUSED(ctx))
{
return op->length == 2 && op->coeffs[1] == WORD(1) && op->coeffs[0] == WORD(0);
}
int fmpz_mod_poly_is_gen(const fmpz_mod_poly_t op, const fmpz_mod_ctx_t ctx);

int fmpz_mod_poly_is_unit(const fmpz_mod_poly_t op, const fmpz_mod_ctx_t ctx);

Expand Down
9 changes: 8 additions & 1 deletion src/fmpz_mod_poly/attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
#include "fmpz_mod.h"
#include "fmpz_mod_poly.h"

int fmpz_mod_poly_is_gen(const fmpz_mod_poly_t op, const fmpz_mod_ctx_t ctx)
{
return (*fmpz_mod_ctx_modulus(ctx) == UWORD(1)) ||
(op->length == 2 && op->coeffs[1] == WORD(1) && op->coeffs[0] == WORD(0));
}

/* bogus for non-prime modulus */
int fmpz_mod_poly_is_unit(const fmpz_mod_poly_t op, const fmpz_mod_ctx_t ctx)
{
return (op->length == 1) && fmpz_mod_is_invertible(op->coeffs + 0, ctx);
return (*fmpz_mod_ctx_modulus(ctx) == UWORD(1)) ||
(op->length == 1 && fmpz_mod_is_invertible(op->coeffs + 0, ctx));
}
Loading