FLINT3.7.0-dev

flint_mpn_mulmid_complex, flint_mpn_sqrmid_complex

Synopsis#include <flint/mpn_extras.h>
void flint_mpn_mulmid_complex(nn_ptr zr, nn_ptr zi, mp_size_t lo, mp_size_t hi, nn_srcptr ar, mp_size_t arn, int ar_sgn, nn_srcptr ai, mp_size_t ain, int ai_sgn, nn_srcptr br, mp_size_t brn, int br_sgn, nn_srcptr bi, mp_size_t bin, int bi_sgn)source
void flint_mpn_sqrmid_complex(nn_ptr zr, nn_ptr zi, mp_size_t lo, mp_size_t hi, nn_srcptr ar, mp_size_t arn, int ar_sgn, nn_srcptr ai, mp_size_t ain, int ai_sgn)source

Windowed products: zr and zi receive \mathit{hi} - \mathit{lo} limbs each, 0 \le \mathit{lo} < \mathit{hi}, the limbs [\mathit{lo}, \mathit{hi}) of the real and imaginary parts in two's complement: for each exact part x the window is \lfloor x / B^{\mathit{lo}} \rfloor + e \bmod B^{\mathit{hi} - \mathit{lo}} with a small error e. For \mathit{lo} = 0 these are the low products (e = 0); on the transformed path |e| \le 1; otherwise |e| < 4 (m + 1) B with m = \min(\max(\mathit{arn}, \mathit{ain}), \max(\mathit{brn}, \mathit{bin})). Inputs are as for the low products (only their low \mathit{hi} limbs are read).

The two's complement window of a signed part is linear, so the real windows of the schoolbook and Karatsuba schemes combine modulo B^{\mathit{hi} - \mathit{lo}}, and it is what a Kronecker unpacking of signed fields reads. To extract the polynomial coefficients [n_{lo}, n_{hi}) of b-bit fields, take \mathit{hi} = \lceil n_{hi} b / \mathtt{FLINT\_BITS} \rceil and \mathit{lo} a few guard limbs below bit n_{lo} b - 1; the unpacked fields are exact provided that |e| B^{\mathit{lo}} is below the distance from the low part \sum_{k < n_{lo}} r_k 2^{k b} to \pm 2^{n_{lo} b - 1}, which a bound |r_k| \le 2^{b - 1} - 2^{b - s} makes at least 2^{n_{lo} b - s} (see _fmpzi_poly_mulmid_KS, which uses three guard limbs).

The schoolbook and Karatsuba variants combine real windows from flint_mpn_mulmid. The transformed variant splits the integers into chunks and multiplies them as chunk sequences on fft_small transforms (four forward and two inverse transforms; two and two for the square), reconstructing only the coefficients that can reach limbs [\mathit{lo}, \mathit{hi}). When a power of two 2^d admits it (operands and the coefficients below the top of the window fitting in 2^d, and the coefficients beyond 2^d aliasing below the first one reaching the window) the transforms are cyclic of length 2^d. For the shape of the Newton middle product (2n by n limbs, window [n, 2n)) this gives a transform of about 2n chunks instead of 3n when 2n chunks lie a little below a power of two.

Cite this page

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