Dimension of vector space of matrices with zero row and column sum. Let $V(\mathbb{R})$ be the vector space of $m\times  n$ real  matrices such that each row sum and each column sum is zero. What is the dimension of $V(\mathbb{R})$? I know by General thinking that its dimension is $(m-1)(n-1)$. But I don't know what is the method to find its dimension. Please tell me how to think about its dimension. Thanks a lot.
 A: Let $K$ be a field. For $A \in \mathrm{M}(m \times n, K)$ let
$$
 R_i(A) = \sum_{j=1}^n A_{ij} \quad \text{for every $1 \leq i \leq m$}
$$
and
$$
 C_j(A) = \sum_{i=1}^m A_{ij} \quad \text{for every $1 \leq j \leq n$},
$$
and set
$$
 V_{m,n}(K) = \{A \in \mathrm{M}(m \times n, K) \mid R_1(A) = \dotsb R_m(A) = C_1(A) = \dotsb = C_n(A)\}.
$$

We show that the map
\begin{align*}
 \Phi \colon V_{m,n}(K) &\to \mathrm{M}((m-1) \times (n-1), K), \\
 \quad (a_{ij})_{1 \leq i \leq n, 1 \leq j \leq m} &\mapsto (a_{ij})_{1 \leq i \leq n-1, 1 \leq j \leq m-1}
\end{align*}
is an isomorphism; it is clearly linear.
First surjectivity: Let $A = (a_{ij})_{1 \leq i \leq n-1, 1 \leq j \leq m-1} \in \mathrm{M}((m-1) \times (n-1), K)$. For all $1 \leq i \leq m-1$ let $a_{in} = -R_i(A)$ and for all $1 \leq j \leq n-1$ let $a_{mj} = -C_j(A)$. Also let
$$
 a_{mn}
 = \sum_{\substack{1 \leq i \leq m-1 \\ 1 \leq j \leq n-1}} a_{ij}.
$$
For $\hat{A} = (a_{ij})_{1 \leq i \leq n, 1 \leq j \leq m} \in \mathrm{M}(m \times n, K)$ we have that
$$
 R_i(\hat{A}) = \sum_{j=1}^n a_{ij} = R_i(A) + a_{in} = 0
 \quad \text{for every $1 \leq i \leq m-1$}
$$
as well as
\begin{align*}
 R_m(\hat{A})
 &= \sum_{j=1}^n a_{mj}
 = \sum_{j=1}^{n-1} a_{mj} + a_{mn} \\
 &= -\sum_{j=1}^{n-1} C_j(A) + a_{mn}
 = -\sum_{j=1}^{n-1} \sum_{i=1}^{m-1} a_{ij} + \sum_{\substack{1 \leq i \leq m-1 \\ 1 \leq j \leq n-1}} a_{ij}
 = 0.
\end{align*}
So all row sums of $\hat{A}$ are zero. Simililarly we find that all column sums of $\hat{A}$ are zero. So $\hat{A} \in V_{m,n}(K)$. Because $\Phi(\hat{A}) = A$ this shows the surjectivity of $\Phi$.
For the injecitvity we argue the other way around: For every $A \in V_{m,n}(K)$ we have $A_{in} = -R_i(\Phi(A))$ for every $1 \leq i \leq m-1$ and $A_{mj} = -C_j(\Phi(A))$ for every $1 \leq j \leq n-1$, as well as
$$
 A_{mn}
 = -\sum_{j=1}^{n-1} A_{mj}
 = \sum_{j=1}^{n-1} C_j(\Phi(A)),
$$
So $A$ is uniquely determined by $\Phi(A)$, showing that $\Phi$ in injective.
A: A variant on Jendrik Stelzner's excellent answer is to note that if a matrix $a$ has row and column sum zero, then for each $i$
$$
a_{i,n} = - \sum_{s=1}^{n-1} a_{i,s},
$$ 
for each $j$
$$
a_{m,j} = - \sum_{t=1}^{m-1} a_{t,j},
$$
and finally
$$
a_{m,n} = \sum_{s=1}^{n-1} \sum_{t=1}^{m-1} a_{t, s}.
$$
Conversely, these three conditions imply that $a$ has row and column sum zero.
Now it is immediate that a basis of the space of this matrices is given by the $(m-1)(n-1)$ matrices
$$
e_{i,j} - e_{i,n} - e_{m, j} + e_{m, n},
$$
for $0 \le i < m$, $0 \le j < n$, where $e_{s, t}$ is the usual matrix which has zero everywhere except for a $1$ in position $s, t$. The above show that they span the space, and it suffices to look at the first $n-1$ and $m-1$ rows to see that they are independent.
For instance, when $m = n = 3$ you get
$$
\begin{bmatrix}
1 & 0 & -1\\
0 & 0 & 0\\
-1 & 0 & 1\\
\end{bmatrix},
\quad
\begin{bmatrix}
0 & 0 & 0\\
1 & 0 & -1\\
-1 & 0 & 1\\
\end{bmatrix},
\quad
\begin{bmatrix}
0 & 0 & 0\\
0 & 1 & -1\\
0 & -1&  1\\
\end{bmatrix},
\quad
\begin{bmatrix}
0 & 1 & -1\\
0 & 0 & 0\\
0 & -1&  1\\
\end{bmatrix}.
$$
Note that if you look at the first two rows and columns, you get the usual base of the space of $2 \times 2$ matrices.
A: Take  variable $x_{ij},\ i=1,2,\ldots,m,\ j=1,2\ldots,n$ that correspod to the entries of the matrix. Row sum being eeuqal to zero gives rise to the conditions $s\sum_{j=1}^n x_{1j}=0, \sum_{j=1}^n x_{2j}=0, \ldots$. Similarly one has to get equations corresponding to columns sums being zero. Now consider the rank of this system on $mn$ variables and $m+n$ equations.
Now use rank and nullity theorem.
A: consider any one row. since row sum is zero, so at least one component of that row  can be written as the linear combination of other components. so that one element can be removed or can be replaced by zero. do this process  for each row. 
Similarly, do this process for each column. you will find finally (m-1).(n-1) remaining elements. so the dimension is (m-1).(n-1).
A: Here is (I think) a more elementary proof.
Let:

*

*$Z\subset M(m\times n, \mathbb F)$ be the subspace of matrices whose elements sum to $0$.

*

*This has dimension $mn-1$.



*$R$ be the $m\times n$ matrices where each row sums to $0$.

*

*Since the subspace of vectors in $\mathbb F^n$ that sum to $0$ has dimension $n-1$, $\dim R = m(n-1)$.



*$C$ be the $m\times n$ matrices where each column sums to $0$.

*

*Since the subspace of vectors in $\mathbb F^m$ that sum to $0$ has dimension $m-1$, $\dim C = (m-1)n$.



*$S = C + R$, the subspace sum $R$ and $C$.

*

*Clearly $S \subseteq Z$.



Then $V = C\cap R$ is the subspace of of $M(m\times n, \mathbb F)$  whose rows and columns sum to $0$.
Let $X \in Z$. We can write:
\begin{align}
 x &= \begin{bmatrix}
x_{1,1} & \ldots &  x_{1,n} \\
    \vdots & &\vdots\\
x_{m-1,1} & \ldots  & x_{m-1,n} \\
x_{m,1} & \ldots  & x_{m,n} \\
\end{bmatrix}
\cr&= \begin{bmatrix}
x_{1,1} & \ldots & x_{1,n} \\
    \vdots & & \vdots &\vdots\\
x_{m-1,1} & \ldots  & x_{m-1,n} \\
x_{m,1} - \sum_{i=1}^m x_{i,1}& \ldots & x_{m,n} - \sum_{i=1}^m x_{i,n}\\
\end{bmatrix}    +
\begin{bmatrix}
0 & \ldots  &0 \\
    \vdots &  &\vdots\\
0 & \ldots  & 0 \\
 \sum_{i=1}^m x_{i,1}& \ldots&  \sum_{i=1}^m x_{i,n}\\
\end{bmatrix}        
\end{align}
The first matrix on the RHS has each column sum to $0$, and so is in $C$.
The second matrix on the RHS is all zeros, except for the last row, whose sum is $\sum_{j=1}^m\sum_{i = i}^m x_{i,j} = 0$, and so is in $R$.
It follows that any element of $Z$ can be written as the sum of an element of $C$ plus an element of $R$, and so is in $S = C + R$.
We conclude $Z = S$.
Now we can use the result from linear algebra that:
\begin{align}
\dim(C+R) &= \dim C + \dim R - \dim (C \cap R) \\
    &\Downarrow\\
\dim Z &= \dim C + \dim R - \dim V\\
mn - 1 &= (m-1)n + (n-1)m - \dim v \\
&\Downarrow\\
\dim V =& mn - n - m + 1 \\
&= (m-1)(n-1). \blacksquare
\end{align}
