diag

diag(x)

diag(x, k)

Try it yourself:

All functions