本文整理汇总了C++中st::string::strtochar方法的典型用法代码示例。如果您正苦于以下问题:C++ string::strtochar方法的具体用法?C++ string::strtochar怎么用?C++ string::strtochar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st::string
的用法示例。
在下文中一共展示了string::strtochar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outfilerun
void outfilerun(dataobject & o)
{
unsigned nrwritten;
ST::string path = o.uwrite.getPath();
list<ST::string> names = o.m.getModelVarnames();
ST::string expression = o.methods[6].getexpression();
if ( (o.uwrite.isexisting() == true) && (o.replace.getvalue() == false) )
o.errormessages.push_back(
"ERROR: file " + path + " is already existing\n");
else
{
ofstream fout;
ST::open(fout,path);
if (expression.length() > 0)
{
realvar v = o.d.eval_exp(expression);
#if defined(JAVA_OUTPUT_WINDOW)
nrwritten = o.d.write(o.adminb_p,fout,names,o.header.getvalue(),v);
#else
nrwritten = o.d.write(fout,names,o.header.getvalue(),v);
#endif
}
else
{
#if defined(JAVA_OUTPUT_WINDOW)
nrwritten = o.d.write(o.adminb_p,fout,names,o.header.getvalue());
#else
nrwritten = o.d.write(fout,names,o.header.getvalue());
#endif
}
o.errormessages = o.d.geterrormessages();
if (o.errormessages.empty())
{
o.out("NOTE: " + ST::inttostring(names.size()) + " variable(s) with " +
ST::inttostring(nrwritten) + " observations written to file\n");
o.out(" " + path + "\n");
}
else
{
fout.close();
remove(path.strtochar());
}
}
}
示例2: outresults
void FC_predict_mult::outresults(ofstream & out_stata, ofstream & out_R,
const ST::string & pathresults)
{
if (pathresults.isvalidfile() != 1)
{
FC::outresults(out_stata,out_R,"");
FC_deviance.outresults(out_stata,out_R,"");
optionsp->out(" PREDICTED VALUES: \n",true);
optionsp->out("\n");
optionsp->out(" Results for the predictor, mean are stored in file\n");
optionsp->out(" " + pathresults + "\n");
optionsp->out("\n");
out_R << "predict=" << pathresults << ";" << endl;
ofstream outres(pathresults.strtochar());
optionsp->out("\n");
unsigned i,j;
ST::string l1 = ST::doubletostring(optionsp->lower1,4);
ST::string l2 = ST::doubletostring(optionsp->lower2,4);
ST::string u1 = ST::doubletostring(optionsp->upper1,4);
ST::string u2 = ST::doubletostring(optionsp->upper2,4);
l1 = l1.replaceallsigns('.','p');
l2 = l2.replaceallsigns('.','p');
u1 = u1.replaceallsigns('.','p');
u2 = u2.replaceallsigns('.','p');
outres << "intnr" << " ";
for (i=0;i<varnames.size();i++)
outres << varnames[i] << " ";
vector<double *> responsep;
vector<double *> weightpmat;
vector<double *> workmeanmat;
vector<datamatrix *> auxhelp;
for (j=0;j<likep.size();j++)
{
workmeanmat.push_back((betamean.getV()+j));
responsep.push_back(likep[j]->response.getV());
weightpmat.push_back(likep[j]->weight.getV());
auxhelp.push_back(likep[j]->get_auxiliary_parameter());
}
if (nosamplessave==false)
{
for (i=0;i<likep.size();i++)
{
if (likep[i]->outpredictor)
{
outres << "pmean_pred_" << likep[i]->predictor_name << " ";
if (optionsp->samplesize > 1)
{
outres << "pqu" << l1 << "_pred_" << likep[i]->predictor_name << " ";
outres << "pqu" << l2 << "_pred_" << likep[i]->predictor_name << " ";
outres << "pmed_pred_" << likep[i]->predictor_name << " ";
outres << "pqu" << u1 << "_pred_" << likep[i]->predictor_name << " ";
outres << "pqu" << u2 << "_pred_" << likep[i]->predictor_name << " ";
}
}
}
for (i=0;i<likep.size();i++)
{
if (likep[i]->outexpectation)
{
outres << "pmean_E_" << likep[i]->predictor_name << " ";
if (optionsp->samplesize > 1)
{
outres << "pqu" << l1 << "_E_" << likep[i]->predictor_name << " ";
outres << "pqu" << l2 << "_E_" << likep[i]->predictor_name << " ";
outres << "pmed_E_" << likep[i]->predictor_name << " ";
outres << "pqu" << u1 << "_E_" << likep[i]->predictor_name << " ";
outres << "pqu" << u2 << "_E_" << likep[i]->predictor_name << " ";
}
}
}
for (i=0;i<likep.size();i++)
{
if (likep[i]->outpredictor)
{
outres << "pmean_" << likep[i]->predictor_name << " ";
//.........这里部分代码省略.........
示例3: outresults_DIC
void FC_predict_mult::outresults_DIC(ofstream & out_stata, ofstream & out_R,
const ST::string & pathresults)
{
ST::string pathresultsdic = pathresults.substr(0,pathresults.length()-4) + "_DIC.res";
ofstream out(pathresultsdic.strtochar());
out_R << "DIC=" << pathresultsdic << ";" << endl;
optionsp->out(" Results for the DIC are stored in file\n");
optionsp->out(" " + pathresultsdic + "\n");
optionsp->out("\n");
double deviance2=0;
double devhelp;
vector<double *> worklinp;
vector<double *> workresponse;
vector<double *> workweight;
vector<datamatrix *> aux;
unsigned j;
for (j=0;j<likep.size();j++)
{
worklinp.push_back(betamean.getV()+j);
workresponse.push_back(likep[j]->response.getV());
workweight.push_back(likep[j]->weight.getV());
aux.push_back(likep[j]->get_auxiliary_parameter(auxpostmean));
}
unsigned i;
for (i=0;i<likep[0]->nrobs;i++)
{
likep[likep.size()-1]->compute_deviance_mult(workresponse,
workweight,worklinp,
&devhelp,aux);
deviance2 += devhelp;
int s = likep.size();
int bs = betamean.cols();
for (j=0;j<s;j++)
{
worklinp[j]+=bs;
workresponse[j]++;
workweight[j]++;
}
}
double devhelpm = FC_deviance.betamean(0,0);
unsigned d;
if (devhelpm > 1000000000)
d = 14;
else if (devhelpm > 1000000)
d = 11;
else
d = 8;
out << "deviance pd dic" << endl;
optionsp->out(" ESTIMATION RESULTS FOR THE DIC: \n",true);
optionsp->out("\n");
optionsp->out(" Deviance(bar_mu): " +
ST::doubletostring(deviance2,d) + "\n");
out << deviance2 << " ";
optionsp->out(" pD: " +
ST::doubletostring(devhelpm-deviance2,d) + "\n");
out << (devhelpm-deviance2) << " ";
optionsp->out(" DIC: " +
ST::doubletostring(2*devhelpm-deviance2,d) + "\n");
optionsp->out("\n");
out << (2*devhelpm-deviance2) << " " << endl;
optionsp->out("\n");
}
示例4: outresults
void FC_nonp_variance::outresults(ofstream & out_stata,ofstream & out_R,
const ST::string & pathresults)
{
FC::outresults(out_stata,out_R,"");
ST::string l1 = ST::doubletostring(optionsp->lower1,4);
ST::string l2 = ST::doubletostring(optionsp->lower2,4);
ST::string u1 = ST::doubletostring(optionsp->upper1,4);
ST::string u2 = ST::doubletostring(optionsp->upper2,4);
ST::string nl1 = ST::doubletostring(optionsp->lower1,4);
ST::string nl2 = ST::doubletostring(optionsp->lower2,4);
ST::string nu1 = ST::doubletostring(optionsp->upper1,4);
ST::string nu2 = ST::doubletostring(optionsp->upper2,4);
nl1 = nl1.replaceallsigns('.','p');
nl2 = nl2.replaceallsigns('.','p');
nu1 = nu1.replaceallsigns('.','p');
nu2 = nu2.replaceallsigns('.','p');
ST::string vstr;
if (optionsp->samplesize > 1)
{
vstr = " Mean: ";
optionsp->out(vstr + ST::string(' ',20-vstr.length()) +
ST::doubletostring(betamean(0,0),6) + "\n");
vstr = " Std. dev.: ";
optionsp->out(vstr + ST::string(' ',20-vstr.length()) +
ST::doubletostring(sqrt(betavar(0,0)),6) + "\n");
vstr = " " + l1 + "% Quantile: ";
optionsp->out(vstr + ST::string(' ',20-vstr.length()) +
ST::doubletostring(betaqu_l1_lower(0,0),6) + "\n");
vstr = " " + l2 + "% Quantile: ";
optionsp->out(vstr + ST::string(' ',20-vstr.length()) +
ST::doubletostring(betaqu_l2_lower(0,0),6) + "\n");
vstr = " 50% Quantile: ";
optionsp->out(vstr + ST::string(' ',20-vstr.length()) +
ST::doubletostring(betaqu50(0,0),6) + "\n");
vstr = " " + u1 + "% Quantile: ";
optionsp->out(vstr + ST::string(' ',20-vstr.length()) +
ST::doubletostring(betaqu_l2_upper(0,0),6) + "\n");
vstr = " " + u2 + "% Quantile: ";
optionsp->out(vstr + ST::string(' ',20-vstr.length()) +
ST::doubletostring(betaqu_l1_upper(0,0),6) + "\n");
optionsp->out("\n");
}
else
{
optionsp->out(" Smoothing parameter: " +
ST::doubletostring(betamean(0,1),6) + "\n");
optionsp->out("\n");
}
// out_R << "term=" << title << ";" << endl;
if (pathresults.isvalidfile() != 1)
{
optionsp->out(" Results for the variance component are also stored in file\n");
optionsp->out(" " + pathresults + "\n");
optionsp->out("\n");
ST::string paths = pathresults.substr(0,pathresults.length()-4) +
"_sample.raw";
out_R << "pathvarsample=" << paths << endl;
// out_R << "filetype=param; path=" << pathresults << ";" << endl;
ofstream ou(pathresults.strtochar());
if (optionsp->samplesize > 1)
{
ou << "pmean pstd pqu" << nl1 << " pqu" << nl2 << " pmed pqu" <<
nu1 << " pqu" << nu2 << endl;
}
else
{
ou << "pmean" << endl;
}
ou << betamean(0,0) << " ";
if (optionsp->samplesize > 1)
{
if (betavar(0,0) < 0.0000000000001)
ou << 0 << " ";
else
ou << sqrt(betavar(0,0)) << " ";
//.........这里部分代码省略.........