Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions dist/dist.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ test_cases = [
{ n = 6, a = -1, b = 1, expected = [-1, -0.73205080756887729, -0.26794919243112271, 0.26794919243112271, 0.73205080756887729, 1] },
]

[chebyshev_augmented]
test_cases = [
{ n = 0, a = -1, b = 1, expected = [] },
{ n = 1, a = -1, b = 1, expected = [0] },
{ n = 2, a = -1, b = 1, expected = [-1, 1] },
{ n = 3, a = -1, b = 1, expected = [-1, 0, 1] },
{ n = 4, a = -1, b = 1, expected = [-1, -0.70710678118654752, 0.70710678118654752, 1] },
{ n = 5, a = -1, b = 1, expected = [-1, -0.86602540378443865, 0, 0.86602540378443865, 1] },
{ n = 6, a = -1, b = 1, expected = [-1, -0.92387953251128676, -0.38268343236508977, 0.38268343236508977, 0.92387953251128676, 1] },
]

[chebyshev_2]
test_cases = [
{ n = 0, a = -1, b = 1, expected = [] },
Expand Down Expand Up @@ -200,6 +211,59 @@ test_cases = [
{ n = 6, a = -1, b = 1, ratio=10, expected = [-1, -0.99539432839813447, -0.93721714482639173, 0.93721714482639173, 0.99539432839813447, 1] },
]

[chebyshev_ellipse_augmented]
test_cases = [
{ n = 0, a = -1, b = 1, ratio=0.1, expected = [] },
{ n = 0, a = -1, b = 1, ratio=0.25, expected = [] },
{ n = 0, a = -1, b = 1, ratio=0.5, expected = [] },
{ n = 0, a = -1, b = 1, ratio=1, expected = [] },
{ n = 0, a = -1, b = 1, ratio=2, expected = [] },
{ n = 0, a = -1, b = 1, ratio=4, expected = [] },
{ n = 0, a = -1, b = 1, ratio=10, expected = [] },
{ n = 1, a = -1, b = 1, ratio=0.1, expected = [0] },
{ n = 1, a = -1, b = 1, ratio=0.25, expected = [0] },
{ n = 1, a = -1, b = 1, ratio=0.5, expected = [0] },
{ n = 1, a = -1, b = 1, ratio=1, expected = [0] },
{ n = 1, a = -1, b = 1, ratio=2, expected = [0] },
{ n = 1, a = -1, b = 1, ratio=4, expected = [0] },
{ n = 1, a = -1, b = 1, ratio=10, expected = [0] },
{ n = 2, a = -1, b = 1, ratio=0.1, expected = [-1, 1] },
{ n = 2, a = -1, b = 1, ratio=0.25, expected = [-1, 1] },
{ n = 2, a = -1, b = 1, ratio=0.5, expected = [-1, 1] },
{ n = 2, a = -1, b = 1, ratio=1, expected = [-1, 1] },
{ n = 2, a = -1, b = 1, ratio=2, expected = [-1, 1] },
{ n = 2, a = -1, b = 1, ratio=4, expected = [-1, 1] },
{ n = 2, a = -1, b = 1, ratio=10, expected = [-1, 1] },
{ n = 3, a = -1, b = 1, ratio=0.1, expected = [-1, 0, 1] },
{ n = 3, a = -1, b = 1, ratio=0.25, expected = [-1, 0, 1] },
{ n = 3, a = -1, b = 1, ratio=0.5, expected = [-1, 0, 1] },
{ n = 3, a = -1, b = 1, ratio=1, expected = [-1, 0, 1] },
{ n = 3, a = -1, b = 1, ratio=2, expected = [-1, 0, 1] },
{ n = 3, a = -1, b = 1, ratio=4, expected = [-1, 0, 1] },
{ n = 3, a = -1, b = 1, ratio=10, expected = [-1, 0, 1] },
{ n = 4, a = -1, b = 1, ratio=0.1, expected = [-1, -0.099503719020998914, 0.099503719020998914, 1] },
{ n = 4, a = -1, b = 1, ratio=0.25, expected = [-1, -0.24253562503633297, 0.24253562503633297, 1] },
{ n = 4, a = -1, b = 1, ratio=0.5, expected = [-1, -0.44721359549995794, 0.44721359549995794, 1] },
{ n = 4, a = -1, b = 1, ratio=1, expected = [-1, -0.70710678118654752, 0.70710678118654752, 1] },
{ n = 4, a = -1, b = 1, ratio=2, expected = [-1, -0.89442719099991588, 0.89442719099991588, 1] },
{ n = 4, a = -1, b = 1, ratio=4, expected = [-1, -0.97014250014533189, 0.97014250014533189, 1] },
{ n = 4, a = -1, b = 1, ratio=10, expected = [-1, -0.99503719020998914, 0.99503719020998914, 1] },
{ n = 5, a = -1, b = 1, ratio=0.1, expected = [-1, -0.17066403719657229, 0, 0.17066403719657229, 1] },
{ n = 5, a = -1, b = 1, ratio=0.25, expected = [-1, -0.39735970711951314, 0, 0.39735970711951314, 1] },
{ n = 5, a = -1, b = 1, ratio=0.5, expected = [-1, -0.65465367070797714, 0, 0.65465367070797714, 1] },
{ n = 5, a = -1, b = 1, ratio=1, expected = [-1, -0.86602540378443865, 0, 0.86602540378443865, 1] },
{ n = 5, a = -1, b = 1, ratio=2, expected = [-1, -0.9607689228305228, 0, 0.9607689228305228, 1] },
{ n = 5, a = -1, b = 1, ratio=4, expected = [-1, -0.98974331861078702, 0, 0.98974331861078702, 1] },
{ n = 5, a = -1, b = 1, ratio=10, expected = [-1, -0.99833748845958268, 0, 0.99833748845958268, 1] },
{ n = 6, a = -1, b = 1, ratio=0.1, expected = [-1, -0.23467915435260521, -0.041385867991006554, 0.041385867991006554, 0.23467915435260521, 1] },
{ n = 6, a = -1, b = 1, ratio=0.25, expected = [-1, -0.51673093692781504, -0.10300259910443524, 0.10300259910443524, 0.51673093692781504, 1] },
{ n = 6, a = -1, b = 1, ratio=0.5, expected = [-1, -0.77007615237912863, -0.20280301033360352, 0.20280301033360352, 0.77007615237912863, 1] },
{ n = 6, a = -1, b = 1, ratio=1, expected = [-1, -0.92387953251128676, -0.38268343236508977, 0.38268343236508977, 0.92387953251128676, 1] },
{ n = 6, a = -1, b = 1, ratio=2, expected = [-1, -0.97921955607495314, -0.63795197275105049, 0.63795197275105049, 0.97921955607495314, 1] },
{ n = 6, a = -1, b = 1, ratio=4, expected = [-1, -0.99468108687042552, -0.85614784869302944, 0.85614784869302944, 0.99468108687042552, 1] },
{ n = 6, a = -1, b = 1, ratio=10, expected = [-1, -0.99914323794470579, -0.97207288539098039, 0.97207288539098039, 0.99914323794470579, 1] },
]

[chebyshev_ellipse_2]
test_cases = [
{ n = 0, a = -1, b = 1, ratio=0.1, expected = [] },
Expand Down
20 changes: 14 additions & 6 deletions dist/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def chebyshev(n):
return [-mp.cos((2*k - 1) * mp.pi / (2*n)) for k in range(1, n + 1)]


def chebyshev_stretched(n):
return stretched(chebyshev(n))


def chebyshev_augmented(n):
return [] if n == 0 else [0] if n == 1 else [-1] + chebyshev(n - 2) + [1]


def chebyshev_2(n):
return [mp.sin(mp.pi / 2 * x) for x in uniform(n)]

Expand All @@ -69,10 +77,6 @@ def chebyshev_4(n):
return [mp.cos(((2*n - 2 - 2*k) * mp.pi) / (2*n - 1)) for k in range(n)]


def chebyshev_stretched(n):
return stretched(chebyshev(n))


def chebyshev_ellipse(n, ratio):
return [mp.sign(2*k+1 - n) / mp.sqrt(1 + (mp.tan(mp.pi * (2*mp.mpf(k) + 1) / (2*n)) / ratio) ** 2) for k in range(n)]

Expand All @@ -81,6 +85,10 @@ def chebyshev_ellipse_stretched(n, ratio):
return stretched(chebyshev_ellipse(n, ratio))


def chebyshev_ellipse_augmented(n, ratio):
return [] if n == 0 else [0] if n == 1 else [-1] + chebyshev_ellipse(n - 2, ratio) + [1]


def chebyshev_ellipse_2(n, ratio):
return [0] if n == 1 else [mp.sign(2*k+1 - n) / mp.sqrt(1 + (mp.tan(mp.pi * mp.mpf(k) / (n-1)) / ratio) ** 2) for k in range(n)]

Expand Down Expand Up @@ -112,8 +120,8 @@ def erf_stretched(n, steepness):
def generate_test_cases():
mapping_intervals_section = 'mapping_intervals = [\n' + '\n'.join([f'\t[{i[0]}, {i[1]}],' for i in mapping_intervals]) + '\n]'

functions = [uniform, quadratic, cubic, chebyshev, chebyshev_stretched, chebyshev_2, chebyshev_3, chebyshev_4,
chebyshev_ellipse, chebyshev_ellipse_stretched, chebyshev_ellipse_2, chebyshev_ellipse_3, chebyshev_ellipse_4,
functions = [uniform, quadratic, cubic, chebyshev, chebyshev_stretched, chebyshev_augmented, chebyshev_2, chebyshev_3, chebyshev_4,
chebyshev_ellipse, chebyshev_ellipse_stretched, chebyshev_ellipse_augmented, chebyshev_ellipse_2, chebyshev_ellipse_3, chebyshev_ellipse_4,
logistic, logistic_stretched, erf, erf_stretched]
sections = []

Expand Down