Transform this diagonal vector as needed.
Use diag twice to replace the original diagonal with a new diagonal.
(The first one changes all the diagonal lines of the matrix to 0, and the second one adds a new diagonal line. )