2012-03-27 23:13:14 +00:00
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2018-12-28 15:30:48 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns = "http://www.w3.org/1999/xhtml" > < head > < meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8" / > < title > Chapter 26. Numerics< / title > < meta name = "generator" content = "DocBook XSL Stylesheets Vsnapshot" / > < meta name = "keywords" content = "ISO C++, library" / > < meta name = "keywords" content = "ISO C++, runtime, library" / > < link rel = "home" href = "../index.html" title = "The GNU C++ Library" / > < link rel = "up" href = "extensions.html" title = "Part III. Extensions" / > < link rel = "prev" href = "ext_algorithms.html" title = "Chapter 25. Algorithms" / > < link rel = "next" href = "ext_iterators.html" title = "Chapter 27. Iterators" / > < / head > < body > < div class = "navheader" > < table width = "100%" summary = "Navigation header" > < tr > < th colspan = "3" align = "center" > Chapter 26. Numerics< / th > < / tr > < tr > < td width = "20%" align = "left" > < a accesskey = "p" href = "ext_algorithms.html" > Prev< / a > < / td > < th width = "60%" align = "center" > Part III.
2012-03-27 23:13:14 +00:00
Extensions
2014-09-21 17:33:12 +00:00
< / th > < td width = "20%" align = "right" > < a accesskey = "n" href = "ext_iterators.html" > Next< / a > < / td > < / tr > < / table > < hr / > < / div > < div class = "chapter" > < div class = "titlepage" > < div > < div > < h2 class = "title" > < a id = "manual.ext.numerics" > < / a > Chapter 26. Numerics< / h2 > < / div > < / div > < / div > < p > 26.4, the generalized numeric operations such as < code class = "code" > accumulate< / code > ,
2012-03-27 23:13:14 +00:00
are extended with the following functions:
< / p > < pre class = "programlisting" >
power (x, n);
power (x, n, monoid_operation);< / pre > < p > Returns, in FORTRAN syntax, "< code class = "code" > x ** n< / code > " where
< code class = "code" > n > = 0< / code > . In the
case of < code class = "code" > n == 0< / code > , returns the identity element for the
monoid operation. The two-argument signature uses multiplication (for
a true "power" implementation), but addition is supported as well.
The operation functor must be associative.
< / p > < p > The < code class = "code" > iota< / code > function wins the award for Extension With the
Coolest Name (the name comes from Ken Iverson's APL language.) As
2018-12-28 15:30:48 +00:00
described in the < a class = "link" href = "https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/iota.html" target = "_top" > SGI
2012-03-27 23:13:14 +00:00
documentation< / a > , it "assigns sequentially increasing values to a range.
That is, it assigns < code class = "code" > value< / code > to < code class = "code" > *first< / code > ,
< code class = "code" > value + 1< / code > to< code class = "code" > *(first + 1)< / code > and so on."
< / p > < pre class = "programlisting" >
void iota(_ForwardIter first, _ForwardIter last, _Tp value);< / pre > < p > The < code class = "code" > iota< / code > function is included in the ISO C++ 2011 standard.
2014-09-21 17:33:12 +00:00
< / p > < / div > < div class = "navfooter" > < hr / > < table width = "100%" summary = "Navigation footer" > < tr > < td width = "40%" align = "left" > < a accesskey = "p" href = "ext_algorithms.html" > Prev< / a > < / td > < td width = "20%" align = "center" > < a accesskey = "u" href = "extensions.html" > Up< / a > < / td > < td width = "40%" align = "right" > < a accesskey = "n" href = "ext_iterators.html" > Next< / a > < / td > < / tr > < tr > < td width = "40%" align = "left" valign = "top" > Chapter 25. Algorithms < / td > < td width = "20%" align = "center" > < a accesskey = "h" href = "../index.html" > Home< / a > < / td > < td width = "40%" align = "right" valign = "top" > Chapter 27. Iterators< / td > < / tr > < / table > < / div > < / body > < / html >