def numpyToReducedAlist(matrix):
    """Convert the matrix to reduced AList format in form of a list of lists.

    The first entry is a pair containing number of columns and rows, respectively. The second entry
    is an empty list (in MacKay's Alist format, this contains the max number of entries per column
    and row, respectively). Then, for each column, a list of nonzero positions follows.
    """
    out = [[matrix.shape[1], matrix.shape[0]], []]
    for i in range(matrix.shape[1]):
        out.append((matrix[:, (i)].nonzero()[0] + 1).tolist())
    return out
