Say I have a matrix of shape (2,3), I need to diagonalize the 3-elements vector into matrix of shape (3,3), for all the 2 vectors at once. That is, I need to return matrix with shape (2,3,3). How can I do that with Numpy elegantly ? given data = np.array([[1,2,3],[4,5,6]]) i want the result [[[1,0,0], [0,2,0], [0,0,3]], [[4,0,0], [0,5,0], [0,0,6]]] Thanks Continue reading...