本文整理汇总了C++中MyParser::DiffRemoveSingularity方法的典型用法代码示例。如果您正苦于以下问题:C++ MyParser::DiffRemoveSingularity方法的具体用法?C++ MyParser::DiffRemoveSingularity怎么用?C++ MyParser::DiffRemoveSingularity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyParser
的用法示例。
在下文中一共展示了MyParser::DiffRemoveSingularity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: user_df
int user_df(const gsl_vector *x, void *params, gsl_matrix *J) {
int n = ((struct FitData *)params)->n;
int p = ((struct FitData *)params)->p;
double *X = ((struct FitData *)params)->X;
double *sigma = ((struct FitData *)params)->sigma;
NonLinearFit *fitter = (NonLinearFit *)((struct FitData *) params)->fitter;
const char *function = fitter->formula().ascii();
QStringList parNames = fitter->parameterNames();
try {
double *param = new double[p];
MyParser parser;
double xvar;
parser.DefineVar("x", &xvar);
for (int k=0; k<p; k++) {
param[k] = gsl_vector_get(x,k);
parser.DefineVar(parNames[k].ascii(), ¶m[k]);
}
QMapIterator<QString, double> i(fitter->constants());
while (i.hasNext()){
i.next();
parser.DefineConst(i.key().ascii(), i.value());
}
parser.SetExpr(function);
for (int i = 0; i < n; i++) {
xvar = X[i];
double s = 1.0/sqrt(sigma[i]);
for (int j = 0; j < p; j++)
try {
gsl_matrix_set (J, i, j, 1.0/s*parser.DiffRemoveSingularity(&xvar, ¶m[j], param[j]));
} catch (MyParser::Pole) {
return GSL_ESING;
}
}
delete[] param;
} catch (mu::ParserError &) {
return GSL_EINVAL;
}
return GSL_SUCCESS;
}