I have a matrix equation that yields a scalar
$$f(M) = MAM^T - 2 \sum_i^{N} \log(M_i)$$
Where $M$ is a $1 \times N$ row vector, and $A$ is an $N \times N$ matrix. As such, the result $f$ is a scalar.
How does one take the derivative of $f$ w.r.t $M$? I have seen matrix cookbook define derivatives of matrices w.r.t specific index values, but I couldn't find a definition of differentiation w.r.t vectors.
My intuition is something like
$$\frac{\partial f}{\partial M} = 2(AM - M^{\circ -1})$$
with my reasoning being the two $M$'s in the first term yield $2AM$ once differentiated, and the log term yields $M$ where each element is raised to the $-1$ power ($\frac{d \log x}{dx} = x^{-1}$).
Again, I'm not sure if I've done this correctly, and the fact that $f$ is a scalar makes it a bit more confusing.