Invert a diagonal matrix which is passed as a vector. If any elements are zero, set them to one.

diag_inverse(x)

Arguments

x

a numeric vector

Value

a diagonal matrix