Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _C1f(eps, c):
"""Private: return C1."""
coeff = [
-1, 6, -16, 32,
-9, 64, -128, 2048,
9, -16, 768,
3, -5, 512,
-7, 1280,
-7, 2048,
]
eps2 = Math.sq(eps)
d = eps
o = 0
for l in range(1, Geodesic.nC1_ + 1): # l is index of C1p[l]
m = (Geodesic.nC1_ - l) // 2 # order of polynomial in eps^2
c[l] = d * Math.polyval(m, coeff, o, eps2) / coeff[o + m + 1]
o += m + 2
d *= eps
_C1f = staticmethod(_C1f)
def _C2f(eps, c):
"""Private: return C2"""
coeff = [
1, 2, 16, 32,
35, 64, 384, 2048,
15, 80, 768,
7, 35, 512,
63, 1280,
77, 2048,
]
eps2 = Math.sq(eps)
d = eps
o = 0
for l in range(1, Geodesic.nC2_ + 1): # l is index of C2[l]
m = (Geodesic.nC2_ - l) // 2 # order of polynomial in eps^2
c[l] = d * Math.polyval(m, coeff, o, eps2) / coeff[o + m + 1]
o += m + 2
d *= eps
_C2f = staticmethod(_C2f)
def _A2m1f(eps):
"""Private: return A2-1"""
coeff = [
-11, -28, -192, 0, 256,
]
m = Geodesic.nA2_//2
t = Math.polyval(m, coeff, 0, Math.sq(eps)) / coeff[m + 1]
return (t - eps) / (1 + eps)
_A2m1f = staticmethod(_A2m1f)
def _A3f(self, eps):
"""Private: return A3"""
# Evaluate A3
return Math.polyval(Geodesic.nA3_ - 1, self._A3x, 0, eps)
def _A3f(self, eps):
"""Private: return A3"""
# Evaluate A3
return Math.polyval(Geodesic.nA3_ - 1, self._A3x, 0, eps)
def _A3coeff(self):
"""Private: return coefficients for A3"""
coeff = [
-3, 128,
-2, -3, 64,
-1, -3, -1, 16,
3, -1, -2, 8,
1, -1, 2,
1, 1,
]
o = 0; k = 0
for j in range(Geodesic.nA3_ - 1, -1, -1): # coeff of eps^j
m = min(Geodesic.nA3_ - j - 1, j) # order of polynomial in n
self._A3x[k] = Math.polyval(m, coeff, o, self._n) / coeff[o + m + 1]
k += 1
o += m + 2
def _A2m1f(eps):
"""Private: return A2-1"""
coeff = [
-11, -28, -192, 0, 256,
]
m = Geodesic.nA2_//2
t = Math.polyval(m, coeff, 0, Math.sq(eps)) / coeff[m + 1]
return (t - eps) / (1 + eps)
_A2m1f = staticmethod(_A2m1f)
def _C4f(self, eps, c):
"""Private: return C4"""
# Evaluate C4 coeffs by Horner's method
# Elements c[0] thru c[nC4_ - 1] are set
mult = 1
o = 0
for l in range(Geodesic.nC4_): # l is index of C4[l]
m = Geodesic.nC4_ - l - 1 # order of polynomial in eps
c[l] = mult * Math.polyval(m, self._C4x, o, eps)
o += m + 1
mult *= eps