diff --git a/src/curve.cpp b/src/curve.cpp index a771c5bb3f3521a9d657c38723aea0ed5dcfd182..29cdd0113f5f58509a409f9e46ed23c1178d8abc 100644 --- a/src/curve.cpp +++ b/src/curve.cpp @@ -385,7 +385,7 @@ void globalEvaluate( double* par, int m_dat, double* fvec, const CScan *s = &(fd->VS[mydata->j]); vector<double> fit; - fc->T->tree_curve_val( &fit, s->x, mydata->k, mydata->j ); + fc->T->tree_curve_val_vec( &fit, s->x, mydata->k, mydata->j ); for ( uint i=0; i<m_dat; i++) { if( fit[i]==INFINITY ) // TEMPORARY UNTIL exceptions can be @@ -588,10 +588,7 @@ typedef struct { double myeval( double x, void* data ) { EvalDatTyp *mydata = (EvalDatTyp*) data; - vector<double> xx(1), cval; - xx[0] = x; - mydata->fc->T->tree_curve_val( &cval, xx, mydata->k, mydata->j ); - return cval[0]; + return mydata->fc->T->tree_curve_val_sca( x, mydata->k, mydata->j ); } @@ -747,7 +744,7 @@ void NCurveFile::IntegrateFile( const COlc *fin, const int k, }; -//! Numeric interation of one curve. +//! Numeric integration of one curve. double NCurveFile::NumericIntegral( const COlc *fc, const CCurve *c, const int k, const int j, diff --git a/src/edif.cpp b/src/edif.cpp index 03120d436d67985eb9a0cb48e3bff34eb8378bd2..ef9426b0aa640a63743e69aa2728f20bdffd055d 100644 --- a/src/edif.cpp +++ b/src/edif.cpp @@ -1017,7 +1017,7 @@ void NEdif::Plot( bool add ) for ( uint i=0; i<npts; i++ ) S.x[i] = NPlot::X.R.plotcoord2value( NPlot::X.log, i/(npts-1.0) ); - fc->T->tree_curve_val( &(S.y), S.x, k, j ); + fc->T->tree_curve_val_vec( &(S.y), S.x, k, j ); s = &S; } for (uint i=0; i<s->size(); i++) { @@ -1076,7 +1076,7 @@ void NEdif::Plot( bool add ) for( uint i=0; i<npts; ++i ) S.x[i] = NPlot::X.R.plotcoord2value( NPlot::X.log, i/(npts-1.0) ); - fc->T->tree_curve_val( &(S.y), S.x, k, j ); + fc->T->tree_curve_val_vec( &(S.y), S.x, k, j ); s = &S; lstyle = -1; } else diff --git a/src/expr.cpp b/src/expr.cpp index cdbf2b98f6bff9daa7104cf8697f67c2e5c3df18..24d5c32c85341a1a2156e9b69a616614732758dd 100644 --- a/src/expr.cpp +++ b/src/expr.cpp @@ -687,8 +687,9 @@ void CTree::tree_vec_val( vector<double> *ret, uint k, uint j ) const //! Evaluate a curve file's tree, substituting _T and _FP. -void CTree::tree_curve_val( vector<double> *ret, const vector<double>& fargs, - uint k, uint j ) const +void CTree::tree_curve_val_vec( + vector<double> *ret,const vector<double>& fargs, uint k, uint j + ) const { //cout << "tree_curve_val\n"; uint n = fargs.size(); @@ -710,6 +711,15 @@ void CTree::tree_curve_val( vector<double> *ret, const vector<double>& fargs, } } +//! Dito, scalar, not optimized + +double CTree::tree_curve_val_sca( const double fargs, uint k, uint j ) const +{ + vector<double> in(1), out(1); + in[0] = fargs; + tree_curve_val_vec( &out, in, k, j ); + return out[0]; +} //! Retrieve kconv. diff --git a/src/expr.h b/src/expr.h index a550de37228f12605f1d3509381831e5c6921c73..ef9b18850d0740ac9572608bd1af69545e3b1663 100644 --- a/src/expr.h +++ b/src/expr.h @@ -218,8 +218,9 @@ class CTree { void tree_vec_val( vector<double> *ret, uint k=(uint)-1, uint j=(uint)-1 ) const; void tree_uival( uint *ret, const CContext *ctx ) const; - void tree_curve_val( vector<double> *ret, const vector<double>& farg, - uint k, uint j ) const; + void tree_curve_val_vec( vector<double> *ret, const vector<double>& farg, + uint k, uint j ) const; + double tree_curve_val_sca( const double farg, uint k, uint j ) const; void coord( CCoord *ret, uint k=(uint)-1 ) const; uint npar() const; string tree_info() const;