FLINT3.7.0-dev
Module · 38 functions

ca_field.h

#include <flint/ca_field.h>

A ca_field_t is the parent field K = \mathbb{Q}(a_1, \ldots, a_n) of ca_t numbers (see ca.h): a list of pointers to extension numbers a_1, \ldots, a_n (see ca_ext.h) together with an ideal I \subset \mathbb{Z}[X_1, \ldots, X_n] of polynomial relations satisfied by them. An element of K is represented by a rational function in the generators, and arithmetic is done in the formal field \operatorname{Frac}(\mathbb{Q}[X_1, \ldots, X_n] / I), reducing numerators and denominators modulo I.

Three kinds of field are distinguished, which mainly affects how elements are stored:

  • the field \mathbb{Q}, with no generators, whose elements are fmpq values;
  • a number field \mathbb{Q}(a) with a single algebraic generator a given by a qqbar_t, whose elements are nf_elem.h values modulo the minimal polynomial of a (the ideal is not stored);
  • a generic field \mathbb{Q}(a_1, \ldots, a_n), whose elements are fmpz_mpoly_q.h rational functions in n variables.

Users do not normally create fields: the context object keeps a cache of fields, and the functions of ca.h find or create the field they need, for example ca_merge_fields when combining elements of different fields. The generators of a field are sorted by the structural order of ca_ext_cmp_repr (reversed), so that a lexicographic monomial order eliminates the most complicated generators first. When a field is created, its ideal of relations is built by the heuristics described in Formal fields and the ideal of relations: minimal polynomials of algebraic generators, defining equations of roots and powers, Vieta's formulas for conjugates, integer relations between logarithms and between exponentials and powers found by LLL and proved exactly, and functional equations of the error and gamma functions, followed by a Gröbner basis computation.

AlgorithmFormal fields and the ideal of relationsHow ca represents numbers as rational functions in extension numbers, modulo an ideal of algebraic relations that is built when a field is created, from minimal polynomials, defining equations of roots and powers, Vieta's formulas, integer relations between logarithms and exponentials found by LLL and proved exactly, functional equations and a Gröbner basis.

Types and macros#

A field. The structure holds the number of generators length, the array ext of pointers to the extension numbers, the ideal ideal (an fmpz_mpoly_vec_struct) and a hash value. A ca_field_t is an array of one structure.

Aliases for ca_field_struct * and const ca_field_struct *.

Access the number n of generators of K (0 for \mathbb{Q}), the array of pointers to the extension numbers, the pointer to the generator with index i (starting from 0), and the hash value.

Test whether K is \mathbb{Q}, a number field \mathbb{Q}(a) with one algebraic generator, or a generic field. A number field is marked by an ideal length of -1.

For a number field K = \mathbb{Q}(a): the nf_struct pointer used for arithmetic in K, and the qqbar_t value of a.

For a generic field: the ideal of relations as an fmpz_mpoly_vec_struct pointer, its element with index i as an fmpz_mpoly_struct pointer, the number of polynomials, the allocated number, and the array of polynomials.

For a generic field with n generators: the fmpz_mpoly_ctx_struct pointer for polynomials in n variables, owned by the context ctx and shared by all fields with n generators. The monomial order is the context option CA_OPT_MPOLY_ORD.

The multiplier used to combine the hashes of the generators into the hash of a field.

Memory management#

Initialises K as the field \mathbb{Q}.

Initialises K as the number field \mathbb{Q}(x), inserting the extension number x into the cache of ctx.

void ca_field_init_fxy(ca_field_t K, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx)

Initialises K as the generic field \mathbb{Q}(a) with the single generator a given by the constant func (for example CA_Pi), the function value f(x) or the function value f(x, y), inserting the extension number into the cache of ctx. The ideal is empty; it is not built by these functions.

Initialises K as a generic field with len generators, which must then be assigned one by one with ca_field_set_ext. The ideal is empty.

Sets the generator with index i of K to the extension number x and updates the hash. Only a pointer is stored, so x must outlive K; extension numbers from the cache of the context do.

Clears K and its ideal. The extension numbers are not cleared, since the field only holds references to them.

Input and output#

Prints a description of K to standard output, of the form QQ(x1, x2) where {x1 = ..., x2 = ...} with ideal {...}, with the generators printed by ca_ext_print and the ideal (if not empty) in the variables x1, x2, ....

Ideal of relations#

Builds the ideal of relations of the generic field K, whose generators have been assigned, in place. Nothing is done for \mathbb{Q} and for number fields. The relations found are always valid, but they need not generate the full ideal of relations between the generators. If CA_OPT_USE_GROEBNER is set and the relations have total degree at most CA_OPT_QQBAR_DEG_LIMIT, the ideal is replaced by its reduced Gröbner basis when Buchberger's algorithm finishes within the limits set by the context options. See Formal fields and the ideal of relations for the relations that are searched for.

Adds relations between error functions among the generators of K that follow from \operatorname{erf}(-x) = -\operatorname{erf}(x), \operatorname{erfc}(x) = 1 - \operatorname{erf}(x) and \operatorname{erfi}(x) = -i \operatorname{erf}(ix), when the arguments are proved to be equal or opposite (or related by a factor i). Called by ca_field_build_ideal.

Adds the relations \Gamma(x + n) = x (x+1) \cdots (x + n - 1) \Gamma(x) between generators \Gamma(x + n) and \Gamma(x) of K whose arguments differ by an integer n with |n| \le 10 (and \Gamma(x) = \Gamma(y) when x = y), provided the factors x + k can be expressed in K. Called by ca_field_build_ideal.

Comparison#

int ca_field_cmp(const ca_field_t K1, const ca_field_t K2, ca_ctx_t ctx)

Compares the fields K1 and K2 in a total structural order (number of generators, then the generators with ca_ext_cmp_repr), returning -1, 0 or 1. The order says nothing about the fields as mathematical objects.

Cache#

A set of fields: an array of pointers to heap-allocated fields and a hash table indexed by the generators. Each context object contains one such cache.

Initialises cache as empty, or clears it, freeing all fields in it.

Returns a pointer to the field in cache whose generators are the length extension numbers x (compared as pointers, in the given order), creating it if needed. A newly created field is \mathbb{Q} if length is 0, a number field if it has one algebraic generator, and otherwise a generic field whose ideal is built immediately with ca_field_build_ideal. The extension numbers must belong to the cache of ctx.

Cite this page

The FLINT team, “ca_field.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/ca_field/index.html (generated 2026-10-20).