Differentiate with respect to vector

I have this problem:

$\displaystyle L=\frac{\mathbf{a}^T\mathbf{w}\mathbf{w}^T\mathbf{ a}}{\mathbf{w}^T(\mathbf{B}\mathbf{w}+\mathbf{C}\m athbf{w})}$

Here, $\displaystyle \mathbf{a}$ is a known d-by-1 vector, $\displaystyle \mathbf{w}$ is a d-by-1 vector to be identified, both $\displaystyle \mathbf{B}$ and $\displaystyle \mathbf{C}$ are known d-by-d matrix.

And I want to find the maximum value of L by taking the first order derivative with respect to $\displaystyle \mathbf{w}$.

Can anyone teach me how to take the first order derivative of this scalar with respect to a vector here?

Thanks a lot!!