Python | 范德蒙矩阵
Python | 范德蒙矩阵
A Vandermonde Matrix is a square matrix (having size nxn), if and only if there are scalars, x1, x2 , x3,…, xn such that,
当且仅当存在标量x 1 ,x 2 ,x 3 ,…,x n时 ,Vandermonde矩阵是方矩阵(大小为n x n ),
![vandermonde matrix in Python](https://www.includehelp.com/python/images/vandermonde-matrix.jpg)
Source: https://en.wikipedia.org/wiki/Vandermonde_matrix
资料来源: https : //en.wikipedia.org/wiki/Vandermonde_matrix
Python numpy package allows us to create a Vandermonde Matrix by providing an inbuilt function numpy.vander().
Python numpy包允许我们通过提供内置函数numpy.vander()创建Vandermonde矩阵。
Vandermonde矩阵的Python代码 (Python code for vandermonde matrix)
# Linear Algebra Learning Sequence
# Vandermonde Matriximport numpy as npx = np.array([1, 2, 3, 5])
N = 3
v1 = np.vander(x)print('Vector x :\n', x)
print('Vandermonde Matrix of vector x', v1)y = np.array([4,5,6,7,8,9])
N = 4
v2 = np.vander(y, N)
v3 = np.vander(y)print('\n\nVector y :\n', y)
print('Vandermonde Matrix of vector y (N = 4): ', v2)
print('\n\n Vandermonde Matrix (Square) of vector y : ', v3)
Output:
输出:
Vector x :[1 2 3 5]
Vandermonde Matrix of vector x [[ 1 1 1 1][ 8 4 2 1][ 27 9 3 1][125 25 5 1]]Vector y :[4 5 6 7 8 9]
Vandermonde Matrix of vector y (N = 4): [[ 64 16 4 1][125 25 5 1][216 36 6 1][343 49 7 1][512 64 8 1][729 81 9 1]]Vandermonde Matrix (Square) of vector y : [[ 1024 256 64 16 4 1][ 3125 625 125 25 5 1][ 7776 1296 216 36 6 1][16807 2401 343 49 7 1][32768 4096 512 64 8 1][59049 6561 729 81 9 1]]
翻译自: https://www.includehelp.com/python/vandermonde-matrix.aspx