For any column vector we can easily create a corresponding diagonal matrix, whose elements along the diagonal are the elements of the column vector.

Is there a simple way to write this transformation using standard linear algebra operations (such as matrix multiplication, etc.), instead of explicitly writing it as $diag(\mathbf{x})$?

For example $M \mathbf{x}$ cannot work for any matrix M, since the result will be a vector, not a diagonal matrix. But maybe there is some more elaborate expression that yields the diagonal matrix.

1more comment