FLINT3.7.0-dev

mpn_mod_ctx_is_pretend_field, mpn_mod_ctx_set_is_pretend_field, mpn_mod_ctx_recover_zero_divisor

Synopsis#include <flint/mpn_mod.h>
truth_t mpn_mod_ctx_is_pretend_field(gr_ctx_t ctx)source
int mpn_mod_ctx_set_is_pretend_field(gr_ctx_t ctx, truth_t is_pretend_field)source
int mpn_mod_ctx_recover_zero_divisor(nn_ptr res, gr_ctx_t ctx)source

The methods behind gr_ctx_is_pretend_field, gr_ctx_set_is_pretend_field and gr_ctx_recover_zero_divisor. While the ring pretends to be a field, an inversion of a nonzero non-unit x fails with GR_UNABLE instead of GR_DOMAIN and records \gcd(x, n), a nontrivial factor of n, in the context (only the first one found is kept). mpn_mod_ctx_recover_zero_divisor sets res to the recorded factor and returns GR_SUCCESS, or sets res to zero and returns GR_UNABLE if none was recorded.

mpn_mod_ctx_is_pretend_field returns T_TRUE if the ring pretends to be a field or is flagged as prime, and T_FALSE otherwise. Turning the pretense off forgets the recorded factor. The flag and the factor are protected by a global lock, so several threads may compute with the same context. The guide Using mpn_mod has an example.

Cite this page

The FLINT team, “mpn_mod_ctx_is_pretend_field, mpn_mod_ctx_set_is_pretend_field, mpn_mod_ctx_recover_zero_divisor (mpn_mod.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_mod/mpn_mod_ctx_is_pretend_field.html (generated 2026-10-20).