def sp_add2_array(sp, arr):
    """
    :param sp: sparse matrix p-by-1 (created
        with :py:meth:`~rlpy.tools.general_tools.sp_matrix`)
    :param arr: a 1-D iterable type (ndarray, list, matrix) of length p.

    Returns ret = arr + sp (with type(ret) = type(arr))

    """
    ind = sp.nonzero()[0]
    for i in ind:
        arr[i] += sp[i, 0]
    return arr