Added MEX file to quickly compute residual