37 Container<Number>
uniform(
SizeT n,
const Number& a,
const Number& b) {
40 Container<Number>
points(n);
41 for (
SizeT i = 0; i < n; ++i) {
42 points[i] = a + (b - a) *
static_cast<Number
>(i) /
static_cast<Number
>(n - 1);
69 Container<Number>
points(n);
70 for (
SizeT i = 0; i < n; ++i) {
71 const Number x = 2 *
static_cast<Number
>(i) / (
static_cast<Number
>(n) - 1) - 1;
72 const Number value = x <= 0 ? x * (x + 2) : -x * (x - 2);
73 points[i] = a + (b - a) * (1 + value) / 2;
94 Container<Number>
cubic(
SizeT n,
const Number& a,
const Number& b) {
97 Container<Number>
points(n);
98 for (
SizeT i = 0; i < n; ++i) {
99 const Number x = 2 *
static_cast<Number
>(i) / (
static_cast<Number
>(n) - 1) - 1;
100 const Number value = (3 - x*x) * x / 2;
101 points[i] = a + (b - a) * (1 + value) / 2;
110 Container<Number>
points(n);
111 for (
SizeT i = 0; i < n; ++i) {
112 const Number x = std::cos(M_PI * (2 * (
static_cast<Number
>(n) -
static_cast<Number
>(i)) - 1) / (2 *
static_cast<Number
>(n)));
113 points[i] = a + (x + 1) * (b - a) / 2;
131 Container<Number>
points(n);
132 Container<Number> c =
chebyshev(n - 2, a, b);
133 std::move(c.begin(), c.end(),
points.begin() + 1);
143 Container<Number>
points(n);
144 for (
SizeT i = 0; i < n; ++i) {
145 const Number x = 1 - std::cos(M_PI *
static_cast<Number
>(i) / (
static_cast<Number
>(n) - 1));
146 points[i] = a + (b - a) * x / 2;
153 Container<Number>
points(n);
154 for (
SizeT i = 0; i < n; ++i) {
155 const Number x = 1 - std::cos(M_PI *
static_cast<Number
>(2*i) /
static_cast<Number
>(2*n - 1));
156 points[i] = a + (b - a) * x / 2;
168 Container<Number>
points(n);
169 for (
SizeT i = 0; i < n; ++i) {
170 const Number x = 1 - std::cos(M_PI *
static_cast<Number
>(2*i + 1) /
static_cast<Number
>(2*n - 1));
171 points[i] = a + (b - a) * x / 2;
183 Container<Number>
points(n);
184 for (
SizeT i = 0; i < n / 2; ++i) {
185 const Number theta = M_PI * (2 *
static_cast<Number
>(i) + 1) / (2 *
static_cast<Number
>(n));
186 const Number x = 1 / std::sqrt(1 + std::pow(std::tan(theta) / ratio, 2));
187 points[i] = a + (1 - x) * (b - a) / 2;
188 points[n-1-i] = a + (1 + x) * (b - a) / 2;
208 Container<Number>
points(n);
210 std::move(c.begin(), c.end(),
points.begin() + 1);
218 Container<Number>
points(n);
219 for (
SizeT i = 0; i < n / 2; ++i) {
220 const Number theta = M_PI *
static_cast<Number
>(i) / (
static_cast<Number
>(n) - 1);
221 const Number x = 1 / std::sqrt(1 + std::pow(std::tan(theta) / ratio, 2));
222 points[i] = (1 - x) * (b - a) / 2 + a;
223 points[n-1-i] = (1 + x) * (b - a) / 2 + a;
232 Container<Number>
points(n);
233 for (
SizeT i = 0; i < n; ++i) {
234 const Number theta = M_PI *
static_cast<Number
>(2*i) /
static_cast<Number
>(2*n - 1);
235 const Number x = (theta < M_PI/2 ? 1 : -1) / std::sqrt(1 + std::pow(std::tan(theta) / ratio, 2));
236 points[i] = (1 - x) * (b - a) / 2 + a;
248 Container<Number>
points(n);
249 for (
SizeT i = 0; i < n; ++i) {
250 const Number theta = M_PI *
static_cast<Number
>(2*i + 1) /
static_cast<Number
>(2*n - 1);
251 const Number x = (theta < M_PI/2 ? 1 : -1) / std::sqrt(1 + std::pow(std::tan(theta) / ratio, 2));
252 points[i] = (1 - x) * (b - a) / 2 + a;
286 Container<Number>
logistic(
SizeT n,
const Number& a,
const Number& b,
const Number& steepness) {
289 Container<Number>
points(n);
290 for (
SizeT i = 0; i < n; ++i) {
291 const Number x = 2 *
static_cast<Number
>(i) / (
static_cast<Number
>(n) - 1) - 1;
292 const Number logisticValue = 1 / (1 + std::exp(-steepness * x));
293 points[i] = a + (b - a) * logisticValue;
304 Container<Number>
points(n);
305 const Number stretch_factor = 1 - 2 / (1 + std::exp(steepness));
306 for (
SizeT i = 1; i < n - 1; ++i) {
307 const Number x = 2 *
static_cast<double>(i) / (
static_cast<Number
>(n) - 1) - 1;
308 const Number logisticValue = 1 / (1 + std::exp(-steepness * x));
309 const Number stretched = (logisticValue - 1 / (1 + std::exp(steepness))) / stretch_factor;
310 points[i] = a + (b - a) * stretched;
341 Container<Number>
erf(
SizeT n,
const Number& a,
const Number& b,
const Number& steepness) {
346 Container<Number>
points(n);
347 for (
SizeT i = 0; i < n; ++i) {
348 const Number x = 2 *
static_cast<Number
>(i) / (
static_cast<Number
>(n) - 1) - 1;
349 const Number erf_value = std::erf(steepness * x);
350 points[i] = a + (b - a) * (1 + erf_value) / 2;
356 Container<Number>
erf_stretched(
SizeT n,
const Number& a,
const Number& b,
const Number& steepness) {
361 Container<Number>
of_type(
Type type,
SizeT n,
const Number& a,
const Number& b,
const Number& parameter = NAN) {
366 return cubic(n, a, b);
400 return logistic(n, a, b, parameter);
404 return erf(n, a, b, parameter);
Container< Number > chebyshev_ellipse_4_stretched(SizeT n, const Number &a, const Number &b, const Number &ratio)
Definition dist.h:258
Container< Number > uniform(SizeT n, const Number &a, const Number &b)
Definition dist.h:37
Container< Number > chebyshev(SizeT n, const Number &a, const Number &b)
Definition dist.h:107
Container< Number > chebyshev_3(SizeT n, const Number &a, const Number &b)
Definition dist.h:152
Container< Number > chebyshev_ellipse_2(SizeT n, const Number &a, const Number &b, const Number &ratio)
Definition dist.h:217
Container< Number > chebyshev_ellipse(SizeT n, const Number &a, const Number &b, const Number &ratio)
Definition dist.h:182
Container< Number > chebyshev_stretched(SizeT n, const Number &a, const Number &b)
Definition dist.h:119
@ LOGISTIC_STRETCHED
Definition dist.h:31
@ ERF_STRETCHED
Definition dist.h:33
@ CHEBYSHEV_ELLIPSE_4_STRETCHED
Definition dist.h:29
@ CHEBYSHEV_ELLIPSE_4
Definition dist.h:28
@ ERF
Definition dist.h:32
@ CHEBYSHEV_ELLIPSE_AUGMENTED
Definition dist.h:24
@ CHEBYSHEV_ELLIPSE_3_STRETCHED
Definition dist.h:27
@ LOGISTIC
Definition dist.h:30
@ UNIFORM
Definition dist.h:11
@ CHEBYSHEV_ELLIPSE_3
Definition dist.h:26
@ CHEBYSHEV_3_STRETCHED
Definition dist.h:19
@ CHEBYSHEV_4
Definition dist.h:20
@ QUADRATIC
Definition dist.h:12
@ CHEBYSHEV_4_STRETCHED
Definition dist.h:21
@ GENERAL
Definition dist.h:10
@ CHEBYSHEV_STRETCHED
Definition dist.h:15
@ CUBIC
Definition dist.h:13
@ CHEBYSHEV_AUGMENTED
Definition dist.h:16
@ CHEBYSHEV_ELLIPSE_STRETCHED
Definition dist.h:23
@ CHEBYSHEV_ELLIPSE
Definition dist.h:22
@ CHEBYSHEV_3
Definition dist.h:18
@ CHEBYSHEV_ELLIPSE_2
Definition dist.h:25
@ CHEBYSHEV_2
Definition dist.h:17
@ CHEBYSHEV
Definition dist.h:14
Container< Number > of_type(Type type, SizeT n, const Number &a, const Number &b, const Number ¶meter=NAN)
Definition dist.h:361
Container< Number > logistic_stretched(SizeT n, const Number &a, const Number &b, const Number &steepness)
Definition dist.h:299
Container< Number > cubic(SizeT n, const Number &a, const Number &b)
Generates a distribution of n points on the segment [a, b] using cubic polynomial.
Definition dist.h:94
Container< Number > logistic(SizeT n, const Number &a, const Number &b, const Number &steepness)
Generates a distribution of n points on the interval (a, b) using the logistic function.
Definition dist.h:286
Container< Number > chebyshev_ellipse_4(SizeT n, const Number &a, const Number &b, const Number &ratio)
Definition dist.h:247
Container< Number > quadratic(SizeT n, const Number &a, const Number &b)
Generates a distribution of n points on the segment [a, b] using two quadratic polynomials.
Definition dist.h:66
Container< Number > erf(SizeT n, const Number &a, const Number &b, const Number &steepness)
Generates a distribution of n points on the interval (a, b) using the error function.
Definition dist.h:341
Container< Number > chebyshev_ellipse_3(SizeT n, const Number &a, const Number &b, const Number &ratio)
Definition dist.h:231
Container< Number > chebyshev_4_stretched(SizeT n, const Number &a, const Number &b)
Definition dist.h:177
Container< Number > erf_stretched(SizeT n, const Number &a, const Number &b, const Number &steepness)
Definition dist.h:356
Container< Number > chebyshev_augmented(SizeT n, const Number &a, const Number &b)
Definition dist.h:124
Container< Number > chebyshev_ellipse_stretched(SizeT n, const Number &a, const Number &b, const Number &ratio)
Definition dist.h:196
Container< Number > chebyshev_ellipse_augmented(SizeT n, const Number &a, const Number &b, const Number &ratio)
Definition dist.h:201
Container< Number > chebyshev_2(SizeT n, const Number &a, const Number &b)
Definition dist.h:140
Container< Number > chebyshev_3_stretched(SizeT n, const Number &a, const Number &b)
Definition dist.h:162
Container< Number > chebyshev_4(SizeT n, const Number &a, const Number &b)
Definition dist.h:167
Container< Number > chebyshev_ellipse_3_stretched(SizeT n, const Number &a, const Number &b, const Number &ratio)
Definition dist.h:242
Container< Number > stretched(const Container< Number > &points, const Number &a, const Number &b)
Definition points.h:38
ALFI_DEFAULT_NUMBER DefaultNumber
Definition config.h:17
ALFI_SIZE_TYPE SizeT
Definition config.h:22
ALFI_DEFAULT_CONTAINER< Number > DefaultContainer
Definition config.h:20