Skip to content

ntt

polynomial · scripts/polynomial/ntt.m

: y = ntt (x, p)
: y = ntt (x, n, p)

Number-theoretic transform (NTT) of vector x modulo prime p.

The NTT is the discrete Fourier transform over the finite field GF(p). It is used for exact integer / polynomial multiplication modulo a prime (see also intt, nttmul).

x must be a real numeric vector. Coefficients are reduced mod (x, p) before transforming. With two arguments the transform length is numel (x). With three arguments, x is zero-padded or truncated to length n.

p must be a prime scalar with mod (p - 1, n) == 0 so a primitive n-th root of unity exists. The output is a double row vector unless x is a column, in which case the output is a column.

MATLAB R2026a has no core builtin of this name; this API follows the standard NTT definition (primitive root of unity in GF(p), same values as the widely documented reference examples for ntt ([1 2 3 4], 13) == [10 8 11 1]).