The C++ numerics library includes common mathematical functions and types, as well as optimized numeric arrays and support for random number generation.
Mathematical functions and types
The header
provides
standard C library mathematical functions
such as
,
, and
.
Mathematical special functions
(since C++17)
The header
also provides several mathematical special functions such as
,
, and
.
(since C++20)
The header
provides several mathematical constants, such as
or
Basic linear algebra algorithms
(since C++26)
The header
provides basic linear algebra algorithms which are based on BLAS.
(since C++26)
The header
provides portable types for explicitly stating data-parallelism and structuring data for more efficient SIMD access.
Complex number arithmetic
Numeric arrays
numeric arrays, array masks and array slices
(class template)Numeric algorithms
The header
provides numeric algorithms below:
Factor operations (since C++17)
(C++17)
computes the greatest common divisor of two integers
(function template)
(C++17)
computes the least common multiple of two integers
(function template)
Interpolation operations (C++20)
Saturation arithmetic (since C++26)
Defined in header
(C++26)
saturating addition operation on two integers
(function template)
(C++26)
saturating subtraction operation on two integers
(function template)
(C++26)
saturating multiplication operation on two integers
(function template)
(C++26)
saturating division operation on two integers
(function template)
(C++26)
returns an integer value clamped to the range of another integer type
(function template)
Numeric operations
Defined in header
(C++11)
fills a range with successive increments of the starting value
(function template & algorithm function object)
(C++23)
sums up or folds a range of elements
(function template)
(C++17)
similar to
, except out of order
(function template)
(C++17)
applies an invocable, then reduces out of order
(function template)
computes the inner product of two ranges of elements
(function template)
computes the differences between adjacent elements in a range
(function template)
computes the partial sum of a range of elements
(function template)
(C++17)
similar to
, includes the ith input element in the ith sum
(function template)
(C++17)
similar to
, excludes the ith input element from the ith sum
(function template)
(C++17)
applies an invocable, then calculates inclusive scan
(function template)
(C++17)
applies an invocable, then calculates exclusive scan
(function template)
Miscellaneous
Pseudo-random number generation
The header
defines
pseudo-random number generators and numerical distributions
. The header
also includes C-style random number generation via
and
.
(since C++11)
The header
defines
flags and functions related to exceptional floating-point state
, such as overflow and division by zero.
(since C++20)
The header
provides several function templates to access, manipulate, and process individual bits and bit sequences. The byte ordering (
) of scalar types can be inspected via std::endian facility.
Checked integer arithmetic (since C++26)
The C compatibility header
provides several function templates for checked integer arithmetic.
(C++26)
checked addition operation on two integers
(function template)
(C++26)
checked subtraction operation on two integers
(function template)
(C++26)
checked multiplication operation on two integers
(function template)
See also