32 void DataOp::readData(
const string& fileName)
34 ifstream
f(fileName.c_str());
44 const size_t p=fileName.rfind(
'/');
47 description(
"\\verb/"+
48 ((p!=string::npos)? fileName.substr(p+1): fileName) +
"/");
54 const double dx=(xmax-xmin)/numSamples;
55 for (
double x=xmin; x<xmax; x+=dx)
56 data[x]=
double(rand())/RAND_MAX;
59 double DataOp::interpolate(
double x)
const 62 if (data.empty())
return 0;
64 const map<double, double>::const_iterator v=data.lower_bound(x);
66 return data.rbegin()->second;
71 map<double, double>::const_iterator v0=v;
73 return (x-v0->first)*(v->second-v0->second)/
74 (v->first-v0->first)+v0->second;
80 double DataOp::deriv(
double x)
const 82 const map<double, double>::const_iterator v=data.lower_bound(x);
83 if (v==data.end() || v==data.begin())
85 map<double, double>::const_iterator v1=v, v2=v;
90 if (v2==data.end()) v2=v;
91 return (v2->second-v1->second)/(v2->first-v1->first);
93 return (v->second-v1->second)/(v->first-v1->first);
void pack(classdesc::pack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
void unpack(classdesc::pack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::DataOp)
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
legacy data importer object