renf_elem.h — Embedded Number Field Elements#

Memory Layout#

typedef renf_elem renf_elem_t[1]#

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.

struct renf_elem#

A real embedded number field element.

Public Members

nf_elem_t elem#

An algebraic ANTIC number field element.

arb_t emb#

An approximation of the embedded element as a real ball.

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]().

static inline 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.

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

Set a to the integer n an element in the number field nf.

void renf_elem_set_ui(renf_elem_t a, ulong n, const renf_t nf)#

Set a to the integer n as an element in the number field nf.

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

Set a to the number field element b which is defined in the number field nf.

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

Set a to the integer c as an element in the number field nf.

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

Set a to the integer c as an element in the number field nf.

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

Set a to the rational c as an element in the number field nf.

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

Set a to the rational c as an element in the number field nf.

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.

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

Set a to the number field element b defined in exact number field underlying nf. Then refine a to precision prec.

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, arf_rnd_t rnd)#

Return a double approximation.

Comparisons#

group renf_elem_cmp

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.

Functions

int renf_elem_cmp(renf_elem_t a, renf_elem_t b, renf_t nf)#
int _renf_elem_cmp_fmpq(renf_elem_t a, fmpz *num, fmpz *den, renf_t nf)#
int renf_elem_cmp_fmpq(renf_elem_t a, const fmpq_t b, renf_t nf)#
int renf_elem_cmp_fmpz(renf_elem_t a, const fmpz_t b, renf_t nf)#
int renf_elem_cmp_si(renf_elem_t a, const slong b, renf_t nf)#
int renf_elem_cmp_ui(renf_elem_t a, const ulong b, renf_t nf)#
int renf_elem_equal(const renf_elem_t a, const renf_elem_t b, const renf_t nf)#
int renf_elem_equal_si(const renf_elem_t a, const slong b, const renf_t nf)#
int renf_elem_equal_ui(const renf_elem_t a, const ulong b, const renf_t nf)#
int renf_elem_equal_fmpz(const renf_elem_t a, const fmpz_t b, const renf_t nf)#
int renf_elem_equal_fmpq(const renf_elem_t a, const fmpq_t b, const renf_t nf)#

String Conversion and Printing#

char *renf_elem_get_str_pretty(renf_elem_t a, const 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, const 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, mp_bitcnt_t 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#

group renf_elem_binop

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.

Functions

void renf_elem_add_si(renf_elem_t a, const renf_elem_t b, slong c, const renf_t nf)#
void renf_elem_sub_si(renf_elem_t a, const renf_elem_t b, slong c, const renf_t nf)#
void renf_elem_mul_si(renf_elem_t a, const renf_elem_t b, slong c, const renf_t nf)#
void renf_elem_div_si(renf_elem_t a, const renf_elem_t b, slong c, const renf_t nf)#
void renf_elem_add_ui(renf_elem_t a, const renf_elem_t b, ulong c, const renf_t nf)#
void renf_elem_sub_ui(renf_elem_t a, const renf_elem_t b, ulong c, const renf_t nf)#
void renf_elem_mul_ui(renf_elem_t a, const renf_elem_t b, ulong c, const renf_t nf)#
void renf_elem_div_ui(renf_elem_t a, const renf_elem_t b, ulong c, const renf_t nf)#
void renf_elem_add_fmpz(renf_elem_t a, const renf_elem_t b, const fmpz_t c, const renf_t nf)#
void renf_elem_sub_fmpz(renf_elem_t a, const renf_elem_t b, const fmpz_t c, const renf_t nf)#
void renf_elem_mul_fmpz(renf_elem_t a, const renf_elem_t b, const fmpz_t c, const renf_t nf)#
void renf_elem_div_fmpz(renf_elem_t a, const renf_elem_t b, const fmpz_t c, const renf_t nf)#
void renf_elem_add_fmpq(renf_elem_t a, const renf_elem_t b, const fmpq_t c, const renf_t nf)#
void renf_elem_sub_fmpq(renf_elem_t a, const renf_elem_t b, const fmpq_t c, const renf_t nf)#
void renf_elem_fmpq_sub(renf_elem_t a, const fmpq_t c, const renf_elem_t b, const renf_t nf)#
void renf_elem_mul_fmpq(renf_elem_t a, const renf_elem_t b, const fmpq_t c, const renf_t nf)#
void renf_elem_div_fmpq(renf_elem_t a, const renf_elem_t b, const fmpq_t c, const renf_t nf)#
void renf_elem_fmpq_div(renf_elem_t a, const fmpq_t b, const renf_elem_t c, const renf_t nf)#
void renf_elem_add(renf_elem_t a, const renf_elem_t b, const renf_elem_t c, const renf_t nf)#
void renf_elem_sub(renf_elem_t a, const renf_elem_t b, const renf_elem_t c, const renf_t nf)#
void renf_elem_mul(renf_elem_t a, const renf_elem_t b, const renf_elem_t c, const renf_t nf)#
void renf_elem_div(renf_elem_t a, const renf_elem_t b, const renf_elem_t c, const renf_t nf)#
void renf_elem_pow(renf_elem_t res, const renf_elem_t a, ulong e, const renf_t nf)#
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.