def subtract_row(v, pairs):
    """
    v_diff[k] = v[i, :] - v[j, :]

    Parameters
    ----------
    v : NDArray
        Nx1 boundary measurements vector or NxM matrix
    pairs : NDArray
        Nx2 subtract_row pairs

    Returns
    -------
    NDArray
        difference measurements
    """
    i = pairs[:, 0]
    j = pairs[:, 1]
    # row-wise/element-wise operation on matrix/vector v
    v_diff = v[i] - v[j]

    return v_diff