All Numeric Algorithms

All Numeric Algorithms

A compact scan page for the main standard numeric algorithms from <numeric> and adjacent math-oriented facilities.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

All Numeric Algorithms

Accumulation and reduction

Prefix and suffix style scans

Differences and products

Integer and ratio helpers

Common use guidance

Small worked example

#include <numeric>
#include <vector>

int main() {
	std::vector<int> values{5, 7, 2, 4};
	std::vector<int> prefix(values.size());
	std::inclusive_scan(values.begin(), values.end(), prefix.begin());
	return prefix.back();
}

Scan algorithms are the right tool when each output depends on all earlier input, such as running totals, partial sums, or progressive limits.

Decision guide

Example in practice

#include <numeric>
#include <vector>

int main() {
    std::vector<int> values{1, 2, 3, 4};
    auto prefix = std::vector<int>(values.size());
    std::inclusive_scan(values.begin(), values.end(), prefix.begin());
    return prefix.back();
}