How to Project a Symmetric Matrix onto the Cone of Positive Semi Definite (PSD) Matrices How would you project a symmetric real matrix onto the cone of all positive semi-definite matrices?

If you merely want to find a projection $\pi$ such that $\pi(S)$ is positive semidefinite for some fixed real symmetric matrix $S$, you may first orthogonally diagonalise $S$ as $QDQ^\top$ and then define $\pi: M\mapsto Q\Sigma Q^\top M$, where $\Sigma$ is a 0-1 diagonal matrix whose $i$-th diagonal entry is $1$ if the $i$-th diagonal entry of $D$ is nonnegative, and $0$ otherwise.
