I need to multiply three matrices X(Nxk), FF(kxk) and X(Nxk) (again). Which is t(xi) * FF * xi, where xi is the ith row of X, i=1:N. The result will be a single column matrix with N rows. The multiplication also can be regarded also as X * FF * t(X).
(Nxk) stands for "N rows, k columns", * is algebraic multiplication, t() transposing.
The problem is that N is quite large (more than 100k). I found some advises for fast multiplication by using drop and sweep. But they consider only the half of the problem - multiplication of vector by matrix.
I want to avoid the multiplication on two stages A=XFF and then At(X) because of the size of X. So what I need is some function or hint, which multiply the three matrices at once (well, as much as possible) in order to make the calculation as fast as possible in R.