|
|
Line 1: |
Line 1: |
− | {{title|Numerics library}}
| + | #REDIRECT [[enwiki:Rust_(programming_language)]] |
− | {{cpp/numeric/navbar}}
| + | |
− | | + | |
− | 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==
| + | |
− | | + | |
− | ===[[cpp/numeric/math|Common mathematical functions]]===
| + | |
− | | + | |
− | The header {{header|cmath}} provides [[cpp/numeric/math|standard C library mathematical functions]] such as {{lc|std::fabs}}, {{lc|std::sqrt}}, and {{lc|std::sin}}.
| + | |
− | | + | |
− | ===[[cpp/numeric/special_functions|Mathematical special functions]] {{mark since c++17}}===
| + | |
− | | + | |
− | The header {{header|cmath}} also provides several mathematical special functions such as {{lc|std::beta}}, {{lc|std::hermite}}, and {{lc|std::cyl_bessel_i}}.
| + | |
− | | + | |
− | ===[[cpp/numeric/constants|Mathematical constants]] {{mark since c++20}}===
| + | |
− | The header {{header|numbers}} provides several mathematical constants, such as {{lc|std::numbers::pi}} or {{lc|std::numbers::sqrt2}}
| + | |
− | | + | |
− | ===Complex number arithmetic===
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc header | complex}}
| + | |
− | {{dsc tclass | cpp/numeric/complex | a complex number type }}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ===Numeric arrays===
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc header | valarray}}
| + | |
− | {{dsc tclass | cpp/numeric/valarray | numeric arrays, array masks and array slices }}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ==Numeric algorithms==
| + | |
− | | + | |
− | The header {{header|numeric}} provides numeric algorithms below:
| + | |
− | | + | |
− | ===Factor operations===
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc header | numeric}}
| + | |
− | {{dsc inc | cpp/numeric/dsc gcd}}
| + | |
− | {{dsc inc | cpp/numeric/dsc lcm}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ===Interpolation operations===
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc header | numeric}}
| + | |
− | {{dsc inc | cpp/numeric/dsc midpoint}}
| + | |
− | {{dsc header | cmath}}
| + | |
− | {{dsc inc | cpp/numeric/dsc lerp}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ===Numeric operations===
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc header | numeric}}
| + | |
− | {{dsc inc | cpp/algorithm/dsc iota}}
| + | |
− | {{dsc inc | cpp/algorithm/ranges/dsc iota}}
| + | |
− | {{dsc inc | cpp/algorithm/dsc accumulate}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc accumulate}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc reduce}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc reduce}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc transform_reduce}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc transform_reduce}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc inner_product}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc inner_product}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc adjacent_difference}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc adjacent_difference}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc partial_sum}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc partial_sum}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc inclusive_scan}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc inclusive_scan}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc exclusive_scan}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc exclusive_scan}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc transform_inclusive_scan}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc transform_inclusive_scan}}-->
| + | |
− | {{dsc inc | cpp/algorithm/dsc transform_exclusive_scan}}
| + | |
− | <!--{{dsc inc | cpp/algorithm/ranges/dsc transform_exclusive_scan}}-->
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ==Miscellanous==
| + | |
− | | + | |
− | ===[[cpp/numeric/random|Pseudo-random number generation]]===
| + | |
− | | + | |
− | The header {{header|random}} defines [[cpp/numeric/random|pseudo-random number generators and numerical distributions]]. The header {{header|cstdlib}} also includes C-style random number generation via {{lc|std::srand}} and {{lc|std::rand}}.
| + | |
− | | + | |
− | ===[[cpp/numeric/fenv|Floating-point environment]] {{mark since c++11}}===
| + | |
− | | + | |
− | The header {{header|cfenv}} defines [[cpp/numeric/fenv|flags and functions related to exceptional floating-point state]], such as overflow and division by zero.
| + | |
− | | + | |
− | === Bit manipulation {{mark since c++20}} ===
| + | |
− | The header {{header|bit}} provides several function templates to access, manipulate, and process individual bits and bit sequences.
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc header|bit}}
| + | |
− | {{dsc namespace | std }}
| + | |
− | {{dsc inc | cpp/numeric/dsc bit_cast}}
| + | |
− | {{dsc inc | cpp/numeric/dsc byteswap}}
| + | |
− | {{dsc inc | cpp/numeric/dsc has_single_bit}}
| + | |
− | {{dsc inc | cpp/numeric/dsc bit_ceil}}
| + | |
− | {{dsc inc | cpp/numeric/dsc bit_floor}}
| + | |
− | {{dsc inc | cpp/numeric/dsc bit_width}}
| + | |
− | {{dsc inc | cpp/numeric/dsc rotl}}
| + | |
− | {{dsc inc | cpp/numeric/dsc rotr}}
| + | |
− | {{dsc inc | cpp/numeric/dsc countl_zero}}
| + | |
− | {{dsc inc | cpp/numeric/dsc countl_one}}
| + | |
− | {{dsc inc | cpp/numeric/dsc countr_zero}}
| + | |
− | {{dsc inc | cpp/numeric/dsc countr_one}}
| + | |
− | {{dsc inc | cpp/numeric/dsc popcount}}
| + | |
− | | + | |
− | {{dsc inc | cpp/types/dsc endian}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ===See also===
| + | |
− | {{dsc begin}}
| + | |
− | {{dsc see c | c/numeric | Numerics | nomono=true}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | {{langlinks|ar|de|es|fr|it|ja|pt|ru|zh}}
| + | |