Python: Resize an existing array and fill with zeros
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I think that my issue should be really simple, yet I can not find any help on the Internet whatsoever. I am very new to Python, so it is possible that I am missing something very obvious. I have an array, S, like this [x x x] (one-dimensional) . I now create a diagonal matrix, sigma , with np.diag(S) - so far, so good. Now, I want to resize this new diagonal array so that I can multiply it by another array that I have. import numpy as np ... shape = np . shape (( 6 , 6 )) #This will be some pre-determined size sigma = np . diag ( S