From Jason Turner

[numerics]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpn4bg2l_b/{from.md → to.md} +133 -80
tmp/tmpn4bg2l_b/{from.md → to.md} RENAMED
@@ -195,30 +195,30 @@ namespace std {
195
  template<class T> complex<T> operator/(const T&, const complex<T>&);
196
 
197
  template<class T> complex<T> operator+(const complex<T>&);
198
  template<class T> complex<T> operator-(const complex<T>&);
199
 
200
- template<class T> bool operator==(
201
  const complex<T>&, const complex<T>&);
202
- template<class T> bool operator==(const complex<T>&, const T&);
203
- template<class T> bool operator==(const T&, const complex<T>&);
204
 
205
- template<class T> bool operator!=(const complex<T>&, const complex<T>&);
206
- template<class T> bool operator!=(const complex<T>&, const T&);
207
- template<class T> bool operator!=(const T&, const complex<T>&);
208
 
209
  template<class T, class charT, class traits>
210
  basic_istream<charT, traits>&
211
  operator>>(basic_istream<charT, traits>&, complex<T>&);
212
 
213
  template<class T, class charT, class traits>
214
  basic_ostream<charT, traits>&
215
  operator<<(basic_ostream<charT, traits>&, const complex<T>&);
216
 
217
  // [complex.value.ops], values:
218
- template<class T> T real(const complex<T>&);
219
- template<class T> T imag(const complex<T>&);
220
 
221
  template<class T> T abs(const complex<T>&);
222
  template<class T> T arg(const complex<T>&);
223
  template<class T> T norm(const complex<T>&);
224
 
@@ -248,10 +248,22 @@ namespace std {
248
  template<class T> complex<T> sin (const complex<T>&);
249
  template<class T> complex<T> sinh (const complex<T>&);
250
  template<class T> complex<T> sqrt (const complex<T>&);
251
  template<class T> complex<T> tan (const complex<T>&);
252
  template<class T> complex<T> tanh (const complex<T>&);
 
 
 
 
 
 
 
 
 
 
 
 
253
  }
254
  ```
255
 
256
  ### Class template `complex` <a id="complex">[[complex]]</a>
257
 
@@ -260,17 +272,17 @@ namespace std {
260
  template<class T>
261
  class complex {
262
  public:
263
  typedef T value_type;
264
 
265
- complex(const T& re = T(), const T& im = T());
266
- complex(const complex&);
267
- template<class X> complex(const complex<X>&);
268
 
269
- T real() const;
270
  void real(T);
271
- T imag() const;
272
  void imag(T);
273
 
274
  complex<T>& operator= (const T&);
275
  complex<T>& operator+=(const T&);
276
  complex<T>& operator-=(const T&);
@@ -297,16 +309,16 @@ namespace std {
297
  template<> class complex<float> {
298
  public:
299
  typedef float value_type;
300
 
301
  constexpr complex(float re = 0.0f, float im = 0.0f);
302
- explicit constexpr complex(const complex<double>&);
303
- explicit constexpr complex(const complex<long double>&);
304
 
305
- constexpr float real();
306
  void real(float);
307
- constexpr float imag();
308
  void imag(float);
309
 
310
  complex<float>& operator= (float);
311
  complex<float>& operator+=(float);
312
  complex<float>& operator-=(float);
@@ -325,15 +337,15 @@ namespace std {
325
  public:
326
  typedef double value_type;
327
 
328
  constexpr complex(double re = 0.0, double im = 0.0);
329
  constexpr complex(const complex<float>&);
330
- explicit constexpr complex(const complex<long double>&);
331
 
332
- constexpr double real();
333
  void real(double);
334
- constexpr double imag();
335
  void imag(double);
336
 
337
  complex<double>& operator= (double);
338
  complex<double>& operator+=(double);
339
  complex<double>& operator-=(double);
@@ -354,13 +366,13 @@ namespace std {
354
 
355
  constexpr complex(long double re = 0.0L, long double im = 0.0L);
356
  constexpr complex(const complex<float>&);
357
  constexpr complex(const complex<double>&);
358
 
359
- constexpr long double real();
360
  void real(long double);
361
- constexpr long double imag();
362
  void imag(long double);
363
 
364
  complex<long double>& operator=(const complex<long double>&);
365
  complex<long double>& operator= (long double);
366
  complex<long double>& operator+=(long double);
@@ -378,19 +390,19 @@ namespace std {
378
  ```
379
 
380
  ### `complex` member functions <a id="complex.members">[[complex.members]]</a>
381
 
382
  ``` cpp
383
- template<class T> complex(const T& re = T(), const T& im = T());
384
  ```
385
 
386
  *Effects:* Constructs an object of class `complex`.
387
 
388
  `real() == re && imag() == im`.
389
 
390
  ``` cpp
391
- T real() const;
392
  ```
393
 
394
  *Returns:* The value of the real component.
395
 
396
  ``` cpp
@@ -398,11 +410,11 @@ void real(T val);
398
  ```
399
 
400
  *Effects:* Assigns `val` to the real component.
401
 
402
  ``` cpp
403
- T imag() const;
404
  ```
405
 
406
  *Returns:* The value of the imaginary component.
407
 
408
  ``` cpp
@@ -450,38 +462,38 @@ complex<T>& operator/=(const T& rhs);
450
  and stores the result in `*this`.
451
 
452
  *Returns:* `*this`.
453
 
454
  ``` cpp
455
- complex<T>& operator+=(const complex<T>& rhs);
456
  ```
457
 
458
  *Effects:* Adds the complex value `rhs` to the complex value `*this` and
459
  stores the sum in `*this`.
460
 
461
  *Returns:* `*this`.
462
 
463
  ``` cpp
464
- complex<T>& operator-=(const complex<T>& rhs);
465
  ```
466
 
467
  *Effects:* Subtracts the complex value `rhs` from the complex value
468
  `*this` and stores the difference in `*this`.
469
 
470
  *Returns:* `*this`.
471
 
472
  ``` cpp
473
- complex<T>& operator*=(const complex<T>& rhs);
474
  ```
475
 
476
  *Effects:* Multiplies the complex value `rhs` by the complex value
477
  `*this` and stores the product in `*this`.
478
 
479
  *Returns:* `*this`.
480
 
481
  ``` cpp
482
- complex<T>& operator/=(const complex<T>& rhs);
483
  ```
484
 
485
  *Effects:* Divides the complex value `rhs` into the complex value
486
  `*this` and stores the quotient in `*this`.
487
 
@@ -541,25 +553,25 @@ template<class T> complex<T> operator/(const T& lhs, const complex<T>& rhs);
541
 
542
  *Returns:* `complex<T>(lhs) /= rhs`.
543
 
544
  ``` cpp
545
  template<class T>
546
- bool operator==(const complex<T>& lhs, const complex<T>& rhs);
547
- template<class T> bool operator==(const complex<T>& lhs, const T& rhs);
548
- template<class T> bool operator==(const T& lhs, const complex<T>& rhs);
549
  ```
550
 
551
  *Returns:* `lhs.real() == rhs.real() && lhs.imag() == rhs.imag()`.
552
 
553
  *Remarks:* The imaginary part is assumed to be `T()`, or 0.0, for the
554
  `T` arguments.
555
 
556
  ``` cpp
557
  template<class T>
558
- bool operator!=(const complex<T>& lhs, const complex<T>& rhs);
559
- template<class T> bool operator!=(const complex<T>& lhs, const T& rhs);
560
- template<class T> bool operator!=(const T& lhs, const complex<T>& rhs);
561
  ```
562
 
563
  *Returns:* `rhs.real() != lhs.real() || rhs.imag() != lhs.imag()`.
564
 
565
  ``` cpp
@@ -612,17 +624,17 @@ explicit decimal point character; as a result, all inserted sequences of
612
  complex numbers can be extracted unambiguously.
613
 
614
  ### `complex` value operations <a id="complex.value.ops">[[complex.value.ops]]</a>
615
 
616
  ``` cpp
617
- template<class T> T real(const complex<T>& x);
618
  ```
619
 
620
  *Returns:* `x.real()`.
621
 
622
  ``` cpp
623
- template<class T> T imag(const complex<T>& x);
624
  ```
625
 
626
  *Returns:* `x.imag()`.
627
 
628
  ``` cpp
@@ -829,10 +841,39 @@ ensure, for a call with at least one argument of type `complex<T>`:
829
  or an integer type, then both arguments are effectively cast to
830
  `complex<double>`.
831
  3. Otherwise, if either argument has type `complex<float>` or `float`,
832
  then both arguments are effectively cast to `complex<float>`.
833
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
834
  ### Header `<ccomplex>` <a id="ccmplx">[[ccmplx]]</a>
835
 
836
  The header behaves as if it simply includes the header `<complex>`.
837
 
838
  ## Random number generation <a id="rand">[[rand]]</a>
@@ -1045,11 +1086,11 @@ It is unspecified whether `D::param_type` is declared as a (nested)
1045
  `D::param_type` are in the form of `typedef`s for convenience of
1046
  exposition only.
1047
 
1048
  `P` shall satisfy the requirements of `CopyConstructible` (Table 
1049
  [[copyconstructible]]), `CopyAssignable` (Table  [[copyassignable]]),
1050
- and EqualityComparable (Table  [[equalitycomparable]]) types.
1051
 
1052
  For each of the constructors of `D` taking arguments corresponding to
1053
  parameters of the distribution, `P` shall have a corresponding
1054
  constructor subject to the same requirements and taking arguments
1055
  identical in number, type, and default values. Moreover, for each of the
@@ -1074,13 +1115,13 @@ namespace std {
1074
  template<class UIntType, UIntType a, UIntType c, UIntType m>
1075
  class linear_congruential_engine;
1076
 
1077
  // [rand.eng.mers], class template mersenne_twister_engine
1078
  template<class UIntType, size_t w, size_t n, size_t m, size_t r,
1079
- UIntType a, size_t u, UintType d, size_t s,
1080
  UIntType b, size_t t,
1081
- UIntType c, size_t l, UintType f>
1082
  class mersenne_twister_engine;
1083
 
1084
  // [rand.eng.sub], class template subtract_with_carry_engine
1085
  template<class UIntType, size_t w, size_t s, size_t r>
1086
  class subtract_with_carry_engine;
@@ -1268,12 +1309,12 @@ public:
1268
 
1269
  // engine characteristics
1270
  static constexpr result_type multiplier = a;
1271
  static constexpr result_type increment = c;
1272
  static constexpr result_type modulus = m;
1273
- static constexpr result_type min() { return c == 0u ? 1u: 0u };
1274
- static constexpr result_type max() { return m - 1u };
1275
  static constexpr result_type default_seed = 1u;
1276
 
1277
  // constructors and seeding functions
1278
  explicit linear_congruential_engine(result_type s = default_seed);
1279
  template<class Sseq> explicit linear_congruential_engine(Sseq& q);
@@ -1799,11 +1840,11 @@ typedef discard_block_engine<ranlux24_base, 223, 23>
1799
  default-constructed object of type `ranlux24` shall produce the value
1800
  9901578.
1801
 
1802
  ``` cpp
1803
  typedef discard_block_engine<ranlux48_base, 389, 11>
1804
- ranlux48@
1805
  ```
1806
 
1807
  *Required behavior:* The $10000^{\,th}$ consecutive invocation of a
1808
  default-constructed object of type `ranlux48` shall produce the value
1809
  249142670248501.
@@ -1897,13 +1938,10 @@ these values are generated.
1897
 
1898
  ### Utilities <a id="rand.util">[[rand.util]]</a>
1899
 
1900
  #### Class `seed_seq` <a id="rand.util.seedseq">[[rand.util.seedseq]]</a>
1901
 
1902
- No function described in this section  [[rand.util.seedseq]] throws an
1903
- exception.
1904
-
1905
  ``` cpp
1906
  class seed_seq
1907
  {
1908
  public:
1909
  // types
@@ -1939,10 +1977,12 @@ seed_seq();
1939
  ```
1940
 
1941
  *Effects:* Constructs a `seed_seq` object as if by default-constructing
1942
  its member `v`.
1943
 
 
 
1944
  ``` cpp
1945
  template<class T>
1946
  seed_seq(initializer_list<T> il);
1947
  ```
1948
 
@@ -1983,18 +2023,23 @@ s = `v.size()` and n = `end` - `begin`, fills the supplied range
1983
  [`begin`,`end`) according to the following algorithm in which each
1984
  operation is to be carried out modulo 2³², each indexing operator
1985
  applied to `begin` is to be taken modulo n, and T(x) is defined as
1986
  $x \, \xor \, (x \, \rightshift \, 27)$:
1987
 
 
 
 
1988
  ``` cpp
1989
  size_t size() const;
1990
  ```
1991
 
1992
  *Returns:* The number of 32-bit units that would be returned by a call
1993
  to `param()`.
1994
 
1995
- *Complexity:* constant time.
 
 
1996
 
1997
  ``` cpp
1998
  template<class OutputIterator>
1999
  void param(OutputIterator dest) const;
2000
  ```
@@ -2009,10 +2054,12 @@ destination, as if by executing the following statement:
2009
 
2010
  ``` cpp
2011
  copy(v.begin(), v.end(), dest);
2012
  ```
2013
 
 
 
2014
  #### Function template `generate_canonical` <a id="rand.util.canonical">[[rand.util.canonical]]</a>
2015
 
2016
  Each function instantiated from the template described in this section 
2017
  [[rand.util.canonical]] maps the result of one or more invocations of a
2018
  supplied uniform random number generator `g` to one member of the
@@ -2249,11 +2296,11 @@ constructed.
2249
 
2250
  A `binomial_distribution` random number distribution produces integer
2251
  values i ≥ 0 distributed according to the discrete probability function
2252
  $$%
2253
  P(i\,|\,t,p)
2254
- = {t \choose i} \cdot p^i \cdot (1-p)^{t-i}
2255
  \; \mbox{.}$$
2256
 
2257
  ``` cpp
2258
  template<class IntType = int>
2259
  class binomial_distribution
@@ -2365,11 +2412,11 @@ constructed.
2365
 
2366
  A `negative_binomial_distribution` random number distribution produces
2367
  random integers i ≥ 0 distributed according to the discrete probability
2368
  function $$%
2369
  P(i\,|\,k,p)
2370
- = {k+i-1 \choose i} \cdot p^k \cdot (1-p)^i
2371
  \; \mbox{.}$$
2372
 
2373
  ``` cpp
2374
  template<class IntType = int>
2375
  class negative_binomial_distribution
@@ -2539,13 +2586,11 @@ constructed.
2539
 
2540
  A `gamma_distribution` random number distribution produces random
2541
  numbers x > 0 distributed according to the probability density function
2542
  $$%
2543
  p(x\,|\,\alpha,\beta)
2544
- = { e^{-x/\beta}
2545
- \over {\beta^{\alpha} \cdot \Gamma(\alpha)}
2546
- }
2547
  \, \cdot \, x^{\, \alpha-1}
2548
  \; \mbox{.}$$
2549
 
2550
  ``` cpp
2551
  template<class RealType = double>
@@ -2619,11 +2664,11 @@ public:
2619
  // types
2620
  typedef RealType result_type;
2621
  typedef unspecified param_type;
2622
 
2623
  // constructor and reset functions
2624
- explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0)
2625
  explicit weibull_distribution(const param_type& parm);
2626
  void reset();
2627
 
2628
  // generating functions
2629
  template<class URNG>
@@ -2734,11 +2779,11 @@ constructed.
2734
  ##### Class template `normal_distribution` <a id="rand.dist.norm.normal">[[rand.dist.norm.normal]]</a>
2735
 
2736
  A `normal_distribution` random number distribution produces random
2737
  numbers x distributed according to the probability density function $$%
2738
  p(x\,|\,\mu,\sigma)
2739
- = {1 \over \sigma \sqrt{2\pi}}
2740
  \cdot
2741
  % e^{-(x-\mu)^2 / (2\sigma^2)}
2742
  \exp{\left(- \, \frac{(x - \mu)^2}
2743
  {2 \sigma^2}
2744
  \right)
@@ -3228,11 +3273,11 @@ $$%
3228
  The n+1 distribution parameters bᵢ, also known as this distribution’s
3229
  *interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
3230
  i = 0, …, n-1. Unless specified otherwise, the remaining n distribution
3231
  parameters are calculated as: $$%
3232
  \rho_k = \;
3233
- {w_k \over {S \cdot (b_{k+1}-b_k)}}
3234
  \; \mbox{ for } k = 0, \ldots, n\!-\!1,$$ in which the values wₖ,
3235
  commonly known as the *weights* , shall be non-negative, non-NaN, and
3236
  non-infinity. Moreover, the following relation shall hold:
3237
  0 < S = w₀ + ⋯ + wₙ₋₁.
3238
 
@@ -3356,12 +3401,12 @@ k = 0, …, n-1.
3356
 
3357
  A `piecewise_linear_distribution` random number distribution produces
3358
  random numbers x, b₀ ≤ x < bₙ, distributed over each subinterval
3359
  [ bᵢ, bᵢ₊₁ ) according to the probability density function $$%
3360
  p(x\,|\,b_0,\ldots,b_n,\;\rho_0,\ldots,\rho_n)
3361
- = \rho_i \cdot {{b_{i+1} - x} \over {b_{i+1} - b_i}}
3362
- + \rho_{i+1} \cdot {{x - b_i} \over {b_{i+1} - b_i}}
3363
  \; \mbox{,}
3364
  \mbox{ for } b_i \le x < b_{i+1}
3365
  \; \mbox{.}$$
3366
 
3367
  The n+1 distribution parameters bᵢ, also known as this distribution’s
@@ -3631,12 +3676,13 @@ not add more than two levels of template nesting over the most deeply
3631
  nested argument type.[^7]
3632
 
3633
  Implementations introducing such replacement types shall provide
3634
  additional functions and operators as follows:
3635
 
3636
- - for every function taking a `const valarray<T>&`, identical functions
3637
- taking the replacement types shall be added;
 
3638
  - for every function taking two `const valarray<T>&` arguments,
3639
  identical functions taking every combination of `const valarray<T>&`
3640
  and replacement types shall be added.
3641
 
3642
  In particular, an implementation shall allow a `valarray<T>` to be
@@ -3845,16 +3891,14 @@ the assignment.
3845
 
3846
  ``` cpp
3847
  valarray<T>& operator=(valarray<T>&& v) noexcept;
3848
  ```
3849
 
3850
- *Effects:* `*this` obtains the value of `v`. If the length of `v` is not
3851
- equal to the length of `*this`, resizes `*this` to make the two arrays
3852
- the same length, as if by calling `resize(v.size())`, before performing
3853
- the assignment.
3854
 
3855
- *Complexity:* Constant.
3856
 
3857
  ``` cpp
3858
  valarray& operator=(initializer_list<T> il);
3859
  ```
3860
 
@@ -3908,12 +3952,12 @@ Likewise, the expression `&a[i] != &b[j]` evaluates as `true` for any
3908
  two arrays `a` and `b` and for any `size_t i` and `size_t j` such that
3909
  `i` is less than the length of `a` and `j` is less than the length of
3910
  `b`. This property indicates an absence of aliasing and may be used to
3911
  advantage by optimizing compilers.[^13]
3912
 
3913
- The reference returned by the subscript operator for an array is
3914
- guaranteed to be valid until the member function
3915
  `resize(size_t, T)` ([[valarray.members]]) is called for that array or
3916
  until the lifetime of that array ends, whichever happens first.
3917
 
3918
  If the subscript operator is invoked with a `size_t` argument whose
3919
  value is not less than the length of the array, the behavior is
@@ -4138,11 +4182,11 @@ void swap(valarray& v) noexcept;
4138
  size_t size() const;
4139
  ```
4140
 
4141
  *Returns:* The number of elements in the array.
4142
 
4143
- *Complexity:* constant time.
4144
 
4145
  ``` cpp
4146
  T sum() const;
4147
  ```
4148
 
@@ -4412,11 +4456,11 @@ size_t size() const;
4412
  size_t stride() const;
4413
  ```
4414
 
4415
  *Returns:* The start, length, or stride specified by a `slice` object.
4416
 
4417
- *Complexity:* constant time.
4418
 
4419
  ### Class template `slice_array` <a id="template.slice.array">[[template.slice.array]]</a>
4420
 
4421
  #### Class template `slice_array` overview <a id="template.slice.array.overview">[[template.slice.array.overview]]</a>
4422
 
@@ -4864,10 +4908,15 @@ iterator ([[random.access.iterators]]) whose `value_type` is the
4864
  template parameter `T` and whose `reference` type is `T&`.
4865
  *unspecified*2 is a type that meets the requirements of a constant
4866
  random access iterator ([[random.access.iterators]]) whose `value_type`
4867
  is the template parameter `T` and whose `reference` type is `const T&`.
4868
 
 
 
 
 
 
4869
  ``` cpp
4870
  template <class T> unspecified{1} begin(valarray<T>& v);
4871
  template <class T> unspecified{2} begin(const valarray<T>& v);
4872
  ```
4873
 
@@ -5036,11 +5085,11 @@ template <class InputIterator, class OutputIterator, class BinaryOperation>
5036
 
5037
  *Effects:* For a non-empty range, the function creates an accumulator
5038
  `acc` whose type is `InputIterator`’s value type, initializes it with
5039
  `*first`, and assigns the result to `*result`. For every iterator `i` in
5040
  \[`first + 1`, `last`) in order, creates an object `val` whose type is
5041
- `InputIterator`’s value type, initializes it with \*i, computes
5042
  `val - acc` or `binary_op(val, acc)`, assigns the result to
5043
  `*(result + (i - first))`, and move assigns from `val` to `acc`.
5044
 
5045
  *Requires:* `InputIterator`’s value type shall be `MoveAssignable`
5046
  (Table  [[moveassignable]]) and shall be constructible from the type of
@@ -5076,12 +5125,12 @@ The expression `++val`, where `val` has type `T`, shall be well formed.
5076
  ## C library <a id="c.math">[[c.math]]</a>
5077
 
5078
  The header `<ctgmath>` simply includes the headers `<ccomplex>` and
5079
  `<cmath>`.
5080
 
5081
- The overloads provided in C by magic macros are already provided in
5082
- `<ccomplex>` and `<cmath>` by “sufficient” additional overloads.
5083
 
5084
  Tables  [[tab:numerics.hdr.cmath]] and  [[tab:numerics.hdr.cstdlib]]
5085
  describe headers `<cmath>` and `<cstdlib>`, respectively.
5086
 
5087
  The contents of these headers are the same as the Standard C library
@@ -5091,11 +5140,13 @@ changes:
5091
  The `rand` function has the semantics specified in the C standard,
5092
  except that the implementation may specify that particular library
5093
  functions may call `rand`. It is implementation-defined whether the
5094
  `rand` function may introduce data races ([[res.on.data.races]]). The
5095
  random number generation ([[rand]]) facilities in this standard are
5096
- often preferable to `rand`.
 
 
5097
 
5098
  In addition to the `int` versions of certain math functions in
5099
  `<cstdlib>`, C++adds `long` and `long long` overloaded versions of these
5100
  functions, with the same semantics.
5101
 
@@ -5283,18 +5334,19 @@ bool islessgreater(long double x, long double y);
5283
  bool isunordered(long double x, long double y);
5284
  ```
5285
 
5286
  Moreover, there shall be additional overloads sufficient to ensure:
5287
 
5288
- 1. If any argument corresponding to a `double` parameter has type
5289
- `long double`, then all arguments corresponding to `double`
5290
- parameters are effectively cast to `long double`.
5291
- 2. Otherwise, if any argument corresponding to a `double` parameter has
5292
- type `double` or an integer type, then all arguments corresponding
5293
- to `double` parameters are effectively cast to `double`.
5294
- 3. Otherwise, all arguments corresponding to `double` parameters are
5295
- effectively cast to `float`.
 
5296
 
5297
  ISO C 7.5, 7.10.2, 7.10.6.
5298
 
5299
  <!-- Link reference definitions -->
5300
  [accumulate]: #accumulate
@@ -5312,10 +5364,11 @@ ISO C 7.5, 7.10.2, 7.10.6.
5312
  [class.gslice.overview]: #class.gslice.overview
5313
  [class.slice]: #class.slice
5314
  [class.slice.overview]: #class.slice.overview
5315
  [cmplx.over]: #cmplx.over
5316
  [complex]: #complex
 
5317
  [complex.member.ops]: #complex.member.ops
5318
  [complex.members]: #complex.members
5319
  [complex.numbers]: #complex.numbers
5320
  [complex.ops]: #complex.ops
5321
  [complex.special]: #complex.special
 
195
  template<class T> complex<T> operator/(const T&, const complex<T>&);
196
 
197
  template<class T> complex<T> operator+(const complex<T>&);
198
  template<class T> complex<T> operator-(const complex<T>&);
199
 
200
+ template<class T> constexpr bool operator==(
201
  const complex<T>&, const complex<T>&);
202
+ template<class T> constexpr bool operator==(const complex<T>&, const T&);
203
+ template<class T> constexpr bool operator==(const T&, const complex<T>&);
204
 
205
+ template<class T> constexpr bool operator!=(const complex<T>&, const complex<T>&);
206
+ template<class T> constexpr bool operator!=(const complex<T>&, const T&);
207
+ template<class T> constexpr bool operator!=(const T&, const complex<T>&);
208
 
209
  template<class T, class charT, class traits>
210
  basic_istream<charT, traits>&
211
  operator>>(basic_istream<charT, traits>&, complex<T>&);
212
 
213
  template<class T, class charT, class traits>
214
  basic_ostream<charT, traits>&
215
  operator<<(basic_ostream<charT, traits>&, const complex<T>&);
216
 
217
  // [complex.value.ops], values:
218
+ template<class T> constexpr T real(const complex<T>&);
219
+ template<class T> constexpr T imag(const complex<T>&);
220
 
221
  template<class T> T abs(const complex<T>&);
222
  template<class T> T arg(const complex<T>&);
223
  template<class T> T norm(const complex<T>&);
224
 
 
248
  template<class T> complex<T> sin (const complex<T>&);
249
  template<class T> complex<T> sinh (const complex<T>&);
250
  template<class T> complex<T> sqrt (const complex<T>&);
251
  template<class T> complex<T> tan (const complex<T>&);
252
  template<class T> complex<T> tanh (const complex<T>&);
253
+
254
+ // [complex.literals], complex literals:
255
+ inline namespace literals {
256
+ inline namespace complex_literals {
257
+ constexpr complex<long double> operator""il(long double);
258
+ constexpr complex<long double> operator""il(unsigned long long);
259
+ constexpr complex<double> operator""i(long double);
260
+ constexpr complex<double> operator""i(unsigned long long);
261
+ constexpr complex<float> operator""if(long double);
262
+ constexpr complex<float> operator""if(unsigned long long);
263
+ }
264
+ }
265
  }
266
  ```
267
 
268
  ### Class template `complex` <a id="complex">[[complex]]</a>
269
 
 
272
  template<class T>
273
  class complex {
274
  public:
275
  typedef T value_type;
276
 
277
+ constexpr complex(const T& re = T(), const T& im = T());
278
+ constexpr complex(const complex&);
279
+ template<class X> constexpr complex(const complex<X>&);
280
 
281
+ constexpr T real() const;
282
  void real(T);
283
+ constexpr T imag() const;
284
  void imag(T);
285
 
286
  complex<T>& operator= (const T&);
287
  complex<T>& operator+=(const T&);
288
  complex<T>& operator-=(const T&);
 
309
  template<> class complex<float> {
310
  public:
311
  typedef float value_type;
312
 
313
  constexpr complex(float re = 0.0f, float im = 0.0f);
314
+ constexpr explicit complex(const complex<double>&);
315
+ constexpr explicit complex(const complex<long double>&);
316
 
317
+ constexpr float real() const;
318
  void real(float);
319
+ constexpr float imag() const;
320
  void imag(float);
321
 
322
  complex<float>& operator= (float);
323
  complex<float>& operator+=(float);
324
  complex<float>& operator-=(float);
 
337
  public:
338
  typedef double value_type;
339
 
340
  constexpr complex(double re = 0.0, double im = 0.0);
341
  constexpr complex(const complex<float>&);
342
+ constexpr explicit complex(const complex<long double>&);
343
 
344
+ constexpr double real() const;
345
  void real(double);
346
+ constexpr double imag() const;
347
  void imag(double);
348
 
349
  complex<double>& operator= (double);
350
  complex<double>& operator+=(double);
351
  complex<double>& operator-=(double);
 
366
 
367
  constexpr complex(long double re = 0.0L, long double im = 0.0L);
368
  constexpr complex(const complex<float>&);
369
  constexpr complex(const complex<double>&);
370
 
371
+ constexpr long double real() const;
372
  void real(long double);
373
+ constexpr long double imag() const;
374
  void imag(long double);
375
 
376
  complex<long double>& operator=(const complex<long double>&);
377
  complex<long double>& operator= (long double);
378
  complex<long double>& operator+=(long double);
 
390
  ```
391
 
392
  ### `complex` member functions <a id="complex.members">[[complex.members]]</a>
393
 
394
  ``` cpp
395
+ template<class T> constexpr complex(const T& re = T(), const T& im = T());
396
  ```
397
 
398
  *Effects:* Constructs an object of class `complex`.
399
 
400
  `real() == re && imag() == im`.
401
 
402
  ``` cpp
403
+ constexpr T real() const;
404
  ```
405
 
406
  *Returns:* The value of the real component.
407
 
408
  ``` cpp
 
410
  ```
411
 
412
  *Effects:* Assigns `val` to the real component.
413
 
414
  ``` cpp
415
+ constexpr T imag() const;
416
  ```
417
 
418
  *Returns:* The value of the imaginary component.
419
 
420
  ``` cpp
 
462
  and stores the result in `*this`.
463
 
464
  *Returns:* `*this`.
465
 
466
  ``` cpp
467
+ template<class X> complex<T>& operator+=(const complex<X>& rhs);
468
  ```
469
 
470
  *Effects:* Adds the complex value `rhs` to the complex value `*this` and
471
  stores the sum in `*this`.
472
 
473
  *Returns:* `*this`.
474
 
475
  ``` cpp
476
+ template<class X> complex<T>& operator-=(const complex<X>& rhs);
477
  ```
478
 
479
  *Effects:* Subtracts the complex value `rhs` from the complex value
480
  `*this` and stores the difference in `*this`.
481
 
482
  *Returns:* `*this`.
483
 
484
  ``` cpp
485
+ template<class X> complex<T>& operator*=(const complex<X>& rhs);
486
  ```
487
 
488
  *Effects:* Multiplies the complex value `rhs` by the complex value
489
  `*this` and stores the product in `*this`.
490
 
491
  *Returns:* `*this`.
492
 
493
  ``` cpp
494
+ template<class X> complex<T>& operator/=(const complex<X>& rhs);
495
  ```
496
 
497
  *Effects:* Divides the complex value `rhs` into the complex value
498
  `*this` and stores the quotient in `*this`.
499
 
 
553
 
554
  *Returns:* `complex<T>(lhs) /= rhs`.
555
 
556
  ``` cpp
557
  template<class T>
558
+ constexpr bool operator==(const complex<T>& lhs, const complex<T>& rhs);
559
+ template<class T> constexpr bool operator==(const complex<T>& lhs, const T& rhs);
560
+ template<class T> constexpr bool operator==(const T& lhs, const complex<T>& rhs);
561
  ```
562
 
563
  *Returns:* `lhs.real() == rhs.real() && lhs.imag() == rhs.imag()`.
564
 
565
  *Remarks:* The imaginary part is assumed to be `T()`, or 0.0, for the
566
  `T` arguments.
567
 
568
  ``` cpp
569
  template<class T>
570
+ constexpr bool operator!=(const complex<T>& lhs, const complex<T>& rhs);
571
+ template<class T> constexpr bool operator!=(const complex<T>& lhs, const T& rhs);
572
+ template<class T> constexpr bool operator!=(const T& lhs, const complex<T>& rhs);
573
  ```
574
 
575
  *Returns:* `rhs.real() != lhs.real() || rhs.imag() != lhs.imag()`.
576
 
577
  ``` cpp
 
624
  complex numbers can be extracted unambiguously.
625
 
626
  ### `complex` value operations <a id="complex.value.ops">[[complex.value.ops]]</a>
627
 
628
  ``` cpp
629
+ template<class T> constexpr T real(const complex<T>& x);
630
  ```
631
 
632
  *Returns:* `x.real()`.
633
 
634
  ``` cpp
635
+ template<class T> constexpr T imag(const complex<T>& x);
636
  ```
637
 
638
  *Returns:* `x.imag()`.
639
 
640
  ``` cpp
 
841
  or an integer type, then both arguments are effectively cast to
842
  `complex<double>`.
843
  3. Otherwise, if either argument has type `complex<float>` or `float`,
844
  then both arguments are effectively cast to `complex<float>`.
845
 
846
+ ### Suffixes for complex number literals <a id="complex.literals">[[complex.literals]]</a>
847
+
848
+ This section describes literal suffixes for constructing complex number
849
+ literals. The suffixes `i`, `il`, and `if` create complex numbers of the
850
+ types `complex<double>`, `complex<long double>`, and `complex<float>`
851
+ respectively, with their imaginary part denoted by the given literal
852
+ number and the real part being zero.
853
+
854
+ ``` cpp
855
+ constexpr complex<long double> operator""il(long double d);
856
+ constexpr complex<long double> operator""il(unsigned long long d);
857
+ ```
858
+
859
+ *Returns:* `complex<long double>{0.0L, static_cast<long double>(d)}`.
860
+
861
+ ``` cpp
862
+ constexpr complex<double> operator""i(long double d);
863
+ constexpr complex<double> operator""i(unsigned long long d);
864
+ ```
865
+
866
+ *Returns:* `complex<double>{0.0, static_cast<double>(d)}`.
867
+
868
+ ``` cpp
869
+ constexpr complex<float> operator""if(long double d);
870
+ constexpr complex<float> operator""if(unsigned long long d);
871
+ ```
872
+
873
+ *Returns:* `complex<float>{0.0f, static_cast<float>(d)}`.
874
+
875
  ### Header `<ccomplex>` <a id="ccmplx">[[ccmplx]]</a>
876
 
877
  The header behaves as if it simply includes the header `<complex>`.
878
 
879
  ## Random number generation <a id="rand">[[rand]]</a>
 
1086
  `D::param_type` are in the form of `typedef`s for convenience of
1087
  exposition only.
1088
 
1089
  `P` shall satisfy the requirements of `CopyConstructible` (Table 
1090
  [[copyconstructible]]), `CopyAssignable` (Table  [[copyassignable]]),
1091
+ and `EqualityComparable` (Table  [[equalitycomparable]]) types.
1092
 
1093
  For each of the constructors of `D` taking arguments corresponding to
1094
  parameters of the distribution, `P` shall have a corresponding
1095
  constructor subject to the same requirements and taking arguments
1096
  identical in number, type, and default values. Moreover, for each of the
 
1115
  template<class UIntType, UIntType a, UIntType c, UIntType m>
1116
  class linear_congruential_engine;
1117
 
1118
  // [rand.eng.mers], class template mersenne_twister_engine
1119
  template<class UIntType, size_t w, size_t n, size_t m, size_t r,
1120
+ UIntType a, size_t u, UIntType d, size_t s,
1121
  UIntType b, size_t t,
1122
+ UIntType c, size_t l, UIntType f>
1123
  class mersenne_twister_engine;
1124
 
1125
  // [rand.eng.sub], class template subtract_with_carry_engine
1126
  template<class UIntType, size_t w, size_t s, size_t r>
1127
  class subtract_with_carry_engine;
 
1309
 
1310
  // engine characteristics
1311
  static constexpr result_type multiplier = a;
1312
  static constexpr result_type increment = c;
1313
  static constexpr result_type modulus = m;
1314
+ static constexpr result_type min() { return c == 0u ? 1u: 0u; }
1315
+ static constexpr result_type max() { return m - 1u; }
1316
  static constexpr result_type default_seed = 1u;
1317
 
1318
  // constructors and seeding functions
1319
  explicit linear_congruential_engine(result_type s = default_seed);
1320
  template<class Sseq> explicit linear_congruential_engine(Sseq& q);
 
1840
  default-constructed object of type `ranlux24` shall produce the value
1841
  9901578.
1842
 
1843
  ``` cpp
1844
  typedef discard_block_engine<ranlux48_base, 389, 11>
1845
+ ranlux48;
1846
  ```
1847
 
1848
  *Required behavior:* The $10000^{\,th}$ consecutive invocation of a
1849
  default-constructed object of type `ranlux48` shall produce the value
1850
  249142670248501.
 
1938
 
1939
  ### Utilities <a id="rand.util">[[rand.util]]</a>
1940
 
1941
  #### Class `seed_seq` <a id="rand.util.seedseq">[[rand.util.seedseq]]</a>
1942
 
 
 
 
1943
  ``` cpp
1944
  class seed_seq
1945
  {
1946
  public:
1947
  // types
 
1977
  ```
1978
 
1979
  *Effects:* Constructs a `seed_seq` object as if by default-constructing
1980
  its member `v`.
1981
 
1982
+ *Throws:* Nothing.
1983
+
1984
  ``` cpp
1985
  template<class T>
1986
  seed_seq(initializer_list<T> il);
1987
  ```
1988
 
 
2023
  [`begin`,`end`) according to the following algorithm in which each
2024
  operation is to be carried out modulo 2³², each indexing operator
2025
  applied to `begin` is to be taken modulo n, and T(x) is defined as
2026
  $x \, \xor \, (x \, \rightshift \, 27)$:
2027
 
2028
+ *Throws:* What and when `RandomAccessIterator` operations of `begin` and
2029
+ `end` throw.
2030
+
2031
  ``` cpp
2032
  size_t size() const;
2033
  ```
2034
 
2035
  *Returns:* The number of 32-bit units that would be returned by a call
2036
  to `param()`.
2037
 
2038
+ *Throws:* Nothing.
2039
+
2040
+ *Complexity:* Constant time.
2041
 
2042
  ``` cpp
2043
  template<class OutputIterator>
2044
  void param(OutputIterator dest) const;
2045
  ```
 
2054
 
2055
  ``` cpp
2056
  copy(v.begin(), v.end(), dest);
2057
  ```
2058
 
2059
+ *Throws:* What and when `OutputIterator` operations of `dest` throw.
2060
+
2061
  #### Function template `generate_canonical` <a id="rand.util.canonical">[[rand.util.canonical]]</a>
2062
 
2063
  Each function instantiated from the template described in this section 
2064
  [[rand.util.canonical]] maps the result of one or more invocations of a
2065
  supplied uniform random number generator `g` to one member of the
 
2296
 
2297
  A `binomial_distribution` random number distribution produces integer
2298
  values i ≥ 0 distributed according to the discrete probability function
2299
  $$%
2300
  P(i\,|\,t,p)
2301
+ = \binom{t}{i} \cdot p^i \cdot (1-p)^{t-i}
2302
  \; \mbox{.}$$
2303
 
2304
  ``` cpp
2305
  template<class IntType = int>
2306
  class binomial_distribution
 
2412
 
2413
  A `negative_binomial_distribution` random number distribution produces
2414
  random integers i ≥ 0 distributed according to the discrete probability
2415
  function $$%
2416
  P(i\,|\,k,p)
2417
+ = \binom{k+i-1}{i} \cdot p^k \cdot (1-p)^i
2418
  \; \mbox{.}$$
2419
 
2420
  ``` cpp
2421
  template<class IntType = int>
2422
  class negative_binomial_distribution
 
2586
 
2587
  A `gamma_distribution` random number distribution produces random
2588
  numbers x > 0 distributed according to the probability density function
2589
  $$%
2590
  p(x\,|\,\alpha,\beta)
2591
+ = \frac{e^{-x/\beta}}{\beta^{\alpha} \cdot \Gamma(\alpha)}
 
 
2592
  \, \cdot \, x^{\, \alpha-1}
2593
  \; \mbox{.}$$
2594
 
2595
  ``` cpp
2596
  template<class RealType = double>
 
2664
  // types
2665
  typedef RealType result_type;
2666
  typedef unspecified param_type;
2667
 
2668
  // constructor and reset functions
2669
+ explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0);
2670
  explicit weibull_distribution(const param_type& parm);
2671
  void reset();
2672
 
2673
  // generating functions
2674
  template<class URNG>
 
2779
  ##### Class template `normal_distribution` <a id="rand.dist.norm.normal">[[rand.dist.norm.normal]]</a>
2780
 
2781
  A `normal_distribution` random number distribution produces random
2782
  numbers x distributed according to the probability density function $$%
2783
  p(x\,|\,\mu,\sigma)
2784
+ = \frac{1}{\sigma \sqrt{2\pi}}
2785
  \cdot
2786
  % e^{-(x-\mu)^2 / (2\sigma^2)}
2787
  \exp{\left(- \, \frac{(x - \mu)^2}
2788
  {2 \sigma^2}
2789
  \right)
 
3273
  The n+1 distribution parameters bᵢ, also known as this distribution’s
3274
  *interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
3275
  i = 0, …, n-1. Unless specified otherwise, the remaining n distribution
3276
  parameters are calculated as: $$%
3277
  \rho_k = \;
3278
+ \frac{w_k}{S \cdot (b_{k+1}-b_k)}
3279
  \; \mbox{ for } k = 0, \ldots, n\!-\!1,$$ in which the values wₖ,
3280
  commonly known as the *weights* , shall be non-negative, non-NaN, and
3281
  non-infinity. Moreover, the following relation shall hold:
3282
  0 < S = w₀ + ⋯ + wₙ₋₁.
3283
 
 
3401
 
3402
  A `piecewise_linear_distribution` random number distribution produces
3403
  random numbers x, b₀ ≤ x < bₙ, distributed over each subinterval
3404
  [ bᵢ, bᵢ₊₁ ) according to the probability density function $$%
3405
  p(x\,|\,b_0,\ldots,b_n,\;\rho_0,\ldots,\rho_n)
3406
+ = \rho_i \cdot {\frac{b_{i+1} - x}{b_{i+1} - b_i}}
3407
+ + \rho_{i+1} \cdot {\frac{x - b_i}{b_{i+1} - b_i}}
3408
  \; \mbox{,}
3409
  \mbox{ for } b_i \le x < b_{i+1}
3410
  \; \mbox{.}$$
3411
 
3412
  The n+1 distribution parameters bᵢ, also known as this distribution’s
 
3676
  nested argument type.[^7]
3677
 
3678
  Implementations introducing such replacement types shall provide
3679
  additional functions and operators as follows:
3680
 
3681
+ - for every function taking a `const valarray<T>&` other than `begin`
3682
+ and `end` ([[valarray.range]]), identical functions taking the
3683
+ replacement types shall be added;
3684
  - for every function taking two `const valarray<T>&` arguments,
3685
  identical functions taking every combination of `const valarray<T>&`
3686
  and replacement types shall be added.
3687
 
3688
  In particular, an implementation shall allow a `valarray<T>` to be
 
3891
 
3892
  ``` cpp
3893
  valarray<T>& operator=(valarray<T>&& v) noexcept;
3894
  ```
3895
 
3896
+ *Effects:* `*this` obtains the value of `v`. The value of `v` after the
3897
+ assignment is not specified.
 
 
3898
 
3899
+ *Complexity:* Linear.
3900
 
3901
  ``` cpp
3902
  valarray& operator=(initializer_list<T> il);
3903
  ```
3904
 
 
3952
  two arrays `a` and `b` and for any `size_t i` and `size_t j` such that
3953
  `i` is less than the length of `a` and `j` is less than the length of
3954
  `b`. This property indicates an absence of aliasing and may be used to
3955
  advantage by optimizing compilers.[^13]
3956
 
3957
+ The reference returned by the subscript operator for an array shall be
3958
+ valid until the member function
3959
  `resize(size_t, T)` ([[valarray.members]]) is called for that array or
3960
  until the lifetime of that array ends, whichever happens first.
3961
 
3962
  If the subscript operator is invoked with a `size_t` argument whose
3963
  value is not less than the length of the array, the behavior is
 
4182
  size_t size() const;
4183
  ```
4184
 
4185
  *Returns:* The number of elements in the array.
4186
 
4187
+ *Complexity:* Constant time.
4188
 
4189
  ``` cpp
4190
  T sum() const;
4191
  ```
4192
 
 
4456
  size_t stride() const;
4457
  ```
4458
 
4459
  *Returns:* The start, length, or stride specified by a `slice` object.
4460
 
4461
+ *Complexity:* Constant time.
4462
 
4463
  ### Class template `slice_array` <a id="template.slice.array">[[template.slice.array]]</a>
4464
 
4465
  #### Class template `slice_array` overview <a id="template.slice.array.overview">[[template.slice.array.overview]]</a>
4466
 
 
4908
  template parameter `T` and whose `reference` type is `T&`.
4909
  *unspecified*2 is a type that meets the requirements of a constant
4910
  random access iterator ([[random.access.iterators]]) whose `value_type`
4911
  is the template parameter `T` and whose `reference` type is `const T&`.
4912
 
4913
+ The iterators returned by `begin` and `end` for an array are guaranteed
4914
+ to be valid until the member function `resize(size_t, T)` (
4915
+ [[valarray.members]]) is called for that array or until the lifetime of
4916
+ that array ends, whichever happens first.
4917
+
4918
  ``` cpp
4919
  template <class T> unspecified{1} begin(valarray<T>& v);
4920
  template <class T> unspecified{2} begin(const valarray<T>& v);
4921
  ```
4922
 
 
5085
 
5086
  *Effects:* For a non-empty range, the function creates an accumulator
5087
  `acc` whose type is `InputIterator`’s value type, initializes it with
5088
  `*first`, and assigns the result to `*result`. For every iterator `i` in
5089
  \[`first + 1`, `last`) in order, creates an object `val` whose type is
5090
+ `InputIterator`’s value type, initializes it with `*i`, computes
5091
  `val - acc` or `binary_op(val, acc)`, assigns the result to
5092
  `*(result + (i - first))`, and move assigns from `val` to `acc`.
5093
 
5094
  *Requires:* `InputIterator`’s value type shall be `MoveAssignable`
5095
  (Table  [[moveassignable]]) and shall be constructible from the type of
 
5125
  ## C library <a id="c.math">[[c.math]]</a>
5126
 
5127
  The header `<ctgmath>` simply includes the headers `<ccomplex>` and
5128
  `<cmath>`.
5129
 
5130
+ The overloads provided in C by type-generic macros are already provided
5131
+ in `<ccomplex>` and `<cmath>` by “sufficient” additional overloads.
5132
 
5133
  Tables  [[tab:numerics.hdr.cmath]] and  [[tab:numerics.hdr.cstdlib]]
5134
  describe headers `<cmath>` and `<cstdlib>`, respectively.
5135
 
5136
  The contents of these headers are the same as the Standard C library
 
5140
  The `rand` function has the semantics specified in the C standard,
5141
  except that the implementation may specify that particular library
5142
  functions may call `rand`. It is implementation-defined whether the
5143
  `rand` function may introduce data races ([[res.on.data.races]]). The
5144
  random number generation ([[rand]]) facilities in this standard are
5145
+ often preferable to `rand`, because `rand`’s underlying algorithm is
5146
+ unspecified. Use of `rand` therefore continues to be nonportable, with
5147
+ unpredictable and oft-questionable quality and performance.
5148
 
5149
  In addition to the `int` versions of certain math functions in
5150
  `<cstdlib>`, C++adds `long` and `long long` overloaded versions of these
5151
  functions, with the same semantics.
5152
 
 
5334
  bool isunordered(long double x, long double y);
5335
  ```
5336
 
5337
  Moreover, there shall be additional overloads sufficient to ensure:
5338
 
5339
+ 1. If any arithmetic argument corresponding to a `double` parameter has
5340
+ type `long double`, then all arithmetic arguments corresponding to
5341
+ `double` parameters are effectively cast to `long double`.
5342
+ 2. Otherwise, if any arithmetic argument corresponding to a `double`
5343
+ parameter has type `double` or an integer type, then all arithmetic
5344
+ arguments corresponding to `double` parameters are effectively cast
5345
+ to `double`.
5346
+ 3. Otherwise, all arithmetic arguments corresponding to `double`
5347
+ parameters have type `float`.
5348
 
5349
  ISO C 7.5, 7.10.2, 7.10.6.
5350
 
5351
  <!-- Link reference definitions -->
5352
  [accumulate]: #accumulate
 
5364
  [class.gslice.overview]: #class.gslice.overview
5365
  [class.slice]: #class.slice
5366
  [class.slice.overview]: #class.slice.overview
5367
  [cmplx.over]: #cmplx.over
5368
  [complex]: #complex
5369
+ [complex.literals]: #complex.literals
5370
  [complex.member.ops]: #complex.member.ops
5371
  [complex.members]: #complex.members
5372
  [complex.numbers]: #complex.numbers
5373
  [complex.ops]: #complex.ops
5374
  [complex.special]: #complex.special