|
12 | 12 | complex number types, random number generation,
|
13 | 13 | numeric (%
|
14 | 14 | \textit{n}-at-a-time)
|
15 |
| -arrays, generalized numeric algorithms, |
16 |
| -and mathematical functions for floating-point types, |
| 15 | +arrays, generalized numeric algorithms, and |
| 16 | +mathematical constants and functions for floating-point types, |
17 | 17 | as summarized in \tref{numerics.summary}.
|
18 | 18 |
|
19 | 19 | \begin{libsumtab}{Numerics library summary}{numerics.summary}
|
|
24 | 24 | \ref{rand} & Random number generation & \tcode{<random>} \\ \rowsep
|
25 | 25 | \ref{numarray} & Numeric arrays & \tcode{<valarray>} \\ \rowsep
|
26 | 26 | \ref{c.math} & Mathematical functions for floating-point types &
|
27 |
| - \tcode{<cmath>}, \tcode{<cstdlib>} \\ |
| 27 | + \tcode{<cmath>}, \tcode{<cstdlib>} \\ \rowsep |
| 28 | +\ref{numbers} & Numbers & \tcode{<numbers>} \\ |
28 | 29 | \end{libsumtab}
|
29 | 30 |
|
30 | 31 | \rSec1[numeric.requirements]{Numeric type requirements}
|
|
10417 | 10418 | \end{itemdescr}
|
10418 | 10419 |
|
10419 | 10420 | \indextext{mathematical special functions|)}
|
| 10421 | + |
| 10422 | +\rSec1[numbers]{Numbers} |
| 10423 | + |
| 10424 | +\rSec2[numbers.syn]{Header \tcode{<numbers>} synopsis} |
| 10425 | +\indexhdr{numbers}% |
| 10426 | + |
| 10427 | +\begin{codeblock} |
| 10428 | +namespace std { |
| 10429 | + namespace numbers { |
| 10430 | + template<typename T> inline constexpr T e_v = @\unspec@; |
| 10431 | + template<typename T> inline constexpr T log2e_v = @\unspec@; |
| 10432 | + template<typename T> inline constexpr T log10e_v = @\unspec@; |
| 10433 | + template<typename T> inline constexpr T pi_v = @\unspec@; |
| 10434 | + template<typename T> inline constexpr T inv_pi_v = @\unspec@; |
| 10435 | + template<typename T> inline constexpr T inv_sqrtpi_v = @\unspec@; |
| 10436 | + template<typename T> inline constexpr T ln2_v = @\unspec@; |
| 10437 | + template<typename T> inline constexpr T ln10_v = @\unspec@; |
| 10438 | + template<typename T> inline constexpr T sqrt2_v = @\unspec@; |
| 10439 | + template<typename T> inline constexpr T sqrt3_v = @\unspec@; |
| 10440 | + template<typename T> inline constexpr T inv_sqrt3_v = @\unspec@; |
| 10441 | + template<typename T> inline constexpr T egamma_v = @\unspec@; |
| 10442 | + template<typename T> inline constexpr T phi_v = @\unspec@; |
| 10443 | + |
| 10444 | + template<FloatingPoint T> inline constexpr T e_v<T> = @\seebelow@; |
| 10445 | + template<FloatingPoint T> inline constexpr T log2e_v<T> = @\seebelow@; |
| 10446 | + template<FloatingPoint T> inline constexpr T log10e_v<T> = @\seebelow@; |
| 10447 | + template<FloatingPoint T> inline constexpr T pi_v<T> = @\seebelow@; |
| 10448 | + template<FloatingPoint T> inline constexpr T inv_pi_v<T> = @\seebelow@; |
| 10449 | + template<FloatingPoint T> inline constexpr T inv_sqrtpi_v<T> = @\seebelow@; |
| 10450 | + template<FloatingPoint T> inline constexpr T ln2_v<T> = @\seebelow@; |
| 10451 | + template<FloatingPoint T> inline constexpr T ln10_v<T> = @\seebelow@; |
| 10452 | + template<FloatingPoint T> inline constexpr T sqrt2_v<T> = @\seebelow@; |
| 10453 | + template<FloatingPoint T> inline constexpr T sqrt3_v<T> = @\seebelow@; |
| 10454 | + template<FloatingPoint T> inline constexpr T inv_sqrt3_v<T> = @\seebelow@; |
| 10455 | + template<FloatingPoint T> inline constexpr T egamma_v<T> = @\seebelow@; |
| 10456 | + template<FloatingPoint T> inline constexpr T phi_v<T> = @\seebelow@; |
| 10457 | + |
| 10458 | + inline constexpr double e = e_v<double>; |
| 10459 | + inline constexpr double log2e = log2e_v<double>; |
| 10460 | + inline constexpr double log10e = log10e_v<double>; |
| 10461 | + inline constexpr double pi = pi_v<double>; |
| 10462 | + inline constexpr double inv_pi = inv_pi_v<double>; |
| 10463 | + inline constexpr double inv_sqrtpi = inv_sqrtpi_v<double>; |
| 10464 | + inline constexpr double ln2 = ln2_v<double>; |
| 10465 | + inline constexpr double ln10 = ln10_v<double>; |
| 10466 | + inline constexpr double sqrt2 = sqrt2_v<double>; |
| 10467 | + inline constexpr double sqrt3 = sqrt3_v<double>; |
| 10468 | + inline constexpr double inv_sqrt3 = inv_sqrt3_v<double>; |
| 10469 | + inline constexpr double egmma = egamma_v<double>; |
| 10470 | + inline constexpr double phi = phi_v<double>; |
| 10471 | + } |
| 10472 | +} |
| 10473 | +\end{codeblock} |
| 10474 | + |
| 10475 | +\rSec2[math.constants]{Mathematical constants} |
| 10476 | + |
| 10477 | +\pnum |
| 10478 | +The library-defined partial specializations of math constant variable templates |
| 10479 | +are initialized with the nearest representable values of |
| 10480 | +$\mathrm{e}$, |
| 10481 | +$\log_{2} \mathrm{e}$, |
| 10482 | +$\log_{10} \mathrm{e}$, |
| 10483 | +$\pi$, |
| 10484 | +$\frac{1}{\pi}$, |
| 10485 | +$\frac{1}{\sqrt{\pi}}$, |
| 10486 | +$\ln 2$, |
| 10487 | +$\ln 10$, |
| 10488 | +$\sqrt{2}$, |
| 10489 | +$\sqrt{3}$, |
| 10490 | +$\frac{1}{\sqrt{3}}$, |
| 10491 | +the Euler-Mascheroni $\gamma$ constant, and |
| 10492 | +the golden ratio $\phi$ constant $\frac{1+\sqrt{5}}{2}$, |
| 10493 | +respectively. |
| 10494 | + |
| 10495 | +\pnum |
| 10496 | +Pursuant to \ref{namespace.std}, |
| 10497 | +a program may partially or explicitly specialize |
| 10498 | +a math constant variable template |
| 10499 | +provided that the specialization depends on a program-defined type. |
| 10500 | + |
| 10501 | +\pnum |
| 10502 | +A program that instantiates a primary template |
| 10503 | +of a math constant variable template is ill-formed. |
0 commit comments