renf_elem.h — Embedded number field elements

Memory Layout

Struct renf_elem

struct renf_elem{
  nf_elem_t elem;
  arb_t emb;
};

A real embedded number field element

Member Variable elem

An algebraic ANTIC number field element.

Member Variable emb

An approximation of the embedded element as a real ball.

Type Alias renf_elem_t

An element of a real embedded number field.

Actually, this is an array of renf_elem of length one.

Typically, users of e-antic should not worry about the exact definition of this and just treat this as the type that represents a number field element in e-antic.

See the documentation of renf_t for why this is an array.

void renf_elem_init(renf_elem_t a, const renf_t nf)

Initialize the number field element a.

This function has to be called prior to any code using a as it performs allocation. Once done with a the memory must be freed with renf_elem_clear.

void renf_elem_clear(renf_elem_t a, const renf_t nf)

Deallocate the memory for a that was allocated with renf_elem_init.

void renf_elem_swap(renf_elem_t a, renf_elem_t b)

Swap the number field elements a and b

Setters

void renf_elem_zero(renf_elem_t a, const renf_t nf)

Set the number field element a to zero.

void renf_elem_one(renf_elem_t a, const renf_t nf)

Set the number field element a to one.

void renf_elem_gen(renf_elem_t a, const renf_t nf)

Set the number field element a to the generator of the number field.

Integer/Rational Setters

(1) void renf_elem_set_si(renf_elem_t a, slong n, const renf_t nf)

(2) void renf_elem_set_ui(renf_elem_t a, mp_limb_t n, const renf_t nf)

(3) void renf_elem_set_nf_elem(renf_elem_t a, const nf_elem_t b, renf_t nf, slong prec)

(4) void renf_elem_set(renf_elem_t a, const renf_elem_t b, const renf_t nf)

(5) void renf_elem_set_fmpz(renf_elem_t a, const fmpz_t c, const renf_t nf)

(6) void renf_elem_set_mpz(renf_elem_t a, const mpz_t c, const renf_t nf)

(7) void renf_elem_set_fmpq(renf_elem_t a, const fmpq_t c, const renf_t nf)

(8) void renf_elem_set_mpq(renf_elem_t a, const mpq_t c, const renf_t nf)

(9) void renf_elem_set_fmpq_poly(renf_elem_t a, const fmpq_poly_t pol, const renf_t nf)

Set a to provided integer/rational as an element in the number field nf.

Embedding refinement

void renf_elem_set_evaluation(renf_elem_t a, const renf_t nf, slong prec)

Set the enclosure of the number field element a using the enclosure of the generator of nf.

Computation is done at precision prec. This function does not make any refinement of the number field generator. For that purpose see renf_refine_embedding.

Properties and conversion

int renf_elem_is_zero(const renf_elem_t a, const renf_t nf)

Return 1 if a is equal to zero and 0 otherwise.

int renf_elem_is_one(const renf_elem_t a, const renf_t nf)

Return 1 if a is equal to one and 0 otherwise.

int renf_elem_is_integer(const renf_elem_t a, const renf_t nf)

Return 1 if a is integral and 0 otherwise.

int renf_elem_is_rational(const renf_elem_t a, const renf_t nf)

Return 1 if a is rational and 0 otherwise.

int renf_elem_sgn(renf_elem_t a, renf_t nf)

Return the sign of a. It is 1 if a is positive, 0 if a is zero and -1 if a is negative.

void renf_elem_floor(fmpz_t a, renf_elem_t b, renf_t nf)

Set a to be the floor of b

void renf_elem_ceil(fmpz_t a, renf_elem_t b, renf_t nf)

Set a to be the ceil of b

Floating point approximations

void renf_elem_get_arb(arb_t x, renf_elem_t a, renf_t nf, slong prec)

Set x to a a real ball enclosing the element a that belongs to the number field nf with prec bits of precision.

double renf_elem_get_d(renf_elem_t a, renf_t nf, int rnd)

Return a double approximation.

Comparisons

(1) int renf_elem_cmp(renf_elem_t a, renf_elem_t b, renf_t nf)

(2) int _renf_elem_cmp_fmpq(renf_elem_t a, fmpz* num, fmpz* den, renf_t nf)

(3) int renf_elem_cmp_fmpq(renf_elem_t a, const fmpq_t b, renf_t nf)

(4) int renf_elem_cmp_fmpz(renf_elem_t a, const fmpz_t b, renf_t nf)

(5) int renf_elem_cmp_si(renf_elem_t a, const slong b, renf_t nf)

(6) int renf_elem_cmp_ui(renf_elem_t a, const mp_limb_t b, renf_t nf)

(7) int renf_elem_equal(const renf_elem_t a, const renf_elem_t b, const renf_t nf)

(8) int renf_elem_equal_si(const renf_elem_t a, const slong b, const renf_t nf)

(9) int renf_elem_equal_ui(const renf_elem_t a, const mp_limb_t b, const renf_t nf)

(10) int renf_elem_equal_fmpz(const renf_elem_t a, const fmpz_t b, const renf_t nf)

(11) int renf_elem_equal_fmpq(const renf_elem_t a, const fmpq_t b, const renf_t nf)

All the comparison functions renf_elem_cmp_… between two elements a and b behave as follows. They return

  • a positive integer if a is greater than b,

  • 0 if a and b are equal, and

  • a negative integer if a is smaller than b.

If you want to check for equality, use the faster renf_elem_equal_… functions.

String Conversion and Printing

char* renf_elem_get_str_pretty(renf_elem_t a, char* var, renf_t nf, slong n, int flag)

Return a as a string with variable name var.

The resulting string needs to be freed with flint_free.

void renf_elem_print_pretty(renf_elem_t a, char* var, renf_t nf, slong n, int flag)

Write a to the standard output.

Randomization

void renf_elem_randtest(renf_elem_t a, flint_rand_t state, ulong bits, renf_t nf)

Set a to a random element in nf.

Unary operations

void renf_elem_neg(renf_elem_t a, const renf_elem_t b, const renf_t nf)

Set a to the negative of b.

void renf_elem_inv(renf_elem_t a, const renf_elem_t b, const renf_t nf)

Set a to the inverse of b.

Binary operations

void renf_elem_add_si(renf_elem_t a, const renf_elem_t b, slong c, const renf_t nf)

All the binary operation functions are of the form renf_elem_OP_TYP(a, b, c, nf) where

  • OP is the operation type

  • TYP is the type of the argument c

  • a is the argument used for returned value

  • b and c are the operands

  • nf is the parent number field of the operation In short, these functions perform a = b OP c.

void renf_elem_fdiv(fmpz_t a, renf_elem_t b, renf_elem_t c, renf_t nf)

Perform the floor division of the number field elements b and c and set the result in a.

The result is equivalent to a call of [renf_elem_div] followed by [renf_elem_floor]. This function is much faster, though.

Other functions

slong renf_elem_get_cfrac(fmpz* c, renf_elem_t rem, renf_elem_t a, slong n, renf_t nf)

Set the array c to the n-th first partial quotients of the continued fraction of the element a of nf.

void renf_elem_check_embedding(const renf_elem_t a, const renf_t nf, slong prec)

Check that the embedding is consistent.

int renf_elem_relative_condition_number_2exp(slong* cond, renf_elem_t a, renf_t nf)

Logarithm of the condition number of a.

The return value corresponds to the number of bits of precision that will be lost when evaluating a as a polynomial in the number field generator.