diff --git a/pub/CHANGELOG b/pub/CHANGELOG index 094e89b53b60d23ca8c707f1ad3ae60696864bde..739b6e8dd1a557863e7d9de4a5c10c6607a5ba57 100644 --- a/pub/CHANGELOG +++ b/pub/CHANGELOG @@ -1,6 +1,6 @@ Release 2.1.8f of -- new commands ftvd (to read x-y-dy lines), oixyd +- new commands ftvd (to read x-y-dy lines), oixyd, ofs - improved error message from convolution Release 2.1.8e of 19nov13, to be used with frida2libs-131120: diff --git a/pub/src/commands.cpp b/pub/src/commands.cpp index 8fa6d1a8558c38c65bc757e66fc12689ae141a07..ea3b003f8cbe7e4b723c295a2f293e026370cfd8 100644 --- a/pub/src/commands.cpp +++ b/pub/src/commands.cpp @@ -503,6 +503,7 @@ bool fridaCommand( string cmd ) " opa take absolute value\n" " opc copy from another curve\n" " ofi functional integrate\n" + " ofs summation up to current index\n" " ofd functional derivate\n" " ofac functional autocorrelate\n" " oi rank-reducing (""integral"") operations\n" diff --git a/pub/src/opr.cpp b/pub/src/opr.cpp index 8d467ce5abba82b3dee1bc9186c198b9d5e60921..2158eb4b27d7209c45d79342a6ae6e764ea2d533 100644 --- a/pub/src/opr.cpp +++ b/pub/src/opr.cpp @@ -675,6 +675,9 @@ void NOperate::Functional( const string& subcmd ) if ( subcmd=="i" ) { // integrate fout->yco.name = "Int d" + fin->xco.name + " " + fin->yco.name; fout->yco.unit = fin->xco.unit + " * " + fin->yco.unit; + } else if ( subcmd=="s" ) { // sum + fout->yco.name = "Sum_0^i " + fin->yco.name; + fout->yco.unit = fin->yco.unit; } else if ( subcmd=="d" ) { // derive fout->yco.name = "d" + fin->yco.name + " / d" + fin->xco.name; fout->yco.unit = fin->yco.unit + " / " + fin->xco.unit; @@ -695,11 +698,16 @@ void NOperate::Functional( const string& subcmd ) sout->x = sin->x; sout->y.resize( n ); sout->y[0] = 0; - for ( int i=1; i<n; ++i ) { + for ( int i=1; i<n; ++i ) sout->y[i] = sout->y[i-1] + (sin->x[i] - sin->x[i-1]) * (sin->y[i] + sin->y[i-1]) / 2; - } + } else if ( subcmd=="s" ) { // sum + sout->x = sin->x; + sout->y.resize( n ); + sout->y[0] = sin->y[0]; + for ( int i=1; i<n; ++i ) + sout->y[i] = sout->y[i-1] + sin->y[i]; } else if ( subcmd=="d" ) { // derive for( int i=0; i<n-1; ++i ){ double dx = sin->x[i+1] - sin->x[i];