CiFEr
|
Vector struct and operations. More...
Go to the source code of this file.
Data Structures | |
struct | cfe_vec |
Typedefs | |
typedef struct cfe_mat | cfe_mat |
typedef struct cfe_vec | cfe_vec |
Functions | |
void | cfe_vec_init (cfe_vec *v, size_t size) |
void | cfe_vec_inits (size_t size, cfe_vec *v,...) |
void | cfe_vec_set_const (cfe_vec *vec, mpz_t c) |
void | cfe_vec_copy (cfe_vec *res, cfe_vec *v) |
void | cfe_vec_free (cfe_vec *v) |
void | cfe_vec_frees (cfe_vec *v,...) |
void | cfe_vec_print (cfe_vec *v) |
void | cfe_vec_add (cfe_vec *res, cfe_vec *v1, cfe_vec *v2) |
void | cfe_vec_dot (mpz_t res, cfe_vec *v1, cfe_vec *v2) |
void | cfe_vec_mod (cfe_vec *res, cfe_vec *v, mpz_t modulo) |
void | cfe_vec_mul (cfe_vec *res, cfe_vec *v1, cfe_vec *v2) |
bool | cfe_vec_check_bound (cfe_vec *v, mpz_t bound) |
void | cfe_vec_get (mpz_t res, cfe_vec *v, size_t i) |
void | cfe_vec_set (cfe_vec *v, mpz_t el, size_t i) |
void | cfe_vec_join (cfe_vec *res, cfe_vec *v1, cfe_vec *v2) |
void | cfe_vec_extract (cfe_vec *res, cfe_vec *v, size_t from, size_t n) |
void | cfe_vec_append (cfe_vec *res, cfe_vec *v, mpz_t el) |
void | cfe_vec_mul_matrix (cfe_vec *res, cfe_vec *v, cfe_mat *m) |
void | cfe_vec_mul_scalar (cfe_vec *res, cfe_vec *v, mpz_t s) |
void | cfe_vec_poly_mul (cfe_vec *res, cfe_vec *v1, cfe_vec *v2) |
void | cfe_vec_neg (cfe_vec *res, cfe_vec *v) |
void | cfe_vec_fdiv_q_scalar (cfe_vec *res, cfe_vec *v, mpz_t s) |
void | cfe_vec_FFT (cfe_vec *y, cfe_vec *a, mpz_t root, mpz_t q) |
void | cfe_vec_poly_mul_FFT (cfe_vec *res, cfe_vec *v1, cfe_vec *v2, mpz_t root, mpz_t inv_root, mpz_t inv_n, mpz_t q) |
Vector struct and operations.
As in GMP library, all functions except initialization functions presume that all of the parameters are properly initialized.
All functions (unless othewise specified) store their results (either a GMP integer or a vector) to a parameter and do not modify the original vector. Thus, the "result" passed as a parameter must also be properly initialized.
void cfe_vec_init | ( | cfe_vec * | v, |
size_t | size | ||
) |
Initializes a vector.
v | A pointer to an uninitialized vector |
size | The size of the vector |
void cfe_vec_inits | ( | size_t | size, |
cfe_vec * | v, | ||
... | |||
) |
Variadic version of cfe_vec_init. Initializes a NULL-terminated list of vectors.
void cfe_vec_set_const | ( | cfe_vec * | vec, |
mpz_t | c | ||
) |
Sets all the values of a vector to equal a constant.
vec | A pointer to an initialized vector |
c | The constant that the entries will equal to |
Copies all the values of a vector to another vector. Sizes of the vectors must match.
res | A pointer to an initialized vector, values will be copied here |
v | A pointer to the vector that will be copied |
void cfe_vec_free | ( | cfe_vec * | v | ) |
Frees the memory occupied by the contents of the vector.
void cfe_vec_frees | ( | cfe_vec * | v, |
... | |||
) |
Variadic version of cfe_vec_free. Frees a NULL-terminated list of vectors.
void cfe_vec_print | ( | cfe_vec * | v | ) |
Prints a vector to standard output.
Calculates the dot product (inner product) of two vectors.
bool cfe_vec_check_bound | ( | cfe_vec * | v, |
mpz_t | bound | ||
) |
Checks if all coordinates are < bound.
void cfe_vec_get | ( | mpz_t | res, |
cfe_vec * | v, | ||
size_t | i | ||
) |
Sets res to the i-th element of the vector.
void cfe_vec_set | ( | cfe_vec * | v, |
mpz_t | el, | ||
size_t | i | ||
) |
Sets the i-th element of the vector to el.
Joins two vectors into a single vector.
Extract n elements of the vector starting at index from.
Appends element el to the end of the vector.
Multiplication of a vector transposed by a matrix.
Multiplication of a vector with a scalar.
Multiplication of two vectors representing polynomials in Z[x] / (x^n + 1)
Coordinate-wise division with floor rounding.
Recursive implementation of FFT, assuming the length of a is a power of 2.