FLINT3.7.0-dev

radix_mulmid

Synopsis#include <flint/radix.h>
void radix_mulmid(nn_ptr res, nn_srcptr a, slong an, nn_srcptr b, slong bn, slong lo, slong hi, const radix_t radix)source

Windowed product: for an,bn≥1\mathit{an}, \mathit{bn} \ge 1 and 0≤lo<hi≤an+bn0 \le \mathit{lo} < \mathit{hi} \le \mathit{an} + \mathit{bn}, sets (res,hi−lo)(\mathit{res}, \mathit{hi} - \mathit{lo}) to the limbs [lo,hi)[\mathit{lo}, \mathit{hi}) of the product, computed without the carries from the limbs below lo\mathit{lo}. res must not overlap the inputs.

Viewing aa and bb as polynomials A,Y∈Z[T]A, Y \in \mathbb{Z}[T] evaluated at T=BT = B, the function computes the slice Zlo:hi=∑k=lohi−1([Tk]AY) Tk−loZ_{lo:hi} = \sum_{k=lo}^{hi-1} ([T^k] AY)\, T^{k-lo} of the polynomial product and writes Zlo:hi(B) mod Bhi−loZ_{lo:hi}(B) \bmod B^{hi-lo}: carries from lower terms are omitted and carries beyond the top are discarded. In particular:

  • for lo=0\mathit{lo} = 0 this is the low product ab mod Bhiab \bmod B^{hi};
  • for hi=an+bn\mathit{hi} = \mathit{an} + \mathit{bn} this is an approximate high product rr with ab≥rBlo≥ab−min⁡(an,bn,lo)Blo+1ab \ge r B^{lo} \ge ab - \min(\mathit{an}, \mathit{bn}, \mathit{lo}) B^{lo+1};
  • for lo=0\mathit{lo} = 0 and hi=an+bn\mathit{hi} = \mathit{an} + \mathit{bn} it is the full product.

The classical algorithm is used if either operand or the window is shorter than 80 limbs, and otherwise if the number of limb products the window needs (counted by _radix_mulmid_pairs_below) is less than RADIX_MULMID_FFT_CUTOFF_RATIO ⋅L\cdot L; the FFT (or Kronecker substitution without fft_small) is used otherwise. The cost of the FFT depends essentially on the length LL of the convolution it computes, while the classical algorithm benefits from short windows: a high product needs about half as many limb products as the full product. With fft_small, LL is _radix_mulmid_fft_length(an,bn,lo,hi)(\mathit{an}, \mathit{bn}, \mathit{lo}, \mathit{hi}), which is smaller than an+bn\mathit{an} + \mathit{bn} for windows that do not need all limbs or that are computed as transposed products; without it, L=an+bnL = \mathit{an} + \mathit{bn}.

Cite this page

The FLINT team, “radix_mulmid (radix.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/radix/radix_mulmid.html (generated 2026-11-02).