I have a $n \times n$ matrix $A$ with a full set of eigenvalues $\lambda$ including repetitions.
I want to create the following $i \times i$ matrix:
$$\left(\sum_{a=2}^i (a-1) |a-1⟩⟨a| \right) + \sum_{j=1}^i d_j \sum_{b=j}^i |b⟩⟨b-j+1| $$
where $|1⟩,...,|i⟩$ is the standard basis and $d_j (\lambda) = \sum_{c=1}^n \lambda_c^j$.
Any help with coding this matrix in Mathematica would be greatly appreciated.