FLINT3.7.0-dev

_gr_vec_sum, _gr_vec_product

Synopsis#include <flint/gr_vec.h>
int _gr_vec_sum(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx)source
int _gr_vec_product(gr_ptr res, gr_srcptr vec, slong len, gr_ctx_t ctx)source

Set res to the sum, respectively the product, of the len entries; the empty sum is 0 and the empty product 1 (methods GR_METHOD_VEC_SUM, GR_METHOD_VEC_PRODUCT).

The defaults are _gr_vec_sum_generic and _gr_vec_product_generic. In finite rings they add or multiply from left to right. In other rings, where entries can grow, the sum of more than 100 entries uses binary splitting with basecase length 100, and the product of more than 20 entries binary splitting with basecase length 20, or, for more than 500 entries in a thread-safe ring, parallel binary splitting with basecase length 500. Balanced binary splitting computes a product of n integers of b bits each in O(M(nb) \log n) time instead of the O(n^2 b) of the left-to-right loop, and similarly sums of fractions; see Binary splitting and product trees.

Guides#

Cite this page

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