Given a 1-D vector $v$, if asked to calculate $\sum_{i} v_i^2$, one can use a dot product trick: $\sum_{i} v_i^2 = v^T v$.
I have a 2-D matrix $X$, and similarly want to calculate $\sum_{j} \sum_{k} X_{j, k}^2$.
How can one use dot product in this case? Does a similar dot product trick exist?
This is the square of the Frobenius norm of $X$, and can be expressed as:
$$\|X\|_F^2 = \text{Tr}(X^\top X) = \text{Tr}(XX^\top)$$
where Tr is the trace function.
Incidentally, this norm is induced from the inner product $\langle A, B \rangle := \text{Tr}(A^\top B)$ on matrices of a given shape (similar to how $\|v\|^2$ is a norm induced by the inner product $\langle v, w\rangle := v^\top w$ on $\mathbb{R}^n$).