Skip to content

Commit

Permalink
Fix Spline
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Aug 4, 2024
1 parent 8405138 commit d3723f4
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions vskernels/kernels/spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _naturalCubicSpline(self, values: list[int]) -> list[float]:
def _splineKernelCoeff(self) -> list[float]:
taps = self.kernel_radius

coeffs = list[float]([taps])
coeffs = list[float]()

def _shiftPolynomial(coeffs: list[float], shift: float) -> list[float]:
return [
Expand Down Expand Up @@ -81,9 +81,7 @@ def kernel(self, x: float) -> float: # type: ignore

tap = int(x)

coefs = [taps, *self._coefs]

a, b, c, d = coefs[4 * tap + 1:4 * tap + 5]
a, b, c, d = self._coefs[4 * tap:4 * tap + 4]

return poly3(x, d, c, b, a)

Expand All @@ -99,8 +97,8 @@ class Spline16(NaturalSpline):
_static_kernel_radius = 2

_static_coeffs = [
1.0, -9.0 / 5.0, -1.0 / 5.0, 1.0,
-1.0 / 3.0, 4.0 / 5.0, -7.0 / 15.0, 0.0
0.9999999999999988, -1.799999999999999, -0.1999999999999993, 1.0000000000000004,
-0.333333333333333, 1.7999999999999985, -3.066666666666665, 1.5999999999999994
]


Expand All @@ -110,9 +108,9 @@ class Spline36(NaturalSpline):
_static_kernel_radius = 3

_static_coeffs = [
13.0 / 11.0, -453.0 / 209.0, -3.0 / 209.0, 1.0,
-6.0 / 11.0, 270.0 / 209.0, -156.0 / 209.0, 0.0,
1.0 / 11.0, -45.0 / 209.0, 26.0 / 209.0, 0.0,
1.1818181818181834, -2.1674641148325353, -0.014354066985642788, 1.0,
-0.5454545454545451, 2.928229665071767, -4.9665071770334865, 2.583732057416266,
0.09090909090909075, -0.760765550239233, 2.0765550239234405, -1.837320574162675
]


Expand All @@ -122,8 +120,8 @@ class Spline64(NaturalSpline):
_static_kernel_radius = 4

_static_coeffs = [
49.0 / 41.0, -6387.0 / 2911.0, -3.0 / 2911.0, 1.0,
-24.0 / 41.0, 4032.0 / 2911.0, -2328.0 / 2911.0, 0.0,
6.0 / 41.0, -1008.0 / 2911.0, 582.0 / 2911.0, 0.0,
-1.0 / 41.0, 168.0 / 2911.0, -97.0 / 2911.0, 0.0
1.195121951219515, -2.1940913775334927, -0.0010305736860232173, 0.9999999999999929,
-0.5853658536585364, 3.141188594984538, -5.326004809343863, 2.7701820680178617,
0.1463414634146341, -1.2243215389900368, 3.3411198900721373, -2.9556853315011997,
-0.02439024390243902, 0.27722432153898985, -1.0381312263826854, 1.277911370663001
]

0 comments on commit d3723f4

Please sign in to comment.