Simplifying Summation of Outer Products

37 Views Asked by At

Let $X \in \mathbb{R}^{d \times n}$ and $Y \in \mathbb{R}^{d \times m}$ have columns $x_{i}, y_{j} \in \mathbb{R}^{d}$ respectively. Is there any way to write the matrix $$\sum_{i = 1}^{n}\sum_{j = 1}^{m}x_{i}y_{j}^{\top}$$ in terms of a matrix product, say via a a Kronecker product?

I have this expression in a large calculation where I am to take derivatives w.r.t. $X$, so simplifying it would help a lot.

2

There are 2 best solutions below

0
On BEST ANSWER

$$\sum_{i = 1}^n \sum_{j = 1}^m x_i y_j^\top = (\sum_{i = 1}^n x_i ) ( \sum_{j = 1}^m y_j )^\top = (X u_n) (Y u_m)^\top$$ where $u_n = (1, \dots, 1)^{\top} \in \mathbb{R}^n$

0
On

Oops, figured out the answer, and leaving it here for posterity. Let $e_{i}$ be the vector whose $i$th entry is $1$ and the other entries are $0$ (with dimension inferred).

We have $$\sum_{i = 1}^{n}\sum_{j = 1}^{m}x_{i}y_{j}^{\top} = \sum_{i = 1}^{n}\sum_{j = 1}^{m}(Xe_{i})(Ye_{j})^{\top} = \sum_{i = 1}^{n}\sum_{j = 1}^{m}Xe_{i}e_{j}^{\top}Y^{\top} = X\left(\sum_{i = 1}^{n}\sum_{j = 1}^{m}e_{i}e_{j}^{\top}\right)Y^{\top} = X1_{m \times n}Y^{\top},$$ where $1_{m \times n}$ is the $m \times n$ all-ones matrix.