FLINT3.7.0-dev
Module · 11 functions

fmpz_mod_vec.h

#include <flint/fmpz_mod_vec.h>

This module provides operations on vectors over \mathbb{Z}/n\mathbb{Z} whose entries are canonical residues in [0, n) stored as plain fmpz arrays, with the modulus given by an fmpz_mod_ctx_t. Vectors are allocated, cleared, copied and compared with the fmpz_vec functions (_fmpz_vec_init, _fmpz_vec_clear, _fmpz_vec_set, _fmpz_vec_equal, ...). The functions are the building blocks of fmpz_mod_poly and fmpz_mod_mat.

All functions take a vector as a pointer and a length. Unless stated otherwise, inputs must be canonical and the output is canonical, and the output may alias an input of the same length (the loops are elementwise).

Conversion#

void _fmpz_mod_vec_set_fmpz_vec(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx)

Sets the entries of (A, \mathit{len}) to the entries of (B, \mathit{len}) reduced modulo n; B may contain any integers and may alias A.

More
void _fmpz_mod_vec_get_fmpz_vec_smod(fmpz * res, const fmpz * vec, slong len, const fmpz_mod_ctx_t ctx)

Given canonical residues (\mathit{vec}, \mathit{len}), sets (\mathit{res}, \mathit{len}) to the symmetric residues in (-n/2, n/2]. This is the same as _fmpz_vec_scalar_smod_fmpz but faster, since the input is known to be reduced: each entry costs one comparison and at most one subtraction.

Arithmetic#

void _fmpz_mod_vec_neg(fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx)

Sets (A, \mathit{len}) to -(B, \mathit{len}).

void _fmpz_mod_vec_add(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx)
void _fmpz_mod_vec_sub(fmpz * a, const fmpz * b, const fmpz * c, slong n, const fmpz_mod_ctx_t ctx)

Set (a, n) to (b, n) + (c, n) and (b, n) - (c, n), elementwise. Here n is the length of the vectors, not the modulus.

void _fmpz_mod_vec_mul(fmpz * A, const fmpz * B, const fmpz * C, slong len, const fmpz_mod_ctx_t ctx)

Sets (A, \mathit{len}) to the elementwise product of (B, \mathit{len}) and (C, \mathit{len}).

Scalar multiplication#

void _fmpz_mod_vec_scalar_mul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx)

Sets (A, \mathit{len}) to c \cdot (B, \mathit{len}), for canonical c. For c = 1 this is a copy.

void _fmpz_mod_vec_scalar_addmul_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx)

Sets (A, \mathit{len}) to (A, \mathit{len}) + c \cdot (B, \mathit{len}), for canonical c. Each entry is updated with one exact fmpz_addmul and one reduction.

void _fmpz_mod_vec_scalar_div_fmpz_mod(fmpz * A, const fmpz * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx)

Sets (A, \mathit{len}) to c^{-1} \cdot (B, \mathit{len}). Throws an exception (from fmpz_mod_inv) if c is not invertible modulo n.

Dot products#

void _fmpz_mod_vec_dot(fmpz_t d, const fmpz * A, const fmpz * B, slong len, const fmpz_mod_ctx_t ctx)
void _fmpz_mod_vec_dot_rev(fmpz_t r, const fmpz * a, const fmpz * b, slong len, const fmpz_mod_ctx_t ctx)

Set the output to \sum_{i} A_i B_i, respectively \sum_i a_i b_{\mathit{len} - 1 - i}, modulo n.

More
Cite this page

The FLINT team, “fmpz_mod_vec.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpz_mod_vec/index.html (generated 2026-10-20).