Lie group of matrices commuting with a fixed set of matrices Given a set of $S$ of $ n\times n$ Hermitian matrices with entries in $\mathbb{C}$, the set of all $n\times n$ unitary matrices that commute with $S$ forms a Lie group $G$. My question is what Lie groups can we get from this process by choice of $n$ and $S$? We can get any products of unitary groups of the form $U(p)\times U(q)\times U(r)...$  by taking S to be a matrix with $p$ eigenvalues equal to $0$, $q$ eigenvalues equal to $1$ and $r$ eigenvalues equal to $2$ and so on. Is that the only possibility? Or can I get a group isomorphic to $U(1)\times Sp(m)$ or something? (We're always going to have a factor of $U(1)$  since the identity matrix commutes with everything. Like literally everything.) I can think of neither a counterexample nor a proof.
If I can get other Lie groups than the natural follow up questions would be: What Lie groups can I get? Is there a nice construction get a set $S$ given a Lie group $G$? What representations of $G$ can I get? 
 A: If $A$ is a Hermitian matrix whose distinct eigenvalues $\lambda_1,\ldots,\lambda_p$ have multiplicities $n_1,\ldots,n_p$ ($\sum n_j = n$), then $A=QDQ^\ast$ where $D=(\lambda_1 I_{n_1}) \oplus\ldots\oplus(\lambda_p I_{n_p})$ and $Q$ is some unitary matrix. Therefore, all unitary matrices that commute with $A$ are of the form $QUQ^\ast$, where $U=U_{n_1}\oplus\ldots\oplus U_{n_p}$ with each $U_{n_j}$ being an $n_j\times n_j$ unitary matrix. In other words, if $A$ is the only element in $S$, the Lie group $G$ in question is isomorphic to $U(n_1)\times\ldots\times U(n_p)$.

Edit: I misread the question and thought that $S$ is a matrix. $S$ should be a set of Hermitian matrices. So I have the following elaboration.
If $S$ contains more than one elements, things get more complicated. For example, it may happen that the only matrices that commute with all elements in $S$ are multiples of the identity matrix. Let $J(m) = \{\omega I_m: \omega\in\mathbb{C},\ |\omega|=1\}$. We claim that in general, the Lie group $G$ in question is isomorphic to some
$$
U(n_1)\times\ldots\times U(n_p)\times J(m_1)\times\ldots\times J(m_q)
$$
with $\sum_i n_i + \sum_j m_j = n$.
Here is a sketch of proof. For convenience, let $T_A:\mathbb{C}^n\mapsto \mathbb{C}^n$ denotes the linear map $x\mapsto Ax$. We say that a vector subspace is an invariant subspace to $S$ if it is invariant to every $A\in S$. Now, among all nonzero invariant subspaces to $S$ (including $\mathbb{C}^n$), choose the one, say $V$, with minimum dimension. Since every $A\in S$ is Hermitian, $V^\perp$ is also invariant to $S$. Again, we choose, among all nonzero subspaces of $V^\perp$ that is invariant to $S$, one that is of minimum dimension. Continue in this manner, we have $\mathbb{C}^n = V\oplus W_1\oplus\ldots\oplus W_q$ where $V$ is the direct sum of a number of 1-dimensional invariant subspaces to $S$ and each $W_i$ is a minimal invariant subspace to $S$ with dimension $\ge2$. Since one-dimensional invariant subspaces are eigenspaces, we may write $V=V_1\oplus\ldots\oplus V_p$ so that $T_A|_{V_j}=\lambda\ {\rm id}$ for some eigenvalue $\lambda$ (that is dependent on $A$ and $V_j$). We write $n_j=\dim(V_j)$ and $m_j=\dim(W_j)$.
Hence, with some unitary matrix $Q$, each $A\in S$ can be written in the form of $QDQ^\ast$, where $D$ is a block diagonal matrix with a common block structure $(\lambda_1 I_{n_1}) \oplus\ldots\oplus(\lambda_p I_{n_p})\oplus A_1\oplus\ldots\oplus A_q$ (each $A_i$ is a $m_i\times m_i$ matrix). For any fixed pair of indices $i\not=j$, we can have $\lambda_i\not=\lambda_j$ for some but not for all $A\in S$. It is this block structure that gives rise to the above-mentioned Lie group.
