本文整理汇总了C++中Samples::computeD2方法的典型用法代码示例。如果您正苦于以下问题:C++ Samples::computeD2方法的具体用法?C++ Samples::computeD2怎么用?C++ Samples::computeD2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Samples
的用法示例。
在下文中一共展示了Samples::computeD2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exception
//.........这里部分代码省略.........
//
////////////////////////////////////////////////////////////////////////////
gvars.free();
//__________________________________________________________________________
//
// construct and link the variables
//__________________________________________________________________________
{
gvars << "p";
gvars << "ve";
{
size_t j=1;
for( Iterator i=db.begin();i!=db.end();++i,++j)
{
Record &r = **i;
Variables &v = r.sample->variables;
v.free();
{
v("p", gvars["p"]);
v("ve",gvars["ve"]);
{
const string q_id = "q" + r.name;
gvars << q_id;
v("q",gvars[q_id]);
}
{
const string vi_id = "vi" + r.name;
gvars << vi_id;
v("vi",gvars[vi_id]);
}
{
const string t0_id = "t0" + r.name;
gvars << t0_id;
v("t0",gvars[t0_id]);
}
}
std::cerr << "v=" << v << std::endl;
}
std::cerr << "g=" << gvars << std::endl;
}
//__________________________________________________________________________
//
// Initialize the variables
//__________________________________________________________________________
const size_t nvar = gvars.size();
Vector aorg(nvar);
Vector aerr(nvar);
vector<bool> used(nvar,false);
//const double p_ini = average_of(P);
//const double pHe_ini = average_of(pHe);
gvars(aorg,"ve") = 7.1;
gvars(aorg,"p" ) = 1;
{
size_t j=1;
for( Iterator i=db.begin();i!=db.end();++i,++j)
{
Record &r = **i;
Variables &v = r.sample->variables;
v(aorg,"t0") = T0[j];
v(aorg,"q" ) = Q[j];
v(aorg,"vi") = pHi[j];
v.on(used,"q");
}
}
std::cerr << "aorg=" << aorg << std::endl;
samples.computeD2(F,aorg);
gvars.on(used,"p");
gvars.on(used,"ve");
if( !ls.fit(samples, F, aorg, aerr, used) )
{
throw exception("Couldn't fit...");
}
gvars.display(std::cerr, aorg, aerr);
ios::ocstream fp("com.dat");
for( Iterator i=db.begin();i!=db.end();++i)
{
Sample &sample = *((**i).sample);
for(size_t j=1;j<=sample.count();++j)
{
fp("%g %g %gn\n", sample.X[j], -log10(sample.Y[j]), -log10(sample.Yf[j]));
}
fp << '\n';
}
}
}