📜  numpy.vander()函数| Python

📅  最后修改于: 2022-05-13 01:55:34.711000             🧑  作者: Mango

numpy.vander()函数| Python

numpy.vander()函数用于生成 Vandermonde 矩阵。

代码#1:

# Python program explaining
# numpy.vander() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.array([1, 2, 3, 4, 5])
  
gfg = geek.vander(arr)
  
print (gfg)

输出 :

[[  1   1   1   1   1]
 [ 16   8   4   2   1]
 [ 81  27   9   3   1]
 [256  64  16   4   1]
 [625 125  25   5   1]]


代码#2:

# Python program explaining
# numpy.vander() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.array([1, 2, 3, 4, 5])
N = 3
  
gfg = geek.vander(arr, N)
  
print (gfg)

输出 :

[[ 1  1  1]
 [ 4  2  1]
 [ 9  3  1]
 [16  4  1]
 [25  5  1]]


代码#3:

# Python program explaining
# numpy.vander() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.array([1, 2, 3, 4, 5])
  
gfg = geek.vander(arr, increasing = True)
  
print (gfg)

输出 :

[[  1   1   1   1   1]
 [  1   2   4   8  16]
 [  1   3   9  27  81]
 [  1   4  16  64 256]
 [  1   5  25 125 625]]