Skip to content

Instantly share code, notes, and snippets.

@SarvagyaVaish
Last active March 13, 2017 09:39
Show Gist options
  • Save SarvagyaVaish/57c326c1faed89694e4d4b06d397d3fe to your computer and use it in GitHub Desktop.
Save SarvagyaVaish/57c326c1faed89694e4d4b06d397d3fe to your computer and use it in GitHub Desktop.
// Compute 'm' errors, one for each data point, for the given parameter values in 'x'
int operator()(const Eigen::VectorXf &x, Eigen::VectorXf &fvec) const
{
// 'x' has dimensions n x 1
// It contains the current estimates for the parameters.
// 'fvec' has dimensions m x 1
// It will contain the error for each data point.
float aParam = x(0);
float bParam = x(1);
float cParam = x(2);
for (int i = 0; i < values(); i++) {
float xValue = measuredValues(i, 0);
float yValue = measuredValues(i, 1);
fvec(i) = yValue - (aParam * xValue * xValue + bParam * xValue + cParam);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment