本文整理匯總了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