optimise sparse inner product