Consider the following;
$$ J = L^{\text{T}}KR $$
where
$$ L \in \mathbb{R}^{p}, ~~ K \in \mathbb{R}^{p \times m}, ~~ r \in \mathbb{R}^{m} $$
I am attempting to find $ \frac{dJ}{dK}$. This is what I have done so far;
\begin{align} J &= \begin{bmatrix} \ell_1 & \ell_2 & \dotsm & \ell_p \end{bmatrix} \begin{bmatrix} k_{1,1} & k_{1,2} & \dotsm & k_{1,m} \\ k_{2,1} & k_{2,2} & \dotsm & k_{2,m} \\ \vdots & \vdots & \ddots & \vdots \\ k_{p,1} & k_{p,2} & \dotsm & k_{p,m} \end{bmatrix} \begin{bmatrix} r_1 \\ r_2 \\ \vdots \\ r_m \end{bmatrix} \\[0.5em] &= \ell_1 (k_{1,1}r_1 + k_{1,2}r_2 + \cdots + k_{1,m}r_m) + \\ &~~~~~ \ell_2 (k_{2,1}r_1 + k_{2,2}r_2 + \cdots + k_{2,m}r_m)+ \\ &~~~~~ \cdots + \\ &~~~~~ \ell_p (k_{p,1}r_1 + k_{p,2}r_2 + \cdots + k_{p,m}r_m) \end{align}
and so, \begin{align} \frac{dJ}{dK} &= \ell_1 (r_1 + r_2 + \cdots + r_m) + \\ &~~~~~ \ell_2 (r_1 + r_2 + \cdots + r_m)+ \\ &~~~~~ \cdots + \\ &~~~~~ \ell_p (r_1 + r_2 + \cdots + r_m) \\ \\[0.5em] &= L^{\text{T}} [1]_{p \times m} R \end{align}
where $ [1]_{p \times m} $ is a $p \times m$ matrix of all ones.
My question is this: 1) did I do this properly, and 2) is there a more elegant way to express the solution?