diff --git a/dist/dist.toml b/dist/dist.toml index 55cc77d..cf9d505 100644 --- a/dist/dist.toml +++ b/dist/dist.toml @@ -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 = [] }, @@ -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 = [] }, diff --git a/dist/generate.py b/dist/generate.py index 73875b3..12072b6 100755 --- a/dist/generate.py +++ b/dist/generate.py @@ -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)] @@ -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)] @@ -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)] @@ -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 = []