Positive definite part of a symmetric matrix - or: are the positive definite matrices a retract of the set of symmetric matrices? $\newcommand{\Sym}{\operatorname{Sym}}$
Denote by $\Sym(n)$ the set of symmetric, real $n\times n$ matrices and let $\iota:\Sym^+(n)\hookrightarrow \Sym(n)$ be the subset of positive definite matrices with its standard topologies. My question: is there a continuous map $r:\Sym(n)\to \Sym^+(n)$ with $r\circ\iota=\operatorname{id}_{\Sym^+(n)}$ (a retraction), i.e. can we speak of a positive definite part $r(A)$ of a symmetric matrix $A$?
 A: If you want to retract onto the positive definite matrices, the answer is no.  The positive definite matrices form an open subset of the real symmetric matrices (which form a connected manifold), so it's not possible to retract onto them.
However, there is a retraction onto the positive semidefinite matrices, as Michael Hardy describes.  To implement the retraction, you must start by orthogonally diagonalizing the matrix:
$$
A \;=\; O^T D\,O.
$$
Here $O$ is an orthogonal matrix, and $D$ is a diagonal matrix.  Next, let $D\,'$ be the diagonal matrix obtained by replacing each negative entry of $D$ with a zero.  Then
$$
r(A) \;=\; O^T D\,'O
$$
Though it's not quite obvious, this map doesn't depend on the orthogonal diagonalization chosen.  In particular, the map $r$ can also be defined by
$$
r(A) \;=\; P^T\,A\,P
$$
where $P$ is the orthogonal projection of $\mathbb{R}^n$ onto the sum of the positive eigenspaces of $A$.
To see that this is continuous, observe that the following diagram commutes:
$$
\begin{array}{ccc}
SO(n) \times \mathcal{D} & \xrightarrow{f} & SO(n)\times \mathcal{D} \\[1ex]
{\scriptstyle q}\downarrow & & \downarrow{\scriptstyle q} \\[1ex]
\mathrm{Sym}(n) & \xrightarrow{r} & \mathrm{Sym}(n)
\end{array}
$$
where $\mathcal{D}$ is the set of diagonal matrices, $q\colon SO(n)\times \mathcal{D} \to \mathrm{Sym}(n)$ is the quotient map defined by $q(O,D) = O^TD\,O$, and $f\colon SO(n)\times \mathcal{D}\to SO(n)\times \mathcal{D}$ is the map $f(O,D) = (O,D\,')$, where $D\,'$ is the nonnegative part of $D$ defined above.  Since $q$ is a quotient map and $f$ is continuous, it follows that $r$ is continuous.
A: How about this: Recall that for every real symmetric matrix $A$ there is an orthogonal matrix $G$ (i.e. $G^TG=GG^T= I$) and a diagonal matrix $\Lambda$ such that $A = G^T\Lambda G$, and $G$ may be chosen so that the diagonal entries $\lambda_i$ , $i=1,2,3\ldots$ are in decreasing order.  So change $\Lambda$ to $\Lambda^\#$ by replacing each negative $\lambda_i$ with $0$ and look at $A^\#=G^T\Lambda^\# G$.  That is a "positive-semidefinite part" of $A$. And $A$ is the sum of that part and a negative-semidefinite part found similarly.
(The notation is mine, invented on the spot.  If it conflicts with some existing notation or is otherwise infelicitous, the replace it at once.)
A: $\newcommand{\Sym}{\operatorname{Sym}}$
A friend of mine found yet another, in my opinion quite nice solution: Observe that the set $Sym^{\ge 0}(n)$ of positive semidefinite $n\times n$ matrices forms a closed convex set (actually a cone) in the Hilbertspace $\Sym(n)$. Now consider the projection $P:\Sym(n)\to\Sym^{\ge 0}(n)$, that is $$P(A)=A^+\quad\Leftrightarrow_\mathrm{def.}\quad \|A-A^+\|=\operatorname{min}_{B\in\Sym^{\ge 0}(n)}\|A-B\|.$$
Then $P$ is continuous (actually it's 1-Lipschitz) and $P(A)=A$ whenever $A$ is positive semidefinite. 
Of course, it's not clear that this $P$ actually coincides with the map that Michael and Jim already considered. But since we are asking only for the existence of a retraction, this is no problem. Also note that we have only used the closedness and convexity of $\Sym^{\ge 0}(n)$.
