How to generalize matrix multiplication?

540 Views Asked by At

Consider expression $x^T A x$, where $x$ is a vector of size $5 \times 1$ and $A$ is a matrix of size $5 \times 5$. The result of the expression will be a constant.

Now, how to generalize this expression, so a vector of constants of size $n \times 1$ is computed for $x$ being a matrix $5 \times n$.

If the formula is not changed then the result is a matrix of size $n \times n$, which is of course not the desired answer.

The solution can be the following sum(x'*A .* x', 2).

Question: Is there a more elegant approach?