on to a matrix
<span class="math">\(W\in\mathbf{R}^{n\times n}\)</span> to make it positive semidefinite:</p>
<div class="math">
\[\begin{split}\begin{array}{ll}
    \text{minimize}   &amp; \operatorname*{\textrm{Tr}}(D) \\
    \text{subject to} &amp; W + D \succeq 0 \\
                      &amp; D ~ \text{diagonal}
\end{array}\end{split}\]</div>
<p>In CVX, this problem might be expressed as follows:</p>
<div class="highlight-none"><div class="highlight"><pre>n = size(W,1);
cvx_begin
    variable D(n,n) di