def to_flat(A, flat_map):
    """Convert a square matrix A to a flat array alpha.

    Parameters
    ----------
    A : ndarray
        The transformation matrix A
    flat_map : ndarray
        Mapping from flat indices (k) to square (i,j) indices.

    Returns
    -------
    FlatenedA : ndarray
        flattened version of A
    """
    return A[flat_map[:, (0)], flat_map[:, (1)]]
