Minor optimization in compute_delta_w