nf.h
#include <flint/nf.h>This module defines the type nf_t of a number field , given by a defining polynomial of degree , and computes the data that the element arithmetic of nf_elem.h needs: the representation used for elements (special ones for degree 1 and 2), a precomputed inverse of the leading coefficient, the powers used for reduction, and the power sums of the roots of used for traces. The module goes back to the ANTIC library [Har2015]. The generic ring interface for number fields is gr_ctx_init_nf in gr.h; algebraic number fields as subfields of are handled by qqbar.h and ca.h.
Types#
A number field. The fields are pol (the defining polynomial, an fmpq_poly_t), pinv (a precomputed inverse of the leading coefficient of the numerator of pol, used for division in the non-monic generic case), powers (precomputed reductions of modulo pol for NF_POWERS_CUTOFF), traces (the power sums of the roots of pol for , as an fmpq_poly_t) and flag.
Bits of the field flag. NF_MONIC is set if pol has integer coefficients and leading coefficient 1, NF_LINEAR for , NF_QUADRATIC for , and NF_GAUSSIAN in addition for exactly; NF_GENERIC is the value 0. Elements of linear and quadratic fields use the representations lnf_elem_t and qnf_elem_t of nf_elem.h.
The bound 30 on the length of the defining polynomial up to which the powers of modulo are precomputed for reduction.
Functions#
void nf_init(nf_t nf, const fmpq_poly_t pol)Initialises nf for the defining polynomial pol, which must have degree at least 1 (otherwise the function throws). The polynomial is not checked to be irreducible: with a reducible polynomial the arithmetic is that of the ring , and the result of inverting a zero divisor is meaningless (_nf_elem_invertible_check tests for this).
void nf_init_randtest(nf_t nf, flint_rand_t state, slong len, flint_bitcnt_t bits_in)Initialises nf with a random defining polynomial of length at most len (that is, degree at most ) with coefficients of at most bits_in bits, for testing. Linear and quadratic fields, monic polynomials and are chosen with increased probability. The polynomial need not be irreducible. Throws if or bits_in .
References#
- [Har2015] W. B. Hart. "ANTIC: Algebraic number theory in C". Computeralgebra-Rundbrief: Vol. 56, 2015
The FLINT team, “nf.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/nf/index.html (generated 2026-11-02).
@misc{flint-doc-nf-index,
author = {{The FLINT team}},
title = {{nf.h (module overview)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/nf/index.html},
note = {Generated 2026-11-02}
}