我正在尝试使用Python中的for循环生成一个简单的Toeplitz矩阵
a = np.array([[3,4,6]])
b = np.zeros((np.size(a),np.size(a)))
b[0,:] = a
b[:,0] = a
for i in range(1,np.size(a)):
for j in range(1,np.size(a)):
a[i,j] = a[i-1,j-1]
应该是有效的,除非我遗漏了什么,但是给出了这个错误:
a[i,j] = a[i-1,j-1]
IndexError: index 1 is out of bounds for axis 0 with size 1
如果没有scipy内置的toeplitz()函数,如何让它成为Toeplitz你能帮上忙吗?
发布于 2021-03-17 03:30:13
我相信你的意思是
b[i,j] = b[i-1,j-1]
而不是a,它显然只有一个维度。
https://stackoverflow.com/questions/66666576
复制相似问题