def project_residuals_to_local(residuals, assignments, Rs, mu):
    """
    Given residuals for training datapoints, their cluster assignments,
    the mean of cluster residuals, and the cluster rotation matrices, project
    all residuals to their appropriate local frame. This is run to generate
    points to cluster for subquantizer training.

    :params ndarray residuals:
        an NxD array of residuals
    :params ndarray assignments:
        an Nx1 array of cluster ids assignments for residuals
    :params ndarray Rs:
        a VxDxD array of rotation matrices for each cluster
    :params ndarray mu:
        a VxD matrix of mean residuals for each cluster

    :returns ndarray:
        an NxD array of locally projected residuals
    """
    projected = np.zeros(residuals.shape)
    for i in xrange(residuals.shape[0]):
        res = residuals[i]
        a = assignments[i]
        projected[i] = np.dot(Rs[a], res + mu[a])

    return projected
dataset/ETHPy150Open yahoo/lopq/python/lopq/model.py/project_residuals_to_local/operator `-` -> `+`