我认为我的问题应该很简单,但我无法在互联网上找到任何帮助.我是Python的新手,所以我可能会遗漏一些非常明显的东西.
我有一个数组,S,就像这样[x x x] (one-dimensional).我现在创建一个对角矩阵,sigma与np.diag(S)-到目前为止,那么好.现在,我想调整这个新的对角线数组的大小,以便我可以将它乘以我拥有的另一个数组.
import numpy as np
...
shape = np.shape((6, 6)) #This will be some pre-determined size
sigma = np.diag(S) #diagonalise the matrix - this works
my_sigma = sigma.resize(shape) #Resize the matrix and fill with zeros - returns "None" - why?
Run Code Online (Sandbox Code Playgroud)
但是,当我打印出内容时my_sigma,我明白了"None".有人可以指出我正确的方向,因为我无法想象这应该是如此复杂.
在此先感谢您的帮助!
卡斯帕
图形:
我有这个:
[x x x]
Run Code Online (Sandbox Code Playgroud)
我要这个:
[x 0 0]
[0 x 0]
[0 0 x]
[0 0 0]
[0 0 0]
[0 0 …Run Code Online (Sandbox Code Playgroud)