ca_vec.h – vectors of real and complex numbers¶
A ca_vec_t
represents a vector of real or complex numbers,
implemented as an array of coefficients of type ca_struct
.
Most functions are provided in two versions: an underscore method which
operates directly on pre-allocated arrays of coefficients
(taking ca_ptr
and ca_srcptr
arguments),
and a non-underscore method which takes ca_vec_t
input
and performs automatic memory management.
Unlike ca_poly_t
, a ca_vec_t
is not normalised
by removing zero coefficients; it retains the exact length
assigned by the user.
Types, macros and constants¶
-
type
ca_vec_struct
¶
-
type
ca_vec_t
¶ Contains a pointer to an array of entries (coeffs), the used length (length), and the allocated size of the array (alloc).
A ca_vec_t is defined as an array of length one of type ca_vec_struct, permitting an ca_vec_t to be passed by reference.
-
ca_vec_entry
(vec, i)¶ Macro returning a pointer to entry i in the vector vec. The index must be in bounds.
Memory management¶
-
ca_ptr
_ca_vec_init
(slong len, ca_ctx_t ctx)¶ Returns a pointer to an array of len coefficients initialized to zero.
-
void
ca_vec_init
(ca_vec_t vec, slong len, ca_ctx_t ctx)¶ Initializes vec to a length len vector. All entries are set to zero.
-
void
_ca_vec_clear
(ca_ptr vec, slong len, ca_ctx_t ctx)¶ Clears all len entries in vec and frees the pointer vec itself.
Length¶
Assignment¶
Special vectors¶
Input and output¶
List operations¶
Arithmetic¶
-
void
_ca_vec_sub
(ca_ptr res, ca_srcptr vec1, ca_srcptr vec2, slong len, ca_ctx_t ctx)¶ Sets res to the sum or difference of vec1 and vec2, all vectors having length len.
-
void
_ca_vec_scalar_mul_ca
(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx)¶ Sets res to src multiplied by c, all vectors having length len.
-
void
_ca_vec_scalar_div_ca
(ca_ptr res, ca_srcptr src, slong len, const ca_t c, ca_ctx_t ctx)¶ Sets res to src divided by c, all vectors having length len.
Comparisons and properties¶
Internal representation¶
-
int
_ca_vec_is_fmpq_vec
(ca_srcptr vec, slong len, ca_ctx_t ctx)¶ Checks if all elements of vec are structurally rational numbers.
-
int
_ca_vec_fmpq_vec_is_fmpz_vec
(ca_srcptr vec, slong len, ca_ctx_t ctx)¶ Assuming that all elements of vec are structurally rational numbers, checks if all elements are integers.