CiFEr
Data Structures | Typedefs | Functions
vec.h File Reference

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)
 

Detailed Description

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.

Typedef Documentation

◆ cfe_vec

typedef struct cfe_vec cfe_vec

Vector of arbitrary precision (GMP) integers.

Function Documentation

◆ cfe_vec_init()

void cfe_vec_init ( cfe_vec v,
size_t  size 
)

Initializes a vector.

Parameters
vA pointer to an uninitialized vector
sizeThe size of the vector

◆ cfe_vec_inits()

void cfe_vec_inits ( size_t  size,
cfe_vec v,
  ... 
)

Variadic version of cfe_vec_init. Initializes a NULL-terminated list of vectors.

◆ cfe_vec_set_const()

void cfe_vec_set_const ( cfe_vec vec,
mpz_t  c 
)

Sets all the values of a vector to equal a constant.

Parameters
vecA pointer to an initialized vector
cThe constant that the entries will equal to

◆ cfe_vec_copy()

void cfe_vec_copy ( cfe_vec res,
cfe_vec v 
)

Copies all the values of a vector to another vector. Sizes of the vectors must match.

Parameters
resA pointer to an initialized vector, values will be copied here
vA pointer to the vector that will be copied

◆ cfe_vec_free()

void cfe_vec_free ( cfe_vec v)

Frees the memory occupied by the contents of the vector.

◆ cfe_vec_frees()

void cfe_vec_frees ( cfe_vec v,
  ... 
)

Variadic version of cfe_vec_free. Frees a NULL-terminated list of vectors.

◆ cfe_vec_print()

void cfe_vec_print ( cfe_vec v)

Prints a vector to standard output.

◆ cfe_vec_add()

void cfe_vec_add ( cfe_vec res,
cfe_vec v1,
cfe_vec v2 
)

Adds two vectors.

◆ cfe_vec_dot()

void cfe_vec_dot ( mpz_t  res,
cfe_vec v1,
cfe_vec v2 
)

Calculates the dot product (inner product) of two vectors.

◆ cfe_vec_mod()

void cfe_vec_mod ( cfe_vec res,
cfe_vec v,
mpz_t  modulo 
)

Coordinate-wise modulo.

◆ cfe_vec_mul()

void cfe_vec_mul ( cfe_vec res,
cfe_vec v1,
cfe_vec v2 
)

Coordinate-wise multiplication.

◆ cfe_vec_check_bound()

bool cfe_vec_check_bound ( cfe_vec v,
mpz_t  bound 
)

Checks if all coordinates are < bound.

Returns
false if any coordinate is >= bound, true otherwise

◆ cfe_vec_get()

void cfe_vec_get ( mpz_t  res,
cfe_vec v,
size_t  i 
)

Sets res to the i-th element of the vector.

◆ cfe_vec_set()

void cfe_vec_set ( cfe_vec v,
mpz_t  el,
size_t  i 
)

Sets the i-th element of the vector to el.

◆ cfe_vec_join()

void cfe_vec_join ( cfe_vec res,
cfe_vec v1,
cfe_vec v2 
)

Joins two vectors into a single vector.

◆ cfe_vec_extract()

void cfe_vec_extract ( cfe_vec res,
cfe_vec v,
size_t  from,
size_t  n 
)

Extract n elements of the vector starting at index from.

◆ cfe_vec_append()

void cfe_vec_append ( cfe_vec res,
cfe_vec v,
mpz_t  el 
)

Appends element el to the end of the vector.

◆ cfe_vec_mul_matrix()

void cfe_vec_mul_matrix ( cfe_vec res,
cfe_vec v,
cfe_mat m 
)

Multiplication of a vector transposed by a matrix.

◆ cfe_vec_mul_scalar()

void cfe_vec_mul_scalar ( cfe_vec res,
cfe_vec v,
mpz_t  s 
)

Multiplication of a vector with a scalar.

◆ cfe_vec_poly_mul()

void cfe_vec_poly_mul ( cfe_vec res,
cfe_vec v1,
cfe_vec v2 
)

Multiplication of two vectors representing polynomials in Z[x] / (x^n + 1)

◆ cfe_vec_neg()

void cfe_vec_neg ( cfe_vec res,
cfe_vec v 
)

Coordinate-wise negation.

◆ cfe_vec_fdiv_q_scalar()

void cfe_vec_fdiv_q_scalar ( cfe_vec res,
cfe_vec v,
mpz_t  s 
)

Coordinate-wise division with floor rounding.

◆ cfe_vec_FFT()

void cfe_vec_FFT ( cfe_vec y,
cfe_vec a,
mpz_t  root,
mpz_t  q 
)

Recursive implementation of FFT, assuming the length of a is a power of 2.

◆ cfe_vec_poly_mul_FFT()

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 
)

Multiplication of two vectors representing polynomials in Z_q[x] using FFT.