Derivative of matrix expression involving Kronecker products Given the matrix expression
$C(f) = R  \left(  X f \otimes I \nonumber +I \otimes X f \right) X$,
where 
$R$ is $n\times n^2$, $X$ is $n\times k$, $f$ is $k\times 1$ and $I$ is an $n \times n$ identity matrix. 
What is $\frac{\partial C(f)}{\partial f}$ ?
Thanks in advance!
 A: Recall that for matrices $(X,Y,Z)$
$$\eqalign{
{\rm vec}(XYZ) &= (Z^T\otimes X)\,{\rm vec}(Y) \cr
}$$
In particular, for vectors $(a,b)$
$$\eqalign{
(a\otimes I)\,b &= {\rm vec}(ba^T) \cr
(I\otimes a)\,b &= {\rm vec}(ab^T) \cr
}$$
Isolate the components of $C$ by multiplying by $e_i^T$ and $\varepsilon_j\;$ 
where 
$\quad e_i$ is the $i^{th}$ column of the ${n\times n}\,$ identity matrix,   and
$\quad\varepsilon_j$ is the $j^{th}$ column of the ${k\times k}\,$ identity matrix.
Then substitute
 $\,(a=Xf,\;b=X\varepsilon_j)\;$ and use the above vec-formulas to obtain
$$\eqalign{
C_{ij}
 = (e_i^TC\varepsilon_j)
 &= e_i^TR\,\Big(a\otimes I+I\otimes a\Big)\,b \\
 &= e_i^TR\;\;{\rm vec}\Big(ba^T+ab^T\Big) \\
 &= e_i^TR\;\;{\rm vec}\Big(X\varepsilon_jf^TX^T+Xf\varepsilon_j^TX^T\Big) \\
 &= e_i^TR\,\Big(X\otimes X\varepsilon_j+X\varepsilon_j\otimes X\Big)\,f \\
}$$
With this reformulation, the derivative is immediately seen to be
$$\frac{\partial C_{ij}}{\partial f_m}
 = e_i^TR\,\Big(X\otimes X\varepsilon_j+X\varepsilon_j\otimes X\Big)\,\varepsilon_m
$$
