當前位置: 首頁>>代碼示例>>Python>>正文


Python chebyshev.cheb2poly方法代碼示例

本文整理匯總了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 
開發者ID:CalebBell,項目名稱:fluids,代碼行數:19,代碼來源:pychebfun.py

示例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]) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test_chebyshev.py

示例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]) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:5,代碼來源:test_chebyshev.py

示例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 
開發者ID:CalebBell,項目名稱:fluids,代碼行數:15,代碼來源:pychebfun.py

示例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 
開發者ID:HazyResearch,項目名稱:learning-circuits,代碼行數:17,代碼來源:ops.py


注:本文中的numpy.polynomial.chebyshev.cheb2poly方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。