`diag` construct a diagnonal matrix.

diagm(x)

Arguments

x

a vector or 1D array.

Value

a matrix with `x` as diagonal and zero off-diagonal entries.