def cov(sources):
    """
    Given the array of sources for all image patches, calculate the covariance
    array between all modes.

    Parameters
    ----------
    sources : numpy array (floats)
        The {NUM_MODES x NUM_PATCHES} array of sources.

    Returns
    -------
    numpy array (floats)
        The {NUM_MODES x NUM_MODES} covariance array between all modes.

    """
    return (sources @ sources.T)/sources.shape[1]