gr_generic_set_str_expr, gr_generic_set_str, gr_generic_set_str_balance_additions, gr_generic_set_str_ring_exponents
#include <flint/gr_generic.h>Parse the expression s and evaluate it in the ring. gr_generic_set_str is gr_generic_set_str_expr with no flags and the default of gr_set_str; the other two set one flag each.
The grammar has integer literals, decimal literals with an optional exponent (1.25e-3, evaluated with gr_set_fmpz_10exp_fmpz), the binary operators +, -, *, / and ^, unary minus, parentheses, and:
- the generators of the ring and of its base rings, by the names given by
gr_gens_recursiveandgr_ctx_gen_name; - the constants
pi,i,infandnan(alsoPi,I,Inf,NaN), when the ring has them; - the functions
abs,sgn,arg,inv,sqrt,rsqrt,floor,ceil,nint,re,im,conj,fac,log,exp,sin,cos,tan,asin,acos,atan,sinpi,cospi,tanpi,gammaandzetaof one argument; - the ball notation
m +/- r, evaluated withgr_set_interval_mid_rad, andm +/- infwithgr_set_interval_mid_inf, which does not requireinfto be an element; O(x^n), evaluated withgr_big_o_base_fmpzwithout forming x^n.
Exponents are nonnegative integer literals unless GR_PARSE_RING_EXPONENTS is set. The status of every operation is propagated, so "1/2" in \mathbb{Z} returns GR_DOMAIN; a syntax error returns GR_UNABLE.
The FLINT team, “gr_generic_set_str_expr, gr_generic_set_str, gr_generic_set_str_balance_additions, gr_generic_set_str_ring_exponents (gr_generic.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/gr_generic/gr_generic_set_str_expr.html (generated 2026-10-20).
@misc{flint-doc-gr-generic-gr-generic-set-str-expr,
author = {{The FLINT team}},
title = {{gr\_generic\_set\_str\_expr, gr\_generic\_set\_str, gr\_generic\_set\_str\_balance\_additions, gr\_generic\_set\_str\_ring\_exponents (gr\_generic.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/gr_generic/gr_generic_set_str_expr.html},
note = {Generated 2026-10-20}
}