本文整理汇总了Python中numpy.polynomial.chebyshev.cheb2poly方法的典型用法代码示例。如果您正苦于以下问题:Python chebyshev.cheb2poly方法的具体用法?Python chebyshev.cheb2poly怎么用?Python chebyshev.cheb2poly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.polynomial.chebyshev
的用法示例。
在下文中一共展示了chebyshev.cheb2poly方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cheb_to_poly
# 需要导入模块: from numpy.polynomial import chebyshev [as 别名]
# 或者: from numpy.polynomial.chebyshev import cheb2poly [as 别名]
def cheb_to_poly(coeffs_or_fun, domain=None):
'''Just call horner on the outputs!
'''
from fluids.numerics import horner as horner_poly
if isinstance(coeffs_or_fun, Chebfun):
coeffs = coeffs_or_fun.coefficients()
domain = coeffs_or_fun._domain
else:
coeffs = coeffs_or_fun
low, high = domain
coeffs = cheb2poly(coeffs)[::-1].tolist() # Convert to polynomial basis
# Mix in limits to make it a normal polynomial
my_poly = Polynomial([-0.5*(high + low)*2.0/(high - low), 2.0/(high - low)])
poly_coeffs = horner_poly(coeffs, my_poly).coef[::-1].tolist()
return poly_coeffs
示例2: test_cheb2poly
# 需要导入模块: from numpy.polynomial import chebyshev [as 别名]
# 或者: from numpy.polynomial.chebyshev import cheb2poly [as 别名]
def test_cheb2poly(self):
for i in range(10):
assert_almost_equal(cheb.cheb2poly([0]*i + [1]), Tlist[i])
示例3: test_cheb2poly
# 需要导入模块: from numpy.polynomial import chebyshev [as 别名]
# 或者: from numpy.polynomial.chebyshev import cheb2poly [as 别名]
def test_cheb2poly(self) :
for i in range(10) :
assert_almost_equal(cheb.cheb2poly([0]*i + [1]), Tlist[i])
示例4: chebfun_to_poly
# 需要导入模块: from numpy.polynomial import chebyshev [as 别名]
# 或者: from numpy.polynomial.chebyshev import cheb2poly [as 别名]
def chebfun_to_poly(fun, text=False):
low, high = fun._domain
# Reverse the coefficients, and use cheb2poly to make it in the polynomial domain
poly_coeffs = cheb2poly(fun.coefficients())[::-1].tolist()
if not text:
return poly_coeffs
s = 'coeffs = %s\n' %poly_coeffs
delta = high - low
delta_sum = high + low
# Generate the expression
s += 'horner(coeffs, %.18g*(x - %.18g))' %(2.0/delta, 0.5*delta_sum)
# return the string
return s
示例5: chebyshev_transpose_mult_slow
# 需要导入模块: from numpy.polynomial import chebyshev [as 别名]
# 或者: from numpy.polynomial.chebyshev import cheb2poly [as 别名]
def chebyshev_transpose_mult_slow(v):
"""Naive multiplication P^T v where P is the matrix of coefficients of
Chebyshev polynomials.
Parameters:
v: (batch_size, n)
Return:
P^T v: (batch_size, n)
"""
n = v.shape[-1]
# Construct the coefficient matrix P for Chebyshev polynomials
P = np.zeros((n, n), dtype=np.float32)
for i, coef in enumerate(np.eye(n)):
P[i, :i + 1] = chebyshev.cheb2poly(coef)
P = torch.tensor(P)
return v @ P