# Sum of a row in a matrix

I have two matrices $A \in M^{m \times n}(\mathbb{R})$ and $B \in M^{n \times p} (\mathbb{R}).$ For $A$ it says that sum of every row in $A$ is $a$ and sum of every row in $B$ is $b.$ I have to show that the product $AB$ has a constant sum of rows.

I started with matrix $$A= \begin{bmatrix} e_{11}& e_{12} & \cdots & \cdots & e_{1n} \\ e_{21}& \cdots & \cdots & \cdots & e_{2n} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ e_{m1} & \cdots & \cdots & \cdots & e_{mn} \end{bmatrix}$$ and $$B =\begin{bmatrix} e_{11}& e_{12} & \cdots & \cdots & e_{1p} \\ e_{21}& \cdots & \cdots & \cdots & e_{2p} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ e_{n1} & \cdots & \cdots & \cdots & e_{np} \end{bmatrix}$$

When I calculate the product $AB$ I get that the sum of the first row is: $$[e_{11} e_{11}+e_{12}e_{21}+\cdots+e_{1n}e_{n1}]+[e_{11} e_{12}+e_{12}e_{22}+\cdots+e_{1n}e_{n2}]+\cdots+[e_{11} e_{1p}+e_{12}e_{2p}+\cdots+e_{1n}e_{np}]$$ I know that $e_{11}+e_{12}+\cdots+e_{1n}=a$ and $e_{11}+e_{12}+\cdots+e_{1p}=b$ and also for other rows but I don't know how to continue.

Thanks for any help.

• You should better take different elements for the matrix $B$. For example call them $f_{ij}$ Commented Feb 19, 2016 at 14:36

Let $z_n \in \mathbb{R}^n$ denote the vector of ones, i.e. all components equal 1. Your assumptions are equivalent to $Az_n = az_m$ and $Bz_p = bz_n$. It follows that $ABz_p = A(bz_n) = bAz_n = ab z_m$, or equivalently the components along each row of $AB$ sum to $ab$.