diff --git a/pub/src/curve.cpp b/pub/src/curve.cpp index 3f4545a4fe4e6f582b7447c62c607bcb69fe2f38..1aac61799a22bf25d8bd77765dc701b10fe70451 100644 --- a/pub/src/curve.cpp +++ b/pub/src/curve.cpp @@ -104,61 +104,35 @@ void COlc::parseFunction( const string& _expr ) void COlc::askCurve( const string& quest ) { ask_again: - string resp = sask( quest+" (or c,ci,cl; h for help) ?" ); + string resp = sask( quest+" (or e(i|c)(r|w); h for help) ?" ); if ( resp=="h" ) { cout << - "curve definition:\n" - "- either an arithmetic expression,\n" - " containing the running variable t,\n" - " for instance: p0+p1*t\n" - "- or an external evaluation mode:\n" - " c: external command reads P and X (hc for help)\n" - " ci: external command reads P, sets X', Frida interpolates (hci for help)\n" - " cl: dito, but P is read from command line (hcl for help)\n"; + "curve definition:\n" + "- either an arithmetic expression,\n" + " containing the running variable t,\n" + " for instance: p0+p1*t\n" + "- or external evaluation mode e(i|c)(u|a)\n" + " next question will ask for external program\n" + " i: program reads #pars, pars from standard input\n" + " c: program reads pars from command line\n" + " r: program reads #points, points from standard input\n" + " w: program writes default grid, Frida interpolates\n"; goto ask_again; - } else if ( resp=="hc" ) { - cout << - "the external curve evaluation command must:\n" - "- read from stdin a whitespace separated list of:\n" - " - 1*int: the number of parameters M\n" - " - M*double: the parameters\n" - " - 1*int: the number of data points N\n" - " - N*double: the data points\n" - "- write to stdout:\n" - " - N*double: N lines with curve values y\n" - "- write error messages to stderr\n"; - goto ask_again; - } else if ( resp=="hci" ) { - cout << - "the external curve evaluation command must:\n" - "- read from stdin a whitespace separated list of:\n" - " - 1*int: the number of parameters M\n" - " - M*double: the parameters\n" - "- write to stdout:\n" - " - N*2*double: N lines with pairs x y\n" - "- write error messages to stderr\n"; - goto ask_again; - } else if ( resp=="hcl" ) { - cout << - "the external curve evaluation command must:\n" - "- read from M parameters from the command line\n" - "- write to stdout:\n" - " - N*2*double: N lines with pairs x y\n" - "- write error messages to stderr\n"; - goto ask_again; - } else if ( resp=="c" ) { - evaMode = COlc::_SCR; - scrInpMode = COlc::_STDIN; - expr = sask( "Curve evaluation command ?" ); - nP = iask( "Number of parameters ?" ); - } else if ( resp=="ci" ) { - evaMode = COlc::_SCR_INTP; - scrInpMode = COlc::_STDIN; - expr = sask( "Curve evaluation command ?" ); - nP = iask( "Number of parameters ?" ); - } else if ( resp=="cl" ) { - evaMode = COlc::_SCR_INTP; - scrInpMode = COlc::_CMDLIN; + } else if ( resp.size()==3 && resp[0]=='e' && + ( resp[1]=='i' || resp[1]=='c' ) && + ( resp[2]=='r' || resp[2]=='w' ) ) { + if ( resp[2]=='i' ) + scrInpMode = COlc::_STDIN; + else if ( resp[2]=='c' ) + scrInpMode = COlc::_CMDLIN; + else + throw "BUG: impossible case"; + if ( resp[2]=='r' ) + evaMode = COlc::_SCR; + else if ( resp[2]=='w' ) + evaMode = COlc::_SCR_INTP; + else + throw "BUG: impossible case"; expr = sask( "Curve evaluation command ?" ); nP = iask( "Number of parameters ?" ); } else { @@ -506,7 +480,12 @@ string COlc::weight_str() const vector<string> COlc::infoFile() const { vector<string> ret; - ret.push_back( expr ); + string out = ""; + if ( evaMode==_SCR ) + out = "script: "; + else if ( evaMode==_SCR_INTP ) + out = "script (followed by interpolation): "; + ret.push_back( out + expr ); string txt = ""; if( kd!=-1 ) txt += "data file: " + S(kd) + ", ";