I've been trying to generalize a vector-matrix-vector product that represents the $i$th element of a vector $v$, but I can't figure out how to put it into a concise form.
Let $v \in \mathbb{R}^{n}$ be the vector in question. Let $K \in \mathbb{R}^{n \times m}$ and $R \in \mathbb{R}^{m \times m}$ be matrices. I also define $k_i \in \mathbb{R}^{1 \times m}$ to be the $i$th row of $K$. The $i$th element of the vector $v$ is \begin{equation} v_i = k_i R k_i^T. \end{equation}
How can I write the whole vector $v$ in terms of $K$ and $R$? I also suspect it could require vectorization or Kronecker products.
The closest I think I've gotten is something like this: \begin{equation} K[\underbrace{R,R,\ldots,R}_{\text{repeated }n \text{ times,}\\ \text{so } m \times nm}]\underbrace{\text{vec}(K^T)}_{nm \times 1}, \end{equation} where vec$(\cdot)$ represents vectorization, i.e., the stacking of vector columns. However, this only works if I could somehow keep just the diagonal blocks of $K[R,R,\ldots,R]$ so that it becomes \begin{equation*} K[R,R,\ldots,R] = \begin{bmatrix} k_1 R & & & \\ & k_2R & & \\ & & \ddots & \\ & & & k_nR \\ \end{bmatrix}. \end{equation*} Then I would have \begin{equation*} \begin{bmatrix} k_1 R & & & \\ & k_2R & & \\ & & \ddots & \\ & & & k_nR \\ \end{bmatrix} \begin{bmatrix} k_1^T \\ k_2^T \\ \vdots \\ k_n^T \\ \end{bmatrix}. \end{equation*}
We have that:
$$\boxed{v = \text{diag}(K\,R\,K^T)}$$
We can define a $3rd$ order tensor $T$, such that:
$$T_{ijk} = \delta_{ij}\,\delta_{ik}$$
(this is not Einstein notation, so there is no summation over the $i$-index)
Therefore, $T_{ijk} = A^{(i)}_{jk}$, where the matrices $A^{(i)}$ are given by:
$$A^{(1)} = \begin{bmatrix} 1 & 0 & ... & 0\\ 0 & 0 & ... & 0\\ \vdots & \vdots & \vdots & \vdots\\ 0 & 0 & 0 & 0 \end{bmatrix}$$
$$A^{(2)} = \begin{bmatrix} 0 & 0 & ... & 0\\ 0 & 1 & ... & 0\\ \vdots & \vdots & \vdots & \vdots\\ 0 & 0 & 0 & 0 \end{bmatrix}$$
$$A^{(m)} = \begin{bmatrix} 0 & 0 & ... & 0\\ 0 & 0 & ... & 0\\ \vdots & \vdots & \vdots & \vdots\\ 0 & 0 & 0 & 1 \end{bmatrix}$$
Using this tensor, we have that:
$$\boxed{v_i = T_{ijk}\,K_{km}\,R_{mn}\,K_{jn}}$$
(now it is Einstein notation)
Alternatively:
$$\boxed{v = T : \left[K \cdot R \cdot K^T\right]}$$