Inserting diagonal elements

We can create a diagonal matrix from an array of its diagonal elements.

>>> D = np.diagflat([1,2,3])
>>> print(D)
[[1 0 0]
 [0 2 0]
 [0 0 3]]