FLINT3.7.0-dev

gr_transformed_mpn_set, gr_transformed_mpn_get, gr_transformed_mpn_get_destructive, gr_transformed_mpn_get_limbs, gr_transformed_mpn_get_limbs_bound

Synopsis#include <flint/gr.h>
int gr_transformed_mpn_set(gr_ptr res, nn_srcptr a, slong an, int sign, gr_ctx_t ctx)source
int gr_transformed_mpn_get(nn_ptr z, slong zn, slong * zn_out, int * sign, gr_srcptr x, gr_ctx_t ctx)source
int gr_transformed_mpn_get_destructive(nn_ptr z, slong zn, slong * zn_out, int * sign, gr_ptr x, gr_ctx_t ctx)source
slong gr_transformed_mpn_get_limbs(gr_ctx_t ctx, gr_srcptr x)source
slong gr_transformed_mpn_get_limbs_bound(gr_ctx_t ctx)source

Conversions by limb arrays with an explicit sign. gr_transformed_mpn_set converts the integer \pm(a_0, \ldots, a_{an-1}) in, failing with GR_DOMAIN if it does not fit the context. The get functions write the absolute value to z, its length to *zn_out and the sign to *sign; the destructive form may consume the element, skipping a copy of the transform. gr_transformed_mpn_get_limbs returns the number of limbs the reconstruction of x needs, which exceeds the length of the value by the length of the top CRT coefficient, and gr_transformed_mpn_get_limbs_bound an upper bound over every element of the context.

A window of at least gr_transformed_mpn_get_limbs limbs receives the reconstruction directly, without staging or copying. A shorter window is also accepted: the ring stages the conversion in its own scratch and copies the result out, succeeding whenever the value fits in zn limbs and returning GR_DOMAIN otherwise. For the destructive form that refusal comes with the element already consumed, so it cannot be retried. Limbs of z above *zn_out are zeroed. Callers converting into an fmpz or into a window of get_limbs limbs need not consult get_limbs_bound; a caller that wants a buffer of its own should size it from that bound rather than from its own model of the representation.

Cite this page

The FLINT team, “gr_transformed_mpn_set, gr_transformed_mpn_get, gr_transformed_mpn_get_destructive, gr_transformed_mpn_get_limbs, gr_transformed_mpn_get_limbs_bound (gr.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/gr/gr_transformed_mpn_set.html (generated 2026-10-20).