grapes-w-grapes function

Computation of the matrix with rows being the linearized matrix products of X[,,i] and B.