The Wayback Machine - https://web.archive.org/web/20240717024406/https://www.geeksforgeeks.org/numeric-library-c-stl/
Open In App

<numeric> library in C++ STL

Last Updated : 04 Apr, 2018
Improve
Suggest changes
Post a comment
Like Article
Like
Save
Share
Report

Common mathematical functions

  • std::fabs: This function returns the absolute value.
  • std::sqrt: This function returns the square root
  • std::sin: This function returns the sine measured in radians.

Special mathematical functions

  • std::beta: This function evaluates the (complete) Beta integral with given parameters
  • std::hermite: This function Returns the value of the Hermite Polynomial of order n at point x
  • std::cyl_bessel_i: This function returns value of the regular modified cylindrical Bessel function.

Complex number arithmetic

  • complex: a complex number class, defined in header (class template)

Numeric arrays

  • valarray : numeric arrays, array masks and array slices (class template)

Factor operations(Defined in header )

  • gcd: constexpr function template returning the greatest common divisor of two integers. (function template)
  • lcm: constexpr function template returning the least common multiple of two integers (function template)

Numeric operations(Defined in header )

  • iota: fills a range with successive increments of the starting value (function template)
  • accumulate: sums up a range of elements (function template)
  • reduce: similar to std::accumulate, except out of order (function template)
  • transform_reduce: applies a functor, then reduces out of order (function template)
  • inner_product: computes the inner product of two ranges of elements .(function template)
  • adjacent_difference: computes the differences between adjacent elements in a range (function template)
  • partial_sum: computes the partial sum of a range of elements (function template)
  • inclusive_scan: similar to std::partial_sum, includes the ith input element in the ith sum (function template)
  • exclusive_scan: similar to std::partial_sum, excludes the ith input element from the ith sum (function template)
  • transform_inclusive_scan: applies a functor, then calculates inclusive scan (function template)
  • transform_exclusive_scan: applies a functor, then calculates exclusive scan (function template)

More Useful Links



Similar Reads

accumulate() and partial_sum() in C++ STL : Numeric header
The numeric header is part of the numeric library in C++ STL. This library consists of basic mathematical functions and types, as well as optimized numeric arrays and support for random number generation. Some of the functions in the numeric header: iotaaccumulatereduceinner_productpartial_sum etc. This article explains accumulate() and partial_sum
4 min read
numeric header in C++ STL | Set 2 (adjacent_difference(), inner_product() and iota())
The numeric header is part of the numeric library in C++ STL. This library consists of basic mathematical functions and types, as well as optimized numeric arrays and support for random number generation. Some of the functions in the numeric header: iotaaccumulatereduceinner_productpartial_sum etc. See this article for more reference: accumulate()
4 min read
The C++ Standard Template Library (STL)
The Standard Template Library (STL) is a set of C++ template classes to provide common programming data structures and functions such as lists, stacks, arrays, etc. It is a library of container classes, algorithms, and iterators. It is a generalized library and so, its components are parameterized. Working knowledge of template classes is a prerequ
5 min read
Sort in C++ Standard Template Library (STL)
Sorting is one of the most basic functions applied to data. It means arranging the data in a particular fashion, which can be increasing or decreasing. There is a builtin function in C++ STL by the name of sort(). This function internally uses IntroSort. In more details it is implemented using hybrid of QuickSort, HeapSort and InsertionSort.By defa
6 min read
Algorithm Library Functions in C++ STL
Non-modifying sequence operations std :: all_of : Test condition on all elements in rangestd :: any_of : Test if any element in range fulfills conditionstd :: none_of : Test if no elements fulfill conditionstd :: for_each : Apply function to rangestd :: find : Find value in rangestd :: find_if : Find element in rangestd :: find_if_not : Find elemen
4 min read
&lt;iterator&gt; library in C++ STL
Iterators in C++ STL | Introduction Functions Iterator operations : std :: advance : Advance iteratorstd :: distance : Return distance between iteratorsstd :: begin : Iterator to beginningstd :: end : Iterator to endstd :: prev : Get iterator to previous elementstd :: next : Get iterator to next elementstd :: next vs std :: advanceAll functions in
1 min read
&lt;strings&gt; library in C++ STL
Member functions String.constructor : Construct string object (public member function ).String.destructor : String destructor (public member function )String.operator= : String assignment (public member function ) Iterators Begin : Return iterator to beginning (public member function )End : Return iterator to end (public member function )Advance :
3 min read
&lt;regex&gt; library in C++ STL
Main classes These classes encapsulate a regular expression and the results of matching a regular expression within a target sequence of characters. basic_regex: Regular expression object (class template) sub_match: Identifies the sequence of characters matched by a sub-expression (class template) match_results: Identifies one regular expression ma
2 min read
Priority Queue in C++ Standard Template Library (STL)
A C++ priority queue is a type of container adapter, specifically designed such that the first element of the queue is either the greatest or the smallest of all elements in the queue, and elements are in non-increasing or non-decreasing order (hence we can see that each element of the queue has a priority {fixed order}). In C++ STL, the top elemen
11 min read
Containers in C++ STL (Standard Template Library)
A container is a holder object that stores a collection of other objects (its elements). They are implemented as class templates, which allows great flexibility in the types supported as elements. The container manages the storage space for its elements and provides member functions to access them, either directly or through iterators (reference ob
2 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg