Suppose we have a fixed n x n matrix, call it $B$. What is fastest way to evaluate $v^t B\;v$ over many different vectors $v$?
Since $B$ is a constant matrix, does this allow the number of operations needed to evaluate $v^t B\;v$ for an arbitrary $v$ to be reduced?
v
is a vector of vectors,v == {v1, v2, ...}
, the direct way is this:Table[x.b.x, {x, v}]
. This is quite fast. We can improve a bit by doing part of the multiplication in a single go:r = v.b; Table[v[[i]].r[[i]], {i, Length[v]}]
. This is a bit faster. I don't know how to do theTable
part in one go while avoiding unpacking the arrays. $\endgroup$