本文整理汇总了C++中mu::Parser::GetExpr方法的典型用法代码示例。如果您正苦于以下问题:C++ Parser::GetExpr方法的具体用法?C++ Parser::GetExpr怎么用?C++ Parser::GetExpr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mu::Parser
的用法示例。
在下文中一共展示了Parser::GetExpr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AnnotateErrMsg
std::string ParserMgr::AnnotateErrMsg(const std::string& err_mesg, const mu::Parser& parser) const
{
#ifdef DEBUG_PM_FUNC
ScopeTracker st("ParserMgr::AnnotateErrMsg", std::this_thread::get_id());
#endif
const char* pos_str = "position ";
size_t pos = err_mesg.find(pos_str);
if (pos!=std::string::npos)
{
size_t spc = err_mesg.find_first_of(' ', pos);
std::string s = err_mesg.substr(spc);
int errpos = std::stoi(s);
std::string pstr = parser.GetExpr();
std::string small = "..." + pstr.substr(errpos, 20) + "...";
return err_mesg + " " + small;
}
return err_mesg;
}
示例2: outpre
//.........这里部分代码省略.........
fprintf(stdout, "%s", print_net_message.c_str());
}
cout << endl;
}
// Get next output time and step
if (time >= nextOutputTime) nextOutputTime += sampleTime;
if (step >= nextOutputStep) nextOutputStep += stepInterval;
lastOut = true;
}
else{ // NO
// Only update observables that are involved in functions
for (unsigned int i=0;i < funcObs.size();i++){
OBSERVABLE[funcObs[i]]->second = OBSERVABLE[funcObs[i]]->first->getValue();
}
// Update all functions
for (unsigned int i=0;i < FUNCTION.size();i++){
FUNCTION[i]->second = FUNCTION[i]->first->Eval();
}
}
}
// Final output
if (!lastOut)
{
// Update all observables
for (unsigned int i=0;i < OBSERVABLE.size();i++){
OBSERVABLE[i]->second = OBSERVABLE[i]->first->getValue();
}
// Update all functions
for (unsigned int i=0;i < FUNCTION.size();i++){
FUNCTION[i]->second = FUNCTION[i]->first->Eval();
}
// Output to file
if (print_cdat) Network3::print_species_concentrations(cdat,time);
// Don't print if stopping condition met and !print_on_stop (must print to CDAT)
if (!(stop_condition.Eval() && !print_on_stop)){
if (gdat) Network3::print_observable_concentrations(gdat,time,print_func);
if (print_func) Network3::print_function_values(gdat,time);
string print_net_message;
if (print_save_net){ // Write current system state to .net file
// Collect species populations and update network concentrations vector
double pops[SPECIES.size()];
for (unsigned int j=0;j < SPECIES.size();j++){
pops[j] = SPECIES[j]->population;
}
set_conc_network(pops);
// Print network w/ current species populations using network::print_network()
char buf[1000];
sprintf(buf, "%s_save.net", prefix);
FILE* out = fopen(buf, "w");
print_network(out);
fclose(out);
print_net_message = " Wrote NET file to " + (string)buf;
}
if (print_classif){
fprintf(classif,"%19.12e",time);
for (unsigned int v=0;v < PLA_SIM->classif.size();v++){
fprintf(classif, " %10d", PLA_SIM->classif[v]);
}
fprintf(classif,"\n");
fflush(classif);
}
}
// Output to stdout
if (verbose){
cout << "\t" << fixed << setprecision(6) << time << "\t" << setprecision(0) << step;
// for (unsigned int i=0;i < OBSERVABLE.size();i++) cout << "\t" << OBSERVABLE[i]->second;
if (print_save_net) fprintf(stdout, "%s", print_net_message.c_str());
cout << endl;
}
}
// Messages if stopping conditions met
if (stop_condition.Eval()){ // Stop condition satisfied
cout << "Stopping condition " << stop_condition.GetExpr() << "met in PLA simulation." << endl;
}
// else if (step >= startStep + maxSteps){ // maxSteps limit reached
// cout << "Maximum step limit (" << maxSteps << ") reached in PLA simulation." << endl;
// }
// If print_end_net = true, collect species populations and update network concentrations vector
if (print_end_net){
double pops[SPECIES.size()];
for (unsigned int j=0;j < SPECIES.size();j++){
pops[j] = SPECIES[j]->population;
}
set_conc_network(pops);
}
// Close files
fclose(cdat);
if (gdat) fclose(gdat);
// if (fdat) fclose(fdat);
if (classif) fclose(classif);
// Return value
if (time >= maxTime) return 0;
else if (step >= maxStep) return -1;
else return -2; // stop condition met
}