TITLE: Can this transformation be expressed as a matrix equation?
QUESTION [5 upvotes]: I have a matrix $A$ of dimension $m \times n$, and I need to get a matrix $B$ which is also $m \times n$, that has the following specifications:
Element $B_{ij}$ of matrix $B$ is the product of the sum of all elements in row $i$, and the sum of all elements in row $j$, divided by the sum of all elements in $A$:
$$B_{ij} = \frac{\sum{A_i}\sum{A_j}}{\sum{A_{ij}}}$$
Is there a matrix equation of basic operations (addition, multiplication, trace, transpose, etc.) that can be used to express this transformation?

REPLY [5 votes]: Yes you can. $B$ is a rank one matrix. Use the column vector $\vec{1}$ with $n$ ones and the row vector $\vec{1}^\top$ with $m$ ones. Then
$$B = \frac{(A\vec{1})(\vec{1}^\top A)}{\vec{1}^\top A\vec{1}}$$
Where the denominator is a scalar. Note that you need only do the left and right vector multiplication once.