當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python Numpy np.chebvander()用法及代碼示例

借助np.chebvander()方法,我們可以從給定的具有度數的數組中獲得Pseudo-Vandermonde矩陣,該矩陣通過使用np.chebvander()方法。

用法: np.chebvander(array, degree)
返回:Return the matrix having size i.e array.size + (degree + 1).

範例1:
在這個例子中,我們可以通過使用np.chebvander()方法,我們能夠使用此方法獲得pseudo-vandermonde矩陣。


# import numpy 
import numpy as np 
import numpy.polynomial.chebyshev as cheb 
  
# using np.chebvander() method 
gfg = cheb.chebvander((2, 4, 8, 1), 2) 
  
print(gfg)

輸出:

[[ 1. 2. 7.]
[ 1. 4. 31.]
[ 1. 8. 127.]
[ 1. 1. 1.]]

範例2:

# import numpy 
import numpy as np 
import numpy.polynomial.chebyshev as cheb 
  
# using np.chebvander() method 
gfg = cheb.chebvander((3, 5, 1, 10), 4) 
  
print(gfg)

輸出:

[[1.0000e+00 3.0000e+00 1.7000e+01 9.9000e+01 5.7700e+02]
[1.0000e+00 5.0000e+00 4.9000e+01 4.8500e+02 4.8010e+03]
[1.0000e+00 1.0000e+00 1.0000e+00 1.0000e+00 1.0000e+00]
[1.0000e+00 1.0000e+01 1.9900e+02 3.9700e+03 7.9201e+04]]



相關用法


注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python | Numpy np.chebvander() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。