Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个矩阵 (n*1),我想用它制作一个对角矩阵。但我不能用 numpy 构造它。我尝试了 numpy 中的每种方法,例如this中的方法
import numpy arr = numpy.array([1,2,3]) mat = numpy.diag(arr) print(mat) >>> [[1 0 0] [0 2 0] [0 0 3]]