I am trying to solve an SDP problem where `M = [n x n]`

symmetric matrix and `k`

is an integer `1 <= k <= n-1`

, `D = [1, e'; e, eye(n-1)]`

where e is a vector of 1s.

```
cvx_begin sdp
variable X(n,n) symmetric
maximize(trace(M*X))
diag(X) == 1;
trace(D*X) == 4*k;
X >= 0;
cvx_end
```

I end up with a matrix `X`

that has a small negative eigenvalue. Is that expected? I would like to add the absolute value of this negative eigenvalue to the diagonal elements of `X`

and use that as a PSD matrix. Are there better ways to get a completely PSD matrix `X`

.