Given the fat matrix ${\bf A} \in \mathbb{C}^{M \times Q}$ (where $M < Q$), the tall matrix ${\bf B} \in \mathbb{C}^{Q \times N}$ (where $Q > N$) and ${\bf C} \in \mathbb{C}^{M \times N}$, how to solve the following linear matrix equation for diagonal matrix ${\bf \Lambda} \in \mathbb{C}^{Q \times Q}$?
$$ {\bf A} {\bf \Lambda} {\bf B} = {\bf C} $$
$ \def\LR#1{\left(#1\right)} \def\op#1{\operatorname{#1}} \def\diag#1{\op{diag}\LR{#1}} \def\Diag#1{\op{Diag}\LR{#1}} \def\trace#1{\op{Tr}\LR{#1}} \def\frob#1{\left\| #1 \right\|_F} \def\qiq{\quad\implies\quad} \def\p{\partial} \def\grad#1#2{\frac{\p #1}{\p #2}} \def\c#1{\color{red}{#1}} \def\CLR#1{\c{\LR{#1}}} \def\fracLR#1#2{\LR{\frac{#1}{#2}}} \def\gradLR#1#2{\LR{\grad{#1}{#2}}} $First, introduce the extremely useful Frobenius $(:)$ product $$\eqalign{ F:G &= \sum_{i=1}^m\sum_{j=1}^n F_{ij}G_{ij} \;=\; \trace{F^TG} \\ F^*:F &= \frob{F}^2 \qquad \{ {\rm Frobenius\;norm} \}\\ F:G &= G:F \;=\; G^T:F^T \\ H:\LR{FG} &= \LR{HG^T}:F \;=\; \LR{F^TH}:G \\ }$$ and a diagonalization identity involving the Hadamard $(\odot)$ product $$ \diag{A\cdot\Diag{x}\cdot B} \;\equiv\; \LR{B^T\odot A}x $$ Then approach this as a least squares problem $$\eqalign{ &M = A\cdot\Diag{x}\cdot B \;-\; C \\ &\min_x\: \frob{M}^2 }$$ Calculate the gradient of the least squares objective function wrt the $x$ vector $$\eqalign{ \phi &= {M^*:M} \\ d\phi &= M^*:\c{dM} \\ &= M^*:\CLR{A\cdot\Diag{dx}\cdot B} \\ &= \LR{A^TM^*B^T}:\Diag{dx} \\ &= \diag{A^TM^*B^T}:dx \\ &= \diag{A^TA^*\cdot\Diag{x^*}\cdot B^*B^T - A^TC^*B^T}:dx \\ \grad{\phi}{x} &= \LR{BB^H\odot A^TA^*}x^* - \diag{A^TC^*B^T} \\ }$$ Conjugate the gradient, set it to zero and solve for the optimal $x$ $$\eqalign{ x &= \LR{B^*B^T\odot A^HA}^{\boldsymbol +}\diag{A^HCB^H} \\ {\large\Lambda} &= \Diag{x} \\ }$$ where
$\quad M^+\:$ denotes the pseudoinverse of $M$
$\quad M^T,M^*,M^H\:$ denote the transpose, complex and hermitian conjugates
$\quad\Diag{}\:$ creates a diagonal matrix from its vector argument
$\quad\diag{}\;$ returns the main diagonal of its matrix argument as a column vector