Let us first recall [Specht's Theorem][1]. Denote by $\text{Mat}_{\mathbb{C}}(n)$ the set of all $n\times n$ matrices over the complex field $\mathbb{C}$. Let $A$ be a matrix in $\text{Mat}_{\mathbb{C}}(n)$ and denote by $A^*$ its conjugate transpose. A word $w(A,A^*)$ of $A$ and $A^*$ is an expression of the form 
$$
A^{n_1}\cdot (A^*)^{m_1}\cdot\cdots\cdot A^{n_k}\cdot (A^*)^{m_k}
$$ 
where ``$\cdot$'' represent matrix multiplication, $A^i$ is the $i$th power of $A$ (similarly for $(A^*)^i$) and $n_1,m_1,\ldots,n_k,m_k$ are non-negative integers.
The length of a word is given by $n_1+n_2+\cdots+n_k+m_1+\cdots+m_k$.

**Spechts's Theorem:** Given two matrices $A$ and $B$ in $\text{Mat}_{\mathbb{C}}(n)$. Then, $A=U\cdot B\cdot U^*$ for some unitary matrix $U$ *if and only if* 
$$
\text{tr}(w(A,A^*))=\text{tr}(w(B,B^*))
$$
for all words $w$. Here, $\text{tr}(\cdot)$ is the standard trace function on matrices.

Let us now replace the trace function by the ``sum of all entries'' function $\sigma$ defined as
$$
\sigma:\text{Mat}_{\mathbb{C}}(n) \to \mathbb{C}: A=(a_{ij})\mapsto \sigma(A)=\sum_{i=1}^n\sum_{j=1}^n a_{ij}.$$ 
It is known that the functions $s(\cdot)$ and $\text{tr}(\cdot)$ share certain properties, see e.g.,  [Merikoski: On the trace and the sum of elements of a matrix][3], Linear Algebra and its applications, Volume 60, August 1984, pp. 177-185.

But what is known for two matrices $A$ and $B$ such that 
$$
\sigma(w(A,A^*))=\sigma(w(B,B^*))\tag{1}
$$
for all words $w$?

**Question:** Is a Specht-like characterisation of matrices satisfying the conditions (1) known? Moreover, 

 -  Is the equivalence relation $A\equiv_s B$ iff $\sigma(w(A,A^*))=\sigma(w(B,B^*))
$
for all words $w$ studied before?
 - What about  $A\equiv_s^K B$ iff $\sigma(w(A,A^*))=\sigma(w(B,B^*))
$
for all words *of length less than $K$*?
 - Can it be that $A\equiv_s^K B$ but $A\not\equiv_s^{K+1} B$?
 - What if we restrict $A$ and $B$ to (non-negative) real matrices?

Any pointers to related work or insights are welcome.

**UPDATE:** A *sufficient* condition seems to be that $P\cdot B=A\cdot P$ and $P\cdot B^*=A^*\cdot P$ for a matrix $P\in\text{Mat}_{\mathbb{C}}(n)$ such that $P\cdot \mathbf{e}=\mathbf{e}$ and $\mathbf{e}^t\cdot P=\mathbf{e}^t$, where $\mathbf{e}$ is the $n\times 1$ vector consisting entirely out of $1$'s (so $P$ is doubly stochastic). Indeed,

 - first note that  $s(w(A,A^*))=\mathbf{e}^t\cdot w(A,A^*)\cdot \mathbf{e}$;
 - then, assume that  $w(A,A^*)=w'(A,A^*)\cdot A$ for some smaller word $w'$. (The case that $w(A,A^*)=w'(A,A^*)\cdot A^*$ is analogous). Note that $$w(A,A^*)\cdot\mathbf{e}=w'(A,A^*)\cdot A\cdot\mathbf{e}=w'(A,A^*)\cdot A
\cdot P\cdot \mathbf{e}=w'(A,A^*)\cdot P\cdot B\cdot\mathbf{e}.$$ An inductive argument shows that $w(A,A^*)\cdot\mathbf{e}=P\cdot w(B,B^*)\cdot\mathbf{e}$. Then, it suffices to note that $$\mathbf{e}^t\cdot w(A,A^*)\cdot\mathbf{e}=\mathbf{e}^t\cdot P\cdot w(B,B^*)\cdot\mathbf{e}=\mathbf{e}^t\cdot w(B,B^*)\cdot\mathbf{e},$$ or that $s(w(A,A^*))=s(w(B,B^*))$.

This hold for any word $w$.

The question is now whether equation (1) also implies the existence of a matrix $P\in\text{Mat}_{\mathbb{C}}(n)$ such that $P\cdot \mathbf{e}=\mathbf{e}$ and $\mathbf{e}^t\cdot P=\mathbf{e}^t$, and such that $P\cdot B=A\cdot P$ and $P\cdot B^*=A^*\cdot P$ for the given matrices $A$ and $B$.



  [1]: https://en.wikipedia.org/wiki/Specht%27s_theorem
  [2]: https://gdz.sub.uni-goettingen.de/id/PPN37721857X_0050?tify=%7B%22pages%22:[25],%22view%22:%22toc%22%7D
  [3]: http://dx.doi.org/10.1016/0024-3795%2884%2990078-8