5

From Sinkhorn & Knopp (1967):

If $\mathbf{A}$ is an $N \times N$ matrix and $\sigma$ is a permutation of $\{1, \dots, N\}$, then the sequence of elements $a_{1, \sigma(1)}, \dots, a_{N, \sigma(N)}$ is called the diagonal of $\mathbf{A}$, corresponding to $\sigma$.

In order to guarantee the convergence of Sinkhorn-Knopp algorithm for square matrix balancing, we require that a matrix $\mathbf{A}$ has support, that is, it must contain at least one diagonal with only positive elements. Is there an easy way to check if a matrix has support?


Example

\begin{equation} \begin{pmatrix} 1 & 0 & 0 \\ 0 & 2 & 3 \\ 0 & 5 & 0 \\ \end{pmatrix} \end{equation}

This matrix has support because the entries $1$, $3$, $5$ reside in a diagonal.

aretor
  • 225
  • 1
  • 6

2 Answers2

1

Given a matrix ${\bf A} \in {\Bbb R}^{n \times n}$, define the $n \times n$ binary matrix $\bf B$ as follows

$$ b_{ij} := \begin{cases} 1 & \text{if} & a_{ij} \neq 0 \\ 0 & \text{if} & a_{ij} = 0 \end{cases} $$

The matrix $\bf B$ contains the sparsity pattern of the matrix $\bf A$. Hence, if $\operatorname{tr} ({\bf B}) = n$, or if there exists an $n \times n$ nontrivial permutation matrix ${\bf P} \neq {\bf I}_n$ that permutes the columns of $\bf B$ such that $\operatorname{tr} ({\bf B} {\bf P}) = n$, then the matrix $\bf A$ does have support.

Let ${\Bbb P}_n$ denote the set of $n \times n$ permutation matrices. Relaxing, the convex hull of ${\Bbb P}_n$ is the Birkhoff polytope ${\Bbb B}_n$ (the set of all $n \times n$ doubly stochastic matrices). Hence, a permutation matrix can be found via the following linear program (LP)

$$\begin{array}{ll} \underset{{\bf X} \in {\Bbb R}^{n \times n}}{\text{maximize}} & \operatorname{tr} ({\bf B} {\bf X}) \\ \text{subject to} & {\bf X} {\bf 1}_n = {\bf 1}_n \\ & {\bf 1}_n^\top {\bf X} = {\bf 1}_n^\top\\ & {\bf X} \geq {\bf O}_n\end{array}$$

Let $\bar{\bf X}$ denote the maximizer. If $\operatorname{tr} \left( {\bf B} \bar{\bf X} \right) = n$, then the matrix $\bf A$ does have support.


Numerical experiment

From the question,

$$ {\bf A} := \begin{pmatrix} 1 & 0 & 0 \\ 0 & 2 & 3 \\ 0 & 5 & 0 \end{pmatrix} $$

Using CVXPY to solve the LP,

from cvxpy import *
import numpy as np

determine whether square matrix A has support

def hasSupport(A):

# extract the number of rows (or columns)
n = A.shape[0]

# extract the sparsity pattern of matrix A
B = (A != 0).astype(int)

# create column vector of n ones
ones_n = np.ones((n,1))

# create matrix decision variable
X = Variable((n,n))

# create linear program (LP)
constraints = [            X @ ones_n == ones_n, 
                ones_n.T @ X          == ones_n.T, 
                           X          >=      0   ]
LP = Problem(Maximize(trace(B @ X)), constraints)
LP.solve(verbose = False)

# check if the optimization problem was solved
if LP.status == "optimal":

    # maximal trace attained (rounded to integer)
    maxTrace = int(np.round(LP.value, 0))

    # return has-support-ness, maximal trace and permutation matrix
    return (maxTrace == n, maxTrace, np.round(X.value, 3))

else:
    return "Error!"

def main():

A = np.array([[ 1, 0, 0],
              [ 0, 2, 3],
              [ 0, 5, 0]])

hasSupp, maxTrace, P = hasSupport(A)

print("Matrix A has support:   ", hasSupp )
print("Permutation matrix:     ", P       )
print("Maximal trace:          ", maxTrace)
print("A with permuted columns:", A @ P   )

if name == "main": main()

which outputs

Matrix A has support:    True
Permutation matrix:      [[ 1.  0.  0.]
                          [ 0. -0.  1.]
                          [ 0.  1. -0.]]
Maximal trace:           3
A with permuted columns: [[1. 0. 0.]
                          [0. 3. 2.]
                          [0. 0. 5.]]
-1

To fully test a square matrix for total support involves (n!) operations. This requires factorial steps. The LeetArxiv implementation of Sinkhorn Solves Sudoku offers heuristics to check for total support.

  1. Check if $A$ is a square matrix.

    • Yes, proceed to step 2.
    • No, A failed stop here.
  2. Check if all the entries of $A$ are greater than $0$.

    • Yes, $A$ has total support, stop here.
    • No, proceed to step 3.
  3. Test if $A$ is invertible. (A quick test is checking determinant is not equal to $0$)

    • Yes, $A$ has total support, stop here.
    • No, proceed to step 4.
  4. Check for zero rows or columns. (If any column is entirely zero then $A$ is disconnected, ie has no total support)

    • Yes, some rows/cols are entirely $0$, stop A failed.
    • No, proceed to Step 5.
  5. Check if every row and column sum is greater than $0$.

    • Yes, proceed to step 6.
    • No, A failed, stop here.
  6. Check for perfect matching in the bipartite graph of $A$.

    • Total support is equivalent to the bipartite graph having a perfect matching.
  • 2
    That link doesn’t work, and I think 6 is the only important observation here. 1,2,4 are just basic obvious checks. 3 is wrong - a matrix of all 1’s has support and determinant 0. 5 is wrong - put $1$ on the diagonal and $-2$ everywhere else for a counterexample. – Eric Oct 18 '25 at 20:54