TITLE: Projecting onto space of matrices with spectral radius less than one
QUESTION [7 upvotes]: Consider the space
$$ S = \left\{ A \in \mathbb{R}^{n \times n} : \mathrm{SpectralRadius}(|A|) \leq 1 \right\}$$
where $|A|$ is the entry-wise absolute value. Given a matrix $M \in \mathbb{R}^{n\times n}$ such that $M \not \in S$. Is there a way to solve
$$\arg\min_{\hat M \in S} \Vert M - \hat M \Vert$$ for some matrix norm $\Vert \cdot \Vert$? That is, is there a (hopefully somewhat simple) operator that projects onto $S$ for some matrix norm?
For context, I'm interested in optimising a function $f:\mathbb{R}^{n\times n} \rightarrow \mathbb{R}$ over this space using stochastic gradient descent. This means that I'd have to perform this projection after every optimisation step. I know that in general $S$ is non-convex and so I won't have any guarantees.

Edit: I'm interested in the case with the absolute value. However, someone noted in a comment that the scenario may simplify if we consider the space $$S' = \left\{ A \in \mathbb{R}^{n \times n} : \mathrm{SpectralRadius}(A) \leq 1 \right\}$$ Maybe to start, is there a simpler answer in this case?

REPLY [2 votes]: For the version without the absolute value, a colleague and I published a few months ago an algorithm to solve that optimization problem and other related ones (the problem you need is called "Schur stable" case in the paper). Some competitors are mentioned in the introduction and in the section with numerical experiments, but I believe ours is the fastest algorithm available as of today. It is not too simple as it relies on optimization on manifolds, however this is not a simple problem in general: the constraint on the eigenvalues is non-smooth and tricky to handle numerically.
We have also published on https://github.com/fph/nearest-omega-stable some proof-of-concept Matlab code that you can use.