\documentclass{article}
\usepackage{latexsym,eepic,makeidx,fancybox}
\usepackage[dvips]{graphicx} \usepackage[latin1]{inputenc} \usepackage[english]{babel} \usepackage{amstext,amssymb,amsmath,amsthm,youngtab}
\title{Limit points of the iterative scaling procedure}
\author{Erik Aas}
\date{}
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{conjecture}{Conjecture}
\newtheorem{definition}{Definition}
\newtheorem{proposition}{Proposition}
\newtheorem{remark}{Remark}
\newcommand{\sgn}{\textrm{sgn}}
\newcommand{\p}{^\prime}
\newcommand{\pp}{^{\prime\prime}}
\newcommand{\lra}{\leftrightarrow}
\newcommand{\mbf}{\mathbf}
\newcommand{\mbb}{\mathbb}
\newcommand{\mcl}{\mathcal}
\newcommand{\e}{\varepsilon}
\newcommand{\R}{\mcl{R}}
\newcommand{\C}{\mcl{C}}
\newcommand{\vphi}{\varphi}
\newcommand{\vtheta}{\vartheta}
\newcommand{\ve}{\varepsilon}
\begin{document}
\maketitle
\abstract{The iterative scaling procedure (ISP) is an algorithm which computes a sequence of matrices, starting from some given matrix. The objective is to find a matrix 'proportional' to the given matrix, having given row and column sums. In many cases, for example if the initial matrix is strictly positive, the sequence is convergent. It is known that the sequence has at most two limit points. When these are distinct, convergence to these two points can be slow. We give an efficient algorithm which finds the limit points, invoking the ISP only on subproblems for which the procedure is convergent.}

\section{Introduction}

The {\it iterative scaling procedure} (ISP) is an algorithm which, given an $m\times n$ entrywise nonnegative matrix $A$ and positive numbers $r_1,\dots,r_m$, $c_1,\dots,c_n$ attempts to find a matrix diagonally equivalent to $A$, having row sums $r_i$ and column sums $c_j$. 
Two matrices $A$ and $A\p$ are {\it diagonally equivalent} if there are sequences $(x_i^{(k)})$, $(y_j^{(k)})$, $k \geq 1$, $1\leq i \leq m$, $1\leq j\leq n$, of strictly positive numbers such that $a_{ij} = \lim_{k\to\infty} x_i^{(k)}a\p_{ij}y_j^{(k)}$ for all $i,j$. (Of course, in some cases the limit can be omitted.)
This is done by computing a sequence of $m\times n$ matrices by alternatingly scaling rows and columns, starting with $A$.

Depending on the initial data $A$, $\mbf{r}$ and $\mbf{c}$, this sequence might or might not converge.
Csisz\'{a}r and Tusn\'{a}dy \cite{CsiTus} showed, in a much more general context, that the sequence has at most two limit points.
Bregman \cite{Bregman} characterized completely the case when there is only one limit point.
In this note we will describe the decomposition of the limit points in the general case.

The ISP has been applied in a variety of contexts, the most interesting of which perhaps being the ranking of webpages \cite{Kni}.
A discrete version of the algorithm is used by the Z\"urich City Council to distribute seats in parliamentary elections \cite{balpuk}.

In Section \ref{sec_prelim}, we define the ISP and state known convergence results. In Section \ref{sec_proofs}, we give prove a characterization of the limit points, see Theorem \ref{th_main}. In Section \ref{sec_algo}, we summarize the results in form of an algorithm for computing the ISP limit points. In Section \ref{sec_ex} we provide an example illustrating the main result. In the concluding Section \ref{sec_fut}, we state some questions related to the results proven here.

\vspace{0.5cm}

{\bf Acknowledgements} \\
I am very thankful to Fabian Reffel who read an early version of this note, finding a serious error and providing many helpful suggestions. 
I also thank Kai-Friedrike Oelbermann and the Augsburg group headed by Prof. Friedrich Pukelsheim for telling me about the present problem and electoral methods in general. Svante Linusson and an anonymous referee provided many helpful suggestions.


\section{Preliminaries}
\label{sec_prelim}

Throughout, $A$ will denote a fixed nonnegative $m\times n$ matrix, and $\mbf{r}= (r_1,\dots,r_m), \mbf{c}=(c_1,\dots,c_n)$ fixed positive numbers.
We further assume that there is no row or column in $A$ containing only zeros, and that $A$ is not the direct sum of two smaller matrices.
For emphasis, we call $(A,\mbf{r},\mbf{c})$ {\it positive} in this case.
We will generally denote matrices by capital letters and their entries by the corresponding lower case letters; thus entry $(i,j)$ in the matrix $A$ is denoted $a_{ij}$.
By the {\it row adjustment} (to $\mbf{r}$) $\R(A)$ of $A$ we mean the matrix whose $(i,j)$ entry is $x_ia_{ij}$, where the {\it row multiplier} $x_i$ is defined as $x_i = r_i/\sum_j a_{ij}$.
We define the {\it column adjustment} $\C(A)$, and the {\it column multipliers} $y_j$ (to $c_1,\dots,c_n$) similarly.
Define the {\it support} of a matrix $M$ to be $S(M) := \{(i,j): m_{ij} \neq 0\}$.
By definition, $S(A) = S(\R(A))= S(\C(A))$. 

For example, if $\mbf{r} = (7,4)$, $\mbf{c}=(3,1)$, and $A=\left(\begin{array}{cc} 2 & 5 \\ 4 & 0 \end{array}\right)$, then $\R(A) = A$ and $\C(A) = \left(\begin{array}{cc} 1 & 1 \\ 2 & 0 \end{array}\right)$.


Note that $\R(A) = A = \C(A)$ in case $A$ has both the desired row and column sums.
The iterative scaling procedure consists of adjusting rows and columns alternatingly, starting with $A$.
The iterates under the scaling procedure are defined to be 
$$
B^{(k+1)} := \R(C^{(k)}),$$
and
$$
C^{(k)} = \C(B^{(k)})
$$ for $k \geq 1$ and $B^{(1)}= \R(A)$.

We define $x_i^{(k)}$ as the row multipliers used when computing $B^{(k)}$, and $y_j^{(k)}$ as the column multipliers used when computing $C^{(k)}$.

Let us cite two theorems concerning the limits of $B^{(k)}$ and $C^{(k)}$. 
\begin{theorem}
	(\cite{CsiTus}, see also \cite{CsiShi}, section 5)
	\label{csishi}
	For positive $A,\mbf{r},\mbf{c}$, the sequences $B^{(k)}$ and $C^{(k)}$ are convergent.
\end{theorem}

Call these two limits, $B$ and $C$ respectively. We refer to these as the {\it ISP limits} (associated to $A,\mbf{r},\mbf{c}$).
Clearly $S(B) = S(C) \subseteq S(A), \C(B) = C$, and $\R(C) = B$.

\begin{theorem}
	(\cite{Bregman})
	\label{pretzel}
	We have $B = C$ if and only if there is some matrix $M$ with row sums $\mbf{r}$, column sums $\mbf{c}$ and support a subset that of $A$; i.e. $S(M) \subseteq S(A)$.	\end{theorem}

The necessity part of Theorem \ref{pretzel} is easy to see. We will be concerned with the case when no such matrix $M$ exists, i.e. when $B \neq C$.

We will use the following observation in what follows. If we scale the desired row sums by a common factor $t$, then this gives new ISP sequence $B^{\prime(k)}, C^{\prime(k)}$ closely related to the original sequence; we have $B^{\prime(k)} = tB^{(k)}$ and $C^{\prime(k)} = C^{(k)}$ for all $k \geq 1$. This is easily proved by induction on $k$.

Therefore we will not suppose that $\sum_i r_i = \sum_j c_j$.
We can always reduce to the sums being equal by choosing $t$ above as $\sum_j c_j / \sum_i r_i$, but it will be more natural not to do so.

In fact, if the limits are not equal, but $\sum_i r_i = \sum_j c_j$ and $A$ is not the direct sum of two smaller matrices, then the support of the limit points is not equal to the support of the initial matrix, that is, some entries in the matrix tend to zero during the ISP. This is a consequence of Theorem \ref{th_main} below.

For integer $n\geq 0$, we use the notation $[n] = \{1,\dots,n\}$.
Let $I\subseteq [m]$ be a set of row indices and $J\subseteq [n]$ a set of column indices.
We call any such pair $(I,J)$ a {\it block}.

A set $S = \{(I_k, J_k)\}_1 ^r$ of blocks is called a {\it splitting} if the sets $I_k$ partition the set of rows, and the sets $J_k$ partition the set of columns. The sets of rows and columns will always be those of the input matrix $A$ in what follows.

An elementary refinement of a splitting consists of replacing a block $(I_k,J_k)$ with $(I\p,J\p)$ and $(I\pp,J\pp)$ such that $I\p,I\pp$ partition $I_k$ and $J\p,J\pp$ partition $J_k$.
If the splitting $S\p$ is obtained by performing a sequence of elementary refinements on the splitting $S$ then we say that $S\p$ is a {\it refinement} of $S$.

By the {\it decomposition} of a matrix $B$ we will mean the splitting $I_1,\dots,I_r$, $J_1,\dots,J_r$ of the row and column sets of $B$ such that $b_{ij} \neq 0$ implies $i\in I_k$ and $j\in J_k$ for some $k$, minimal with respect to refinement.

The algorithm to be described will find the decomposition of $B$ (which of course is the same as that of $C$). The following observation from \cite{Pretzel} shows that this suffices to compute $B$, running the ISP only on input for which it converges.

\begin{proposition}
\label{distributive}
Let $A\p$ be the matrix obtained from $A$ by setting the $(i,j)$ entry to $0$ if $b_{ij} = 0$. Then the ISP limits of $(A, \mbf{r}, \mbf{c})$ and $(A\p, \mbf{r}, \mbf{c})$ coincide.
\end{proposition}

Let $x_i$ and $y_j$ be such that $x_ib_{ij} = c_{ij}$ and $c_{ij}y_j = b_{ij}$.
Hence $x_ib_{ij}y_j = b_{ij}$ and thus $x_iy_j = 1$ whenever $(i,j) \in S(B)$.
For subsets $I$ of rows, define $r(I) := \sum_{i\in I} r_i$ and $c(J)$ similarly for subsets $J$ of columns.
Denote by $\mcl{D}\p$ the decomposition of $B$.
It follows that for each block $(I,J) \in \mcl{D}\p$, $x_i$ takes the same value for each $i\in I$ and similarly for $y_j$, $j\in J$.
This common value is easily seen to be $x_i = 1/y_j = r(I)/c(J)$. The number $r(I)/c(J)$ will be called the {\it quotient} of the block $(I,J)$.
Therefore, $x_i^{(k)} \to r(I_p) / c(J_p)$ and $y_j^{(k)} \to c(J_p) / r(I_p)$ as $k\to\infty$ for $(i,j) \in I_p \times J_p$.

Thus, we conclude that, after reordering rows and columns suitably, the matrix $B$ will look as follows.

$$
\bordermatrix{&J_1 & J_2 & \dots & J_r \cr
I_1 & B[I_1, J_1] & \bar{0} & \dots & \bar{0}\cr
I_2 &    0        & B[I_2, J_2]   & \dots & \bar{0}\cr
\vdots & \vdots  &  \vdots        & \ddots & \vdots \cr
I_r &  0 & 0 & \dots & B[I_r, J_r] \cr
} 
$$

We further assume the blocks are ordered so that $r(I_1)/c(J_1) \geq r(I_2)/c(J_2) \geq \dots$. Ties will be broken according to Lemma $\ref{order_1_blocks}$.
A consequence of Theorem \ref{th_main} will be that the barred zeros will in fact correspond to zeros in $A$. 

Note that for each $k$, the submatrix $B[I_k, J_k]$ is a matrix with row sums $r_i$ and column sums $(r(I_k)/c(J_k))c_j$.
Similarly, $C[I_k,J_k]$ has column sums $c_j$ and row sums $(c(J_k)/r(I_k))r_i$.
Whenever $k \neq l$, we have $B[I_k, J_l] = C[I_k, J_l] = 0$. 

We will say a block $(I,J)$ is {\it feasible} if there is some $I \times J$ matrix $M$ with row sums $r_i$, column sums $(r(I)/c(J))c_j$ and $S(M) \subseteq S(A)$.
A splitting is feasible if all its blocks are feasible.
So the decomposition of $B$ is clearly feasible.

\section{Proofs}
\label{sec_proofs}
\begin{lemma}
\label{numbers}
Let $p_1,\dots,p_n, q_1,\dots, q_n$ be positive real numbers. Then $$\min_i \frac{p_i}{q_i} \leq \frac{p_1+\dots+p_n}{q_1+\dots+q_n} \leq \max_i \frac{p_i}{q_i}.$$ If any of the two inequalities is in fact an equality, then all the $p_i/q_i$ are equal.
\end{lemma}
\begin{proof} This follows by induction, the case $n=2$ being easy.\end{proof}
A more intuitive way to think about the fraction in the middle is as the average of the $p_i$'s over the average of the $q_i$'s.
It is important to note that $\min_i p_i / \max_j q_j \leq (p_1+\dots+p_n)/(q_1+\dots+q_n)$ is a considerably weaker statement than Lemma \ref{numbers}.

We define the (bipartite) {\it graph} of $A$ as follows. The vertices are the rows and columns of $A$, and row $i$ and column $j$ are adjacent in the graph if and only if $a_{ij} \neq 0$. If $I$ is a set of rows, we denote by $N(I)$ the set of {\it neighbours} of $I$, i.e. the set $\{j : a_{ij} \neq 0$ for some $i\in I\}$.


We will use the following simple generalization of a well-known theorem by Philip Hall (see eg. \cite{Brualdi}). We formulate the lemma in terms of a submatrix of $A$ for later convenience.
\begin{lemma}
\label{hall}
Let $(I\p,J\p)$ be a fixed block in $A$, and let $t = r(I\p)/c(J\p)$. Then there is a $I\p\times J\p$ matrix $M$ with $S(M) \subseteq S(A)$ and row sums $r_i$, $i\in I\p$, and column sums $tc_j$, $j\in J\p$ if and only if there is no subset $I\pp\subseteq I\p$ of rows such that $r(I\pp) > tc(N(I\pp)\cap J\p)$.
\end{lemma}


For initial data $A,\mbf{r},\mbf{c}$, we define $\vphi(A,\mbf{r},\mbf{c})$ as the subset $I$ of rows such that $\# I$ is maximal among those $I$ maximizing $r(I)/c(N(I))$.
Let us prove that $\vphi(A,\mbf{r},\mbf{c})$ is well defined.

\begin{lemma}
\label{unique}
	If $I_1$ and $I_2$ satisfy the definition of $\vphi(A,\mbf{r},\mbf{c})$, then $I_1 = I_2$.
\end{lemma}
\begin{proof}
Suppose $I_1 \neq I_2$. We have $r(I_1) + r(I_2) = r(I_1\cup I_2) + r(I_1\cap I_2)$ and $c(N(I_1)) + c(N(I_2)) = c(N(I_1) \cup N(I_2)) + c(N(I_1) \cap N(I_2)) \geq c(N(I_1\cup I_2)) + c(N(I_1\cap I_2))$.

Therefore
$$
\frac{r(I_1) + r(I_2)}{c(N(I_1)) + c(N(I_2))} \leq \frac{r(I_1\cup I_2) + r(I_1\cap I_2)}{c(N(I_1\cup I_2)) + c(N(I_1\cap I_2))}.
$$
By Lemma \ref{numbers} either $I_1 \cup I_2$ or $I_1\cap I_2$ shows that neither $I_1$ nor $I_2$ can satisfy the definition of $\vphi(A,r,c)$.
\end{proof}

Though it will follow from Theorem \ref{th_main}, it is interesting to note that we can prove directly that $(I, N(I))$ is feasible, where $I =\vphi(A,r,c)$.
\begin{lemma} 	Let $I = \vphi(A,r,c)$. Then the block $(I, N(I))$ is feasible. \end{lemma}
\begin{proof} Suppose $(I, N(I))$ is not feasible.
By Lemma \ref{hall} there is then some $I\p \subseteq I$ such that $r(I\p) > (r(I)/c(N(I)))c(N(I\p))$, or $r(I\p)/c(N(I\p)) > r(I)/c(N(I))$.
But this contradicts the choice of $I$. \end{proof}

Consider the decomposition $\mcl{D}\p$ of $B$ and denote by $\Psi(B)$ the block obtained by merging all blocks with maximal quotient into a single block (which will have this same quotient). We will denote by $\mcl{D}$ the splitting obtained from $\mcl{D}\p$ after this merge. Of course, the blocks in $\mcl{D}$ are all feasible (since this is true for $\mcl{D}\p$).

\begin{theorem}
\label{th_main}
	Suppose $A,\mbf{r},\mbf{c}$ is positive, and let $I = \vphi(A,\mbf{r},\mbf{c})$. Then $\Psi(B) = (I, N(I))$.
\end{theorem}
\begin{proof}
Let $(I_1, J_1) = \Psi(B)$. We wish to prove that $I_1 = I$ and $J_1 = N(I)$.
We do this in two steps.

We clearly have $J_1\subseteq N(I_1)$: otherwise $B[I_1, J_1]$ would have a zero column.
For the same reason we have $J\p \subseteq N(I\p)$ for each $(I\p, J\p)\in\mcl{D}$.

We now prove that $N(I_1) \subseteq J_1$.
Suppose this is not the case.
Then there are $p \in I_1$, $q \notin J_1$ such that $a_{pq} \neq 0$.
Denote by $(I_2, J_2)$ the block in $\mcl{D}$ such that $q \in J_2$.
		
We know that $x_p(k) \to r(I_1)/c(J_1)$ and $y_q(k) \to c(J_2)/r(I_2)$ as $k\to\infty$.
Therefore $$x_p(k)y_q(k) \to \frac{r(I_1)}{c(J_1)}\frac{c(J_2)}{r(I_2)} > 1.$$
Choose $\eta > 0$ and $K$ such that $x_p(k)y_q(k) > 1+\eta$ for all $k\geq K$.
Hence $b_{pq}(K+n) > (1+\eta)^n b_{pq}(K)\to\infty$ as $n\to\infty$.
This contradicts the fact that all entries in the $B^{(k)}$ are bounded by $\max(r_1+\dots+r_m, c_1+\dots+c_n)$.

Thus $J_1 = N(I_1)$.

It follows from the previous step and the definition of $I$ that $r(I)/c(N(I)) \geq r(I_1) / c(J_1)$.

Let $(I\p, J\p) \in \mcl{D}$.
We show that $r(I\cap I\p) / c(N(I\cap I\p) \cap J\p) \leq r(I\p)/c(J\p)$.
Suppose not; then $N(I\cap I\p) \cap J\p \neq J\p$, since otherwise $r(I\cap I\p)/c(N(I\cap I\p) \cap J\p) = r(I\cap I\p)/c(J\p) \leq r(I\p)/c(J\p)$.
Let $I\pp = I\cap I\p$.
We have $r(I\pp) > (r(I\p)/c(J\p)) c(N(I\pp) \cap J\p)$, and thus by Lemma \ref{hall} the block $(I\p, J\p)$ is not feasible, a contradiction.

Note that $r(I) = \sum r(I\cap I\p)$ and $c(N(I)) = \sum c(N(I)\cap J\p) \geq \sum c(N(I\cap I\p)\cap J\p)$, where the sums range over the blocks $(I\p, J\p)$ of $\mcl{D}$ such that $I\cap I\p \neq \emptyset$.

We can therefore write 
\begin{equation}
\label{moo}
\frac{r(I)}{c(N(I))} = \frac{\sum r(I\cap I\p)}
														{\sum c(N(I)\cap J\p)}
									 \leq\frac{\sum r(I\cap I\p)}
														{\sum c(N(I\cap I\p)\cap J\p)}.
\end{equation}

We know from above and the definition of $I$ that 
$$\frac{r(I\cap I\p)}{c(N(I\cap I\p) \cap J\p)} \leq \frac{r(I\p)}{c(J\p)} \leq \frac{r(I_1)}{c(J_1)} = \frac{r(I_1)}{c(N(I_1))} \leq \frac{r(I)}{c(N(I))}$$ for each $(I\p, J\p)\in\mcl{D}$ with $I\cap I\p \neq \emptyset$, so by Lemma \ref{numbers} all these terms must be equal.

We now show that in fact the only term is $r(I\cap I_1)/c(N(I\cap I_1))$.
Suppose to the contrary that we have $(I\p,J\p)\in\mcl{D}$, $I\p\cap I \neq \emptyset$, $(I\p,J\p)\neq (I_1,J_1)$, and $r(I\cap I\p) / c(N(I\cap I\p)\cap J\p) = r(I)/c(N(I))$.

Then we have $r(I\cap I\p) / c(N(I\cap I\p)\cap J\p) = r(I)/c(N(I)) \geq r(I_1)/c(J_1) > r(I\p)/c(J\p)$, and this contradicts $(I\p, J\p)$ being feasible in the same manner as was done above.
Thus the only term occurring is $r(I\cap I_1) / c(N(I\cap I_1)\cap J_1)$, and it equals $r(I)/c(N(I))$.
Therefore $I\subseteq I_1$ and by the definition of $I$ we thus conclude that $I = I_1$.
\end{proof}

Using Theorem \ref{th_main}, it is easy to find $\Psi(B)$, as we detail in Section \ref{sec_algo}.

The following lemma is a consequence of Theorem 2 in \cite{Puk}.

\begin{lemma}
\label{same}
If the only $I$ satisfying $r(I) \geq c(N(I))$ are $I = \emptyset$ and $[m]$, then $S(A) = S(B)$.	
\end{lemma}

The next lemma is needed for distinguishing blocks with the same multiplier (for example, the blocks in $\Psi(B)$). The proof is similar to that of Theorem $\ref{th_main}$, except we consider cumulative multipliers (to be defined) instead of incremental ones.

\begin{lemma}
\label{order_1_blocks}
Suppose $(A,\mbf{r},\mbf{c})$ is positive, and let $(I_k,J_k)$ be the blocks of the decomposition of $B$. Then the $(I_k,J_k)$ can be ordered so that $N(I_k) \subseteq J_1\cup\dots\cup J_k$ for each $k$.
\end{lemma}
\begin{proof}
Note that a pair $(i,j)$ is in the support of $A$ but not of $B$ if and only if the product of cumulative multipliers $X_i ^{(k)} Y_j^{(k)} \to 0$ as $k\to\infty$.
The cumulative multipliers are defined by $X_i^{(k)} = \prod_{l=1}^k x_i ^{(l)}$ and $Y_j^{(k)} = \prod_{l=1}^k y_j ^{(l)}$ (so that $a^{(k)}_{ij} = X_i^{(k)} a_{ij} Y_j^{(k)}$) for all $k$.

For blocks $(I_a,J_a)$ and $(I_b,J_b)$ we define $(I_a, J_a) \leq (I_b, J_b)$ if $S(A) \cap (I_b\times J_a)\neq \emptyset$.
To prove the lemma it suffices to show that there is no cycle in $\leq$.
To this end, suppose there is a cycle in $\leq$.

Then one can find a sequence of points $(i_1, j_1), (i_2, j_2), \dots, (i_r, j_r)$ with the following properties
\begin{itemize}
\item $r$ is even.
\item For $l$ even, $i_l = i_{l+1}$ and $j_l = j_{l-1}$, taking indices modulo $r$.
\item If $(i_l, j_l)$ does not belong to a block of $B$, then both its (cyclic) successor and predecessor do.  
\item $(i_r, j_r) \in S(A) \backslash S(B)$
\item If $l$ is odd, then $(i_k, j_k) \in S(B)$.
\end{itemize}

By assumption, for each $k$, $\prod _{l\text{ odd}} X^{(k)} _{i_l} Y^{(k)}_{j_l} = \prod _{l\text{ even}} X^{(k)} _{i_l}Y^{(k)}_{j_l}$.
The limit of the left hand side is a product of $b_{ij}/a_{ij}$ for $(i,j)\in S(B)$, hence strictly positive.
But the limit of the right hand side is $0$, since it contains at least one term $X^{(k)}_{i_l}Y^{(k)}_{j_l}$ with $(i_l, j_l) \in S(A)\backslash S(B)$, while all terms are clearly bounded.
This contradiction finishes the proof.
\end{proof}
\section{The algorithm}
\label{sec_algo}
We now describe how to find the decomposition of $B$ given $A$, $\mbf{r}$, $\mbf{c}$.
This is done by repeatedly splitting blocks until this can be done no more, starting with the single block $([m], [n])$. For ease of notation we assume the current block under consideration is $([m], [n])$.

The splitting is naturally divided into two steps, I and II. In step I we look for a subblock of the current block with greatest quotient among all such subblocks. In step II we look for (proper) subblocks of the current block with same quotient as the current block. As observed earlier, we may assume the current block has quotient equal to $1$.

{\bf Step I}

First compute $I=\varphi(A,\mbf{r},\mbf{c})$.
This can be done in polynomial time in the size of $A$ and the number of bits used to represent the input data, as follows.
Let $t$ be any positive number and consider the problem of finding a matrix with support contained in $S(A)$, row sums $r_i$ and column sums $\leq t\cdot c_j$.
For each fixed $t$ this is a standard problem that can be solved with linear programming in polynomial time.
Now, to compute $\varphi(A,\mbf{r},\mbf{c})$, we want to find the largest $t$ such that this problem has a solution with column sums {\it equal} to $tc_j$.
If this property is satisfied for some $t$, it is of course also satisified for any smaller $t$.
So one can perform binary search in $t$ to find the rightmost point in the interval of $t$'s such that the problem has such a solution.
When we have found such a maximal $t$ (which we can guarantee to be maximal by making sure it is in a sufficiently small interval), it is easy (for example, by successively forcing the values of variables in the linear program) to find $\varphi(A,\mbf{r},\mbf{c})$ since it is the unique inclusion-wise maximal one among all solutions.

Now, if $r(I)/c(N(I)) > 1$, then split the current block into $(I, N(I))$ and $([m]-I,[n]-N(I))$. Otherwise, the current block is left unchanged. 

When step I cannot be applied any further (to any block), we perform

{\bf Step II}

As before, compute $I = \varphi(A, \mbf{r}, \mbf{c})$, forcing the solution to be different from $I = [m]$ if possible (as is easily done by modifying the previous linear program slightly). If this leads to a proper subset $I \subseteq [m]$ with $r(I)/c(N(I))=1$, then split the current block into $(I,N(I))$ and $([m]-I,[n]-N(I))$. Otherwise no such subset exists and the ISP limit of the current block will have the same support as $A$ does in the current block, by Lemma \ref{same}.

Theorem \ref{th_main} shows that after Step I, all blocks of $B$ contained in some particular block of the ones found all have the same quotient. Lemma \ref{order_1_blocks} show that when step II can not be applied further we will have found the decomposition of $B$.

Now, referring to Proposition \ref{distributive}, if we change $A$ by setting the entries in $S(A)\backslash S(B)$ to $0$, the ISP limit points will not change.
However, numerical experiments suggest that convergence is much quicker than without the change.
As a small example of this, take the matrix from the example below, set the entries outside the splitting found ($(1,3)$, $(1,4)$, $(2,1)$, $(2,3)$, and $(2,4)$) to zero.
Then it takes about $2$ iterations to get as close to $(B,C)$ in the example, as $B(5)$ and $C(5)$ from earlier are from $B$ and $C$.


\section{An example}
\label{sec_ex}
Let

$A=
\left(
\begin{array}{cccc}
1 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 \\
1 & 1 & 7 & 2 \\
1 & 1 & 9 & 6 \\
\end{array}
\right)$, $r = (4,1,1,1)$, and $c = (1,2,2,2)$.

After $10$ iterations we get the following matrices (rounded to $3$ digits):

$B(5) = 
\left(
\begin{array}{cccc}
4.000 & 0.000 & 0.000 &  0.000 \\
\ve_1 & 1.000 & 0.000 &  0.000 \\
\ve_2 & 0.074 & 0.560 &  0.360 \\
\ve_3 & 0.039 & 0.380 &  0.580 \\
\end{array}
\right)$ and

$C(5) = 
\left(
\begin{array}{cccc}
1.000 & 0.000 & 0.000 & 0.000 \\
\ve_4 & 1.800 & 0.000 & 0.000 \\
\ve_5 & 0.130 & 1.200 & 0.770 \\
\ve_6 & 0.070 & 0.810 & 1.200 \\
\end{array}\right).$

Here, $\ve_1$ and $\ve_4$ are approximately $10^{-4}$, and $\ve_2,\ve_3, \ve_5,\ve_6$ are approximately $10^{-6}$.

The actual limit matrices are (these are exact values)

$B = \left(
\begin{array}{cccc}
4.0 & 0.0 & 0.0 & 0.0 \\
0.0 & 1.0 & 0.0 & 0.0 \\
0.0 & 0.0 & 0.6 & 0.4 \\
0.0 & 0.0 & 0.4 & 0.6 \\
\end{array}
\right)$
and 
$C = \left(\begin{array}{cccc}
1.0 & 0.0 & 0.0 & 0.0 \\
0.0 & 2.0 & 0.0 & 0.0 \\
0.0 & 0.0 & 1.2 & 0.8 \\
0.0 & 0.0 & 0.8 & 1.2 \\
\end{array}\right).$


We have $\Psi(B) = (I_1, J_1)$ where $I_1 = \{1\}$, $J_1 = \{1\}$.
One can check that we have $\vphi(A,r,c) = I_1$ and $J_1 = N(I_1)$ in this case, as expected.

In step I of the algorithm, we find the splitting consisting of the blocks $(I_1, J_1)$ and $(I_2, J_2)$ where $I_2 = \{2,3,4\}$ and $J_2 = \{2,3,4\}$.

In step II applied to the block $(I_2, J_2)$ we find the subset $I_3 = \{2\} \subseteq I_2$ with the property $r(I_3) = 1 = (3/6)6 = (r(I_2)/c(J_2)) c(N(I_2) \cap J_2)$.
So the result of applying step II to $(I_2, J_2)$ is $(I_3, J_3)$ and $(I_4, J_4) := (I_2\backslash I_3, J_2\backslash J_3)$.
Applying step II to any of the blocks $(I_2,J_2)$, $(I_3,J_3)$ or $(I_4,J_4)$ yields nothing new, so the final splitting found is $\{(I_2,J_2), (I_3,J_3), (I_4,J_4)\}$, which coincides with the decomposition of $B$.

\section{Future work}
\label{sec_fut}
I would like to mention some related extensions and problems.
First, most results above seem to carry over to the much more general setting of Theorem 5.2 in \cite{CsiShi}, but I have not explored this further.

A formalisation of the claim that convergence is quicker in the case $B = C$ would of course be very interesting.
 
There is a natural version of the ISP with continuous time, as follows.
Let $\vtheta\in(0,1)$, and define $\R_\vtheta(A)_{ij} = x_i^\vtheta A_{ij}$, and $\C_\vtheta(A)_{ij} = A_{ij}y_j^\vtheta$, with $x_i$ and $y_j$ defined as before.
Now we can define $F_{\alpha,\beta} = R_\alpha C_\beta$, and ask about the properties of $\lim_{\e\to 0}\lim_{n\to\infty} F^{(n)}_{\alpha\e, \beta\e}(A)$.
The matrix $F_{\alpha,\beta}(A)$ will be diagonally equivalent to $A$ and from this it follows (cf. \cite{Pretzel}) that the limit $\lim_{\e\to 0}\lim_{n\to\infty} F^{(n)}_{\alpha\e,\beta\e}(A)$ will be the same as the ordinary ISP limit of $A$ if the latter exists.
It is not clear what happens in the general case when that limit does not exist. 



Finally, the ISP can of course be defined for arbitrary, not necessarily nonnegative, $A,r,c$.
Two issues arise in this case.
One problem is that we may obtain matrices having marginals equal to $0$ during the iteration.
This could probably be avoided by using the continuous version described above; it seems reasonable such a system would repel from matrices having some marginal close to $0$.
For the discrete time version, the analogous convergence claims are not true; the initial data

$A = 
\left(
\begin{array}{cccc}
 1 & 2 \\
 3 & 4 \\
\end{array}
\right)$,
$\mbf{r} = (13,-12)$, $\mbf{c} = (4,6)$

gives a sequence with period $4$. This cycle appears to be unstable in the input.

\begin{thebibliography}{9}
\bibitem{balpuk} Michel Balinski and Friedrich Pukelsheim (2006). Matrices and politics, {\it Festschrift for Tarmo Pukkila on his 60th Birthday} (Eds. E. Liski, J. Isotalo, S. Puntanen, G.P.H. Styan), 233-242.
\bibitem{Bregman} L. Bregman (1967). Proof of the convergence of Sheleikhovskii's method for a problem with transportation constraints. {\it USSR Computational Mathematics and Mathematical Physics}, 7:191-204.
\bibitem{Brualdi} Richard Brualdi, Seymour Parter, Hans Schneider (1966). The diagonal equivalence of a nonnegative matrix to a stochastic matrix. {\it Journal of Mathematical Analysis and Applications}, 16, 31 - 50.
\bibitem{CsiShi} Imre Csisz\'{a}r and Paul Shields (2004). {\it Information theory and statistics}, now Publishers, Delft, section 5.2.
\bibitem{CsiTus} Imre Csisz\'{a}r and G\'{a}bor Tusn\'{a}dy, (1984). Information geometry and alternating minimization procedures. {\it Statistics and Decisions}, Supplement Issue, 1:205-237.
\bibitem{Kni} Philip Knight (2008). The Sinkhorn-Knopp algorithm: convergence and applications, {\it SIAM Journal on Matrix Analysis and Applications}, 30:261-275.
\bibitem{Pretzel} Oliver Pretzel (1980). Convergence of the iterative scaling procedure, {\it Journal of the London Mathematical Society}, 21, 379-384.
\bibitem{Puk} Friedrich Pukelsheim (2012). An $L^1$-Analysis of the Iterative Proportional Fitting Procedure, preprint. Retrieved at {\tt opus.bibliothek.uni-augsburg.de}.
\end{thebibliography}
\end{document}

