Simplifying $\left(\nabla\vec{A}\right)\vec{B}$ to a more computationally efficient form

51 Views Asked by At

If one wanted to calculate $\left(\nabla\vec{A}\right)^T\vec{B}$ and knew that $\vec{B}$ was a constant, they could just calculate $\nabla\left({\vec{A}}^T\vec{B}\right)$ instead. This is because $$\nabla\left({\vec{A}}^T\vec{B}\right)=\left(\nabla\vec{A}\right)^T\vec{B}+\left(\nabla\vec{B}\right)^T\vec{A}$$ Where the vector gradient is defined by $$\left(\nabla\vec{A}\right)_{ij}=\left(\frac{\partial A_i}{\partial x_j}\right)$$ The reason why they should calculate it that way instead is because $\nabla\left({\vec{A}}^T\vec{B}\right)$ is calculated in O(n) whereas $\left(\nabla\vec{A}\right)^T\vec{B}$ is calculated in O(n²). I need to calculate $\left(\nabla\vec{A}\right)\vec{B}$ instead, which will also take O(n²). Is there a way I can simplify the calculation? $\vec{B}$ is still a constant.

EDIT: I've determined that $\left(\nabla\vec{A}\right)\vec{B}=\nabla\cdot\left(\vec{B}{\vec{A}}^T\right)=\left(\vec{B}\cdot\nabla\right)\vec{A}$. Not really any easier to calculate to be honest. Starting to doubt a computationally simpler method exists.