tmp/tmp2l10q0lp/{from.md → to.md}
RENAMED
|
@@ -2,20 +2,17 @@
|
|
| 2 |
|
| 3 |
##### Class template `discrete_distribution` <a id="rand.dist.samp.discrete">[[rand.dist.samp.discrete]]</a>
|
| 4 |
|
| 5 |
A `discrete_distribution` random number distribution produces random
|
| 6 |
integers i, 0 ≤ i < n, distributed according to the discrete probability
|
| 7 |
-
function $$
|
| 8 |
-
P(i\,|\,p_0,\ldots,p_{n-1})
|
| 9 |
-
= p_i
|
| 10 |
-
\; \mbox{.}$$
|
| 11 |
|
| 12 |
Unless specified otherwise, the distribution parameters are calculated
|
| 13 |
-
as:
|
| 14 |
-
|
| 15 |
-
non-
|
| 16 |
-
0 < S =
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
template<class IntType = int>
|
| 20 |
class discrete_distribution {
|
| 21 |
public:
|
|
@@ -61,15 +58,18 @@ p₀ = 1.
|
|
| 61 |
``` cpp
|
| 62 |
template<class InputIterator>
|
| 63 |
discrete_distribution(InputIterator firstW, InputIterator lastW);
|
| 64 |
```
|
| 65 |
|
| 66 |
-
*
|
| 67 |
-
|
| 68 |
-
`
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
*Effects:* Constructs a `discrete_distribution` object with
|
| 73 |
probabilities given by the formula above.
|
| 74 |
|
| 75 |
``` cpp
|
|
@@ -81,22 +81,22 @@ discrete_distribution(initializer_list<double> wl);
|
|
| 81 |
``` cpp
|
| 82 |
template<class UnaryOperation>
|
| 83 |
discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw);
|
| 84 |
```
|
| 85 |
|
| 86 |
-
*
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
|
| 92 |
*Effects:* Constructs a `discrete_distribution` object with
|
| 93 |
probabilities given by the formula above, using the following values: If
|
| 94 |
`nw` = 0, let w₀ = 1. Otherwise, let wₖ = `fw`(`xmin` + k ⋅ δ + δ / 2)
|
| 95 |
for k = 0, …, n - 1.
|
| 96 |
|
| 97 |
-
*Complexity:* The number of invocations of `fw`
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
vector<double> probabilities() const;
|
| 101 |
```
|
| 102 |
|
|
@@ -107,27 +107,21 @@ k = 0, …, n-1.
|
|
| 107 |
##### Class template `piecewise_constant_distribution` <a id="rand.dist.samp.pconst">[[rand.dist.samp.pconst]]</a>
|
| 108 |
|
| 109 |
A `piecewise_constant_distribution` random number distribution produces
|
| 110 |
random numbers x, b₀ ≤ x < bₙ, uniformly distributed over each
|
| 111 |
subinterval [ bᵢ, bᵢ₊₁ ) according to the probability density function
|
| 112 |
-
$$
|
| 113 |
-
|
| 114 |
-
= \rho_i
|
| 115 |
-
\; \mbox{,}
|
| 116 |
-
\mbox{ for } b_i \le x < b_{i+1}
|
| 117 |
-
\; \mbox{.}$$
|
| 118 |
|
| 119 |
The n + 1 distribution parameters bᵢ, also known as this distribution’s
|
| 120 |
-
*interval boundaries* , shall satisfy the relation
|
| 121 |
-
i = 0, …, n-1. Unless specified otherwise, the remaining n
|
| 122 |
-
parameters are calculated as:
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
non-infinity. Moreover, the following relation shall hold:
|
| 128 |
-
0 < S = w₀ + ⋯ + wₙ₋₁.
|
| 129 |
|
| 130 |
``` cpp
|
| 131 |
template<class RealType = double>
|
| 132 |
class piecewise_constant_distribution {
|
| 133 |
public:
|
|
@@ -175,59 +169,60 @@ n = 1, ρ₀ = 1, b₀ = 0, and b₁ = 1.
|
|
| 175 |
template<class InputIteratorB, class InputIteratorW>
|
| 176 |
piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB,
|
| 177 |
InputIteratorW firstW);
|
| 178 |
```
|
| 179 |
|
| 180 |
-
*
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
`iterator_traits<
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
*Effects:* Constructs a `piecewise_constant_distribution` object with
|
| 192 |
parameters as specified above.
|
| 193 |
|
| 194 |
``` cpp
|
| 195 |
template<class UnaryOperation>
|
| 196 |
piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);
|
| 197 |
```
|
| 198 |
|
| 199 |
-
*
|
| 200 |
-
|
| 201 |
-
`double`. Moreover, `double` shall be convertible to the type of
|
| 202 |
-
`UnaryOperation`’s sole parameter.
|
| 203 |
|
| 204 |
*Effects:* Constructs a `piecewise_constant_distribution` object with
|
| 205 |
parameters taken or calculated from the following values: If
|
| 206 |
`bl.size()` < 2, let n = 1, w₀ = 1, b₀ = 0, and b₁ = 1. Otherwise, let
|
| 207 |
[`bl.begin()`, `bl.end()`) form a sequence b₀, …, bₙ, and let
|
| 208 |
wₖ = `fw`((bₖ₊₁ + bₖ) / 2) for k = 0, …, n - 1.
|
| 209 |
|
| 210 |
-
*Complexity:* The number of invocations of `fw`
|
| 211 |
|
| 212 |
``` cpp
|
| 213 |
template<class UnaryOperation>
|
| 214 |
piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
|
| 215 |
```
|
| 216 |
|
| 217 |
-
*
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
|
| 223 |
*Effects:* Constructs a `piecewise_constant_distribution` object with
|
| 224 |
parameters taken or calculated from the following values: Let
|
| 225 |
bₖ = `xmin` + k ⋅ δ for k = 0, …, n, and wₖ = `fw`(bₖ + δ / 2) for
|
| 226 |
k = 0, …, n - 1.
|
| 227 |
|
| 228 |
-
*Complexity:* The number of invocations of `fw`
|
| 229 |
|
| 230 |
``` cpp
|
| 231 |
vector<result_type> intervals() const;
|
| 232 |
```
|
| 233 |
|
|
@@ -245,29 +240,24 @@ k = 0, …, n-1.
|
|
| 245 |
|
| 246 |
##### Class template `piecewise_linear_distribution` <a id="rand.dist.samp.plinear">[[rand.dist.samp.plinear]]</a>
|
| 247 |
|
| 248 |
A `piecewise_linear_distribution` random number distribution produces
|
| 249 |
random numbers x, b₀ ≤ x < bₙ, distributed over each subinterval
|
| 250 |
-
[
|
| 251 |
-
|
| 252 |
-
|
| 253 |
+ \rho_{i+1} \cdot {\frac{x - b_i}{b_{i+1} - b_i}}
|
| 254 |
-
\
|
| 255 |
-
\mbox{ for } b_i \le x < b_{i+1}
|
| 256 |
-
\; \mbox{.}$$
|
| 257 |
|
| 258 |
The n + 1 distribution parameters bᵢ, also known as this distribution’s
|
| 259 |
*interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
|
| 260 |
i = 0, …, n - 1. Unless specified otherwise, the remaining n + 1
|
| 261 |
-
distribution parameters are calculated as
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
0 < S = \frac{1}{2}
|
| 267 |
-
\cdot \sum_{k=0}^{n-1} (w_k + w_{k+1}) \cdot (b_{k+1} - b_k)
|
| 268 |
-
\; \mbox{.}$$
|
| 269 |
|
| 270 |
``` cpp
|
| 271 |
template<class RealType = double>
|
| 272 |
class piecewise_linear_distribution {
|
| 273 |
public:
|
|
@@ -314,58 +304,55 @@ n = 1, ρ₀ = ρ₁ = 1, b₀ = 0, and b₁ = 1.
|
|
| 314 |
template<class InputIteratorB, class InputIteratorW>
|
| 315 |
piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
|
| 316 |
InputIteratorW firstW);
|
| 317 |
```
|
| 318 |
|
| 319 |
-
*
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
`
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
n+1, and any wₖ for k ≥ n+1 shall be ignored by the distribution.
|
| 329 |
|
| 330 |
*Effects:* Constructs a `piecewise_linear_distribution` object with
|
| 331 |
parameters as specified above.
|
| 332 |
|
| 333 |
``` cpp
|
| 334 |
template<class UnaryOperation>
|
| 335 |
piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);
|
| 336 |
```
|
| 337 |
|
| 338 |
-
*
|
| 339 |
-
|
| 340 |
-
`double`. Moreover, `double` shall be convertible to the type of
|
| 341 |
-
`UnaryOperation`’s sole parameter.
|
| 342 |
|
| 343 |
*Effects:* Constructs a `piecewise_linear_distribution` object with
|
| 344 |
parameters taken or calculated from the following values: If
|
| 345 |
`bl.size()` < 2, let n = 1, ρ₀ = ρ₁ = 1, b₀ = 0, and b₁ = 1. Otherwise,
|
| 346 |
let [`bl.begin(),` `bl.end()`) form a sequence b₀, …, bₙ, and let
|
| 347 |
wₖ = `fw`(bₖ) for k = 0, …, n.
|
| 348 |
|
| 349 |
-
*Complexity:* The number of invocations of `fw`
|
| 350 |
|
| 351 |
``` cpp
|
| 352 |
template<class UnaryOperation>
|
| 353 |
piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
|
| 354 |
```
|
| 355 |
|
| 356 |
-
*
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
|
| 362 |
*Effects:* Constructs a `piecewise_linear_distribution` object with
|
| 363 |
parameters taken or calculated from the following values: Let
|
| 364 |
bₖ = `xmin` + k ⋅ δ for k = 0, …, n, and wₖ = `fw`(bₖ) for k = 0, …, n.
|
| 365 |
|
| 366 |
-
*Complexity:* The number of invocations of `fw`
|
| 367 |
|
| 368 |
``` cpp
|
| 369 |
vector<result_type> intervals() const;
|
| 370 |
```
|
| 371 |
|
|
|
|
| 2 |
|
| 3 |
##### Class template `discrete_distribution` <a id="rand.dist.samp.discrete">[[rand.dist.samp.discrete]]</a>
|
| 4 |
|
| 5 |
A `discrete_distribution` random number distribution produces random
|
| 6 |
integers i, 0 ≤ i < n, distributed according to the discrete probability
|
| 7 |
+
function $$P(i \,|\, p_0, \dotsc, p_{n-1}) = p_i \text{ .}$$
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
Unless specified otherwise, the distribution parameters are calculated
|
| 10 |
+
as: pₖ = {wₖ / S} for k = 0, …, n - 1, in which the values wₖ, commonly
|
| 11 |
+
known as the *weights* , shall be non-negative, non-NaN, and
|
| 12 |
+
non-infinity. Moreover, the following relation shall hold:
|
| 13 |
+
$0 < S = w_0 + \dotsb + w_{n - 1}$.
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
template<class IntType = int>
|
| 17 |
class discrete_distribution {
|
| 18 |
public:
|
|
|
|
| 58 |
``` cpp
|
| 59 |
template<class InputIterator>
|
| 60 |
discrete_distribution(InputIterator firstW, InputIterator lastW);
|
| 61 |
```
|
| 62 |
|
| 63 |
+
*Mandates:*
|
| 64 |
+
`is_convertible_v<iterator_traits<InputIterator>::value_type, double>`
|
| 65 |
+
is `true`.
|
| 66 |
+
|
| 67 |
+
*Preconditions:* `InputIterator` meets the *Cpp17InputIterator*
|
| 68 |
+
requirements [[input.iterators]]. If `firstW == lastW`, let n = 1 and
|
| 69 |
+
w₀ = 1. Otherwise, [`firstW`, `lastW`) forms a sequence w of length
|
| 70 |
+
n > 0.
|
| 71 |
|
| 72 |
*Effects:* Constructs a `discrete_distribution` object with
|
| 73 |
probabilities given by the formula above.
|
| 74 |
|
| 75 |
``` cpp
|
|
|
|
| 81 |
``` cpp
|
| 82 |
template<class UnaryOperation>
|
| 83 |
discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw);
|
| 84 |
```
|
| 85 |
|
| 86 |
+
*Mandates:* `is_invocable_r_v<double, UnaryOperation&, double>` is
|
| 87 |
+
`true`.
|
| 88 |
+
|
| 89 |
+
*Preconditions:* If `nw` = 0, let n = 1, otherwise let n = `nw`. The
|
| 90 |
+
relation 0 < δ = (`xmax` - `xmin`) / n holds.
|
| 91 |
|
| 92 |
*Effects:* Constructs a `discrete_distribution` object with
|
| 93 |
probabilities given by the formula above, using the following values: If
|
| 94 |
`nw` = 0, let w₀ = 1. Otherwise, let wₖ = `fw`(`xmin` + k ⋅ δ + δ / 2)
|
| 95 |
for k = 0, …, n - 1.
|
| 96 |
|
| 97 |
+
*Complexity:* The number of invocations of `fw` does not exceed n.
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
vector<double> probabilities() const;
|
| 101 |
```
|
| 102 |
|
|
|
|
| 107 |
##### Class template `piecewise_constant_distribution` <a id="rand.dist.samp.pconst">[[rand.dist.samp.pconst]]</a>
|
| 108 |
|
| 109 |
A `piecewise_constant_distribution` random number distribution produces
|
| 110 |
random numbers x, b₀ ≤ x < bₙ, uniformly distributed over each
|
| 111 |
subinterval [ bᵢ, bᵢ₊₁ ) according to the probability density function
|
| 112 |
+
$$p(x \,|\, b_0, \dotsc, b_n, \; \rho_0, \dotsc, \rho_{n-1}) = \rho_i
|
| 113 |
+
\text{ , for $b_i \le x < b_{i+1}$.}$$
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
The n + 1 distribution parameters bᵢ, also known as this distribution’s
|
| 116 |
+
*interval boundaries* , shall satisfy the relation $b_i < b_{i + 1}$ for
|
| 117 |
+
i = 0, …, n - 1. Unless specified otherwise, the remaining n
|
| 118 |
+
distribution parameters are calculated as:
|
| 119 |
+
$$\rho_k = \frac{w_k}{S \cdot (b_{k+1}-b_k)} \text{ for } k = 0, \dotsc, n - 1 \text{ ,}$$
|
| 120 |
+
in which the values wₖ, commonly known as the *weights* , shall be
|
| 121 |
+
non-negative, non-NaN, and non-infinity. Moreover, the following
|
| 122 |
+
relation shall hold: 0 < S = w₀ + … + wₙ₋₁.
|
|
|
|
|
|
|
| 123 |
|
| 124 |
``` cpp
|
| 125 |
template<class RealType = double>
|
| 126 |
class piecewise_constant_distribution {
|
| 127 |
public:
|
|
|
|
| 169 |
template<class InputIteratorB, class InputIteratorW>
|
| 170 |
piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB,
|
| 171 |
InputIteratorW firstW);
|
| 172 |
```
|
| 173 |
|
| 174 |
+
*Mandates:* Both of
|
| 175 |
+
|
| 176 |
+
- `is_convertible_v<iterator_traits<InputIteratorB>::value_type, double>`
|
| 177 |
+
- `is_convertible_v<iterator_traits<InputIteratorW>::value_type, double>`
|
| 178 |
+
|
| 179 |
+
are `true`.
|
| 180 |
+
|
| 181 |
+
*Preconditions:* `InputIteratorB` and `InputIteratorW` each meet the
|
| 182 |
+
*Cpp17InputIterator* requirements [[input.iterators]]. If
|
| 183 |
+
`firstB == lastB` or `++firstB == lastB`, let n = 1, w₀ = 1, b₀ = 0, and
|
| 184 |
+
b₁ = 1. Otherwise, [`firstB`, `lastB`) forms a sequence b of length n+1,
|
| 185 |
+
the length of the sequence w starting from `firstW` is at least n, and
|
| 186 |
+
any wₖ for k ≥ n are ignored by the distribution.
|
| 187 |
|
| 188 |
*Effects:* Constructs a `piecewise_constant_distribution` object with
|
| 189 |
parameters as specified above.
|
| 190 |
|
| 191 |
``` cpp
|
| 192 |
template<class UnaryOperation>
|
| 193 |
piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);
|
| 194 |
```
|
| 195 |
|
| 196 |
+
*Mandates:* `is_invocable_r_v<double, UnaryOperation&, double>` is
|
| 197 |
+
`true`.
|
|
|
|
|
|
|
| 198 |
|
| 199 |
*Effects:* Constructs a `piecewise_constant_distribution` object with
|
| 200 |
parameters taken or calculated from the following values: If
|
| 201 |
`bl.size()` < 2, let n = 1, w₀ = 1, b₀ = 0, and b₁ = 1. Otherwise, let
|
| 202 |
[`bl.begin()`, `bl.end()`) form a sequence b₀, …, bₙ, and let
|
| 203 |
wₖ = `fw`((bₖ₊₁ + bₖ) / 2) for k = 0, …, n - 1.
|
| 204 |
|
| 205 |
+
*Complexity:* The number of invocations of `fw` does not exceed n.
|
| 206 |
|
| 207 |
``` cpp
|
| 208 |
template<class UnaryOperation>
|
| 209 |
piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
|
| 210 |
```
|
| 211 |
|
| 212 |
+
*Mandates:* `is_invocable_r_v<double, UnaryOperation&, double>` is
|
| 213 |
+
`true`.
|
| 214 |
+
|
| 215 |
+
*Preconditions:* If `nw` = 0, let n = 1, otherwise let n = `nw`. The
|
| 216 |
+
relation 0 < δ = (`xmax` - `xmin`) / n holds.
|
| 217 |
|
| 218 |
*Effects:* Constructs a `piecewise_constant_distribution` object with
|
| 219 |
parameters taken or calculated from the following values: Let
|
| 220 |
bₖ = `xmin` + k ⋅ δ for k = 0, …, n, and wₖ = `fw`(bₖ + δ / 2) for
|
| 221 |
k = 0, …, n - 1.
|
| 222 |
|
| 223 |
+
*Complexity:* The number of invocations of `fw` does not exceed n.
|
| 224 |
|
| 225 |
``` cpp
|
| 226 |
vector<result_type> intervals() const;
|
| 227 |
```
|
| 228 |
|
|
|
|
| 240 |
|
| 241 |
##### Class template `piecewise_linear_distribution` <a id="rand.dist.samp.plinear">[[rand.dist.samp.plinear]]</a>
|
| 242 |
|
| 243 |
A `piecewise_linear_distribution` random number distribution produces
|
| 244 |
random numbers x, b₀ ≤ x < bₙ, distributed over each subinterval
|
| 245 |
+
[bᵢ, bᵢ₊₁) according to the probability density function
|
| 246 |
+
$$p(x \,|\, b_0, \dotsc, b_n, \; \rho_0, \dotsc, \rho_n)
|
| 247 |
+
= \rho_{i} \cdot {\frac{b_{i+1} - x}{b_{i+1} - b_i}}
|
| 248 |
+ \rho_{i+1} \cdot {\frac{x - b_i}{b_{i+1} - b_i}}
|
| 249 |
+
\text{ , for $b_i \le x < b_{i+1}$.}$$
|
|
|
|
|
|
|
| 250 |
|
| 251 |
The n + 1 distribution parameters bᵢ, also known as this distribution’s
|
| 252 |
*interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
|
| 253 |
i = 0, …, n - 1. Unless specified otherwise, the remaining n + 1
|
| 254 |
+
distribution parameters are calculated as ρₖ = {wₖ / S} for k = 0, …, n,
|
| 255 |
+
in which the values wₖ, commonly known as the *weights at boundaries* ,
|
| 256 |
+
shall be non-negative, non-NaN, and non-infinity. Moreover, the
|
| 257 |
+
following relation shall hold:
|
| 258 |
+
$$0 < S = \frac{1}{2} \cdot \sum_{k=0}^{n-1} (w_k + w_{k+1}) \cdot (b_{k+1} - b_k) \text{ .}$$
|
|
|
|
|
|
|
|
|
|
| 259 |
|
| 260 |
``` cpp
|
| 261 |
template<class RealType = double>
|
| 262 |
class piecewise_linear_distribution {
|
| 263 |
public:
|
|
|
|
| 304 |
template<class InputIteratorB, class InputIteratorW>
|
| 305 |
piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
|
| 306 |
InputIteratorW firstW);
|
| 307 |
```
|
| 308 |
|
| 309 |
+
*Mandates:* `is_invocable_r_v<double, UnaryOperation&, double>` is
|
| 310 |
+
`true`.
|
| 311 |
+
|
| 312 |
+
*Preconditions:* `InputIteratorB` and `InputIteratorW` each meet the
|
| 313 |
+
*Cpp17InputIterator* requirements [[input.iterators]]. If
|
| 314 |
+
`firstB == lastB` or `++firstB == lastB`, let n = 1, ρ₀ = ρ₁ = 1,
|
| 315 |
+
b₀ = 0, and b₁ = 1. Otherwise, [`firstB`, `lastB`) forms a sequence b of
|
| 316 |
+
length n+1, the length of the sequence w starting from `firstW` is at
|
| 317 |
+
least n+1, and any wₖ for k ≥ n + 1 are ignored by the distribution.
|
|
|
|
| 318 |
|
| 319 |
*Effects:* Constructs a `piecewise_linear_distribution` object with
|
| 320 |
parameters as specified above.
|
| 321 |
|
| 322 |
``` cpp
|
| 323 |
template<class UnaryOperation>
|
| 324 |
piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);
|
| 325 |
```
|
| 326 |
|
| 327 |
+
*Mandates:* `is_invocable_r_v<double, UnaryOperation&, double>` is
|
| 328 |
+
`true`.
|
|
|
|
|
|
|
| 329 |
|
| 330 |
*Effects:* Constructs a `piecewise_linear_distribution` object with
|
| 331 |
parameters taken or calculated from the following values: If
|
| 332 |
`bl.size()` < 2, let n = 1, ρ₀ = ρ₁ = 1, b₀ = 0, and b₁ = 1. Otherwise,
|
| 333 |
let [`bl.begin(),` `bl.end()`) form a sequence b₀, …, bₙ, and let
|
| 334 |
wₖ = `fw`(bₖ) for k = 0, …, n.
|
| 335 |
|
| 336 |
+
*Complexity:* The number of invocations of `fw` does not exceed n+1.
|
| 337 |
|
| 338 |
``` cpp
|
| 339 |
template<class UnaryOperation>
|
| 340 |
piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
|
| 341 |
```
|
| 342 |
|
| 343 |
+
*Mandates:* `is_invocable_r_v<double, UnaryOperation&, double>` is
|
| 344 |
+
`true`.
|
| 345 |
+
|
| 346 |
+
*Preconditions:* If `nw` = 0, let n = 1, otherwise let n = `nw`. The
|
| 347 |
+
relation 0 < δ = (`xmax` - `xmin`) / n holds.
|
| 348 |
|
| 349 |
*Effects:* Constructs a `piecewise_linear_distribution` object with
|
| 350 |
parameters taken or calculated from the following values: Let
|
| 351 |
bₖ = `xmin` + k ⋅ δ for k = 0, …, n, and wₖ = `fw`(bₖ) for k = 0, …, n.
|
| 352 |
|
| 353 |
+
*Complexity:* The number of invocations of `fw` does not exceed n+1.
|
| 354 |
|
| 355 |
``` cpp
|
| 356 |
vector<result_type> intervals() const;
|
| 357 |
```
|
| 358 |
|