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
.
-
nf_elem_t elem#
-
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 usinga
as it performs allocation. Once done witha
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
andb
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 integern
an element in the number fieldnf
.
-
void renf_elem_set_ui(renf_elem_t a, ulong n, const renf_t nf)#
Set
a
to the integern
as an element in the number fieldnf
.
-
void renf_elem_set(renf_elem_t a, const renf_elem_t b, const renf_t nf)#
Set
a
to the number field elementb
which is defined in the number fieldnf
.
-
void renf_elem_set_fmpz(renf_elem_t a, const fmpz_t c, const renf_t nf)#
Set
a
to the integerc
as an element in the number fieldnf
.
-
void renf_elem_set_mpz(renf_elem_t a, const mpz_t c, const renf_t nf)#
Set
a
to the integerc
as an element in the number fieldnf
.
-
void renf_elem_set_fmpq(renf_elem_t a, const fmpq_t c, const renf_t nf)#
Set
a
to the rationalc
as an element in the number fieldnf
.
-
void renf_elem_set_mpq(renf_elem_t a, const mpq_t c, const renf_t nf)#
Set
a
to the rationalc
as an element in the number fieldnf
.
-
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 fieldnf
.
-
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 elementb
defined in exact number field underlyingnf
. Then refinea
to precisionprec
.
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 ofnf
. Computation is done at precisionprec
. 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 is1
ifa
is positive,0
ifa
is zero and-1
ifa
is negative.
-
void renf_elem_floor(fmpz_t a, renf_elem_t b, renf_t nf)#
Set
a
to be the floor ofb
-
void renf_elem_ceil(fmpz_t a, renf_elem_t b, renf_t nf)#
Set
a
to be the ceil ofb
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 elementa
that belongs to the number fieldnf
withprec
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 elementsa
andb
behave as follows. They returna positive integer if
a
is greater thanb
,0
ifa
andb
are equal, anda negative integer if
a
is smaller thanb
.
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 namevar
. The resulting string needs to be freed withflint_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 innf
.
Unary operations#
-
void renf_elem_neg(renf_elem_t a, const renf_elem_t b, const renf_t nf)#
Set
a
to the negative ofb
.
-
void renf_elem_inv(renf_elem_t a, const renf_elem_t b, const renf_t nf)#
Set
a
to the inverse ofb
.
Binary operations#
- group renf_elem_binop
All the binary operation functions are of the form
renf_elem_OP_TYP(a, b, c, nf)
whereOP
is the operation typeTYP
is the type of the argumentc
a
is the argument used for returned valueb
andc
are the operandsnf
is the parent number field of the operation In short, these functions performa = 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
andc
and set the result ina
. 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 then
-th first partial quotients of the continued fraction of the elementa
ofnf
.
-
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 evaluatinga
as a polynomial in the number field generator.