diff --git a/pub/src/expr.cpp b/pub/src/expr.cpp index 42389513d8a785922a1c7be6600e04856b5a686f..fc904897eaa6100e6dc27d635ac04b2be70479c9 100644 --- a/pub/src/expr.cpp +++ b/pub/src/expr.cpp @@ -470,11 +470,6 @@ CTree::CTree( char _typ, const PTree& a0, const PTree& a1 ) throw string( "invalid tree type in char-constructor" ); } -//! Numeric value node constructor. - -CTree::CTree( double v_in ) - : fun(0), val(v_in) {} - //! Function node with 1 argument. CTree::CTree( const class CFunc *f_in, PTree a0 ) @@ -505,24 +500,14 @@ CTree::CTree( const class CFunc *f_in, PTree a0, PTree a1, PTree a2 ) throw string( "BUG: CTree(3) with conflicting #arg" ); } -//! Reference node constructor. - -CTree::CTree( PRef& _ref ) - : fun(0), ref(_ref) {}; - //! Curve evaluation node constructor. -CTree::CTree( PRef& _ref, PTree a0 ) - : fun(0), ref(_ref) +CTree::CTree( PTree a0 ) + : fun(0) { arg[0] = a0; } -//! Register reference node constructor. - -CTree::CTree( PRgr& _rgr ) - : rgr(_rgr) {}; - //***************************************************************************// //* CTree: status requests *// @@ -537,32 +522,6 @@ uint CTree::npar() const return np; } -//! Implementation - -void CNodeFun::npar_exec( uint *np ) const -{ - for ( uint iarg=0; iarg<narg; ++iarg ) - arg[iarg]->npar_exec( np ); -} - -void CNodeConv::npar_exec( uint *np ) const -{ - for ( uint iarg=0; iarg<narg; ++iarg ) - arg[iarg]->npar_exec( np ); -} - -void CNodeDirac::npar_exec( uint *np ) const -{ - for ( uint iarg=0; iarg<narg; ++iarg ) - arg[iarg]->npar_exec( np ); -} - -void CNodeIva::npar_exec( uint *np ) const -{ - if ( ref->typ==CRef::_CP ) - *np = max( *np, ref->num+1 ); -} - //! Does the result depend on k? @@ -799,6 +758,12 @@ void CNodeFun::kdep_exec( bool *kd ) const arg[iarg]->kdep_exec( kd ); } +void CNodeFun::npar_exec( uint *np ) const +{ + for ( uint iarg=0; iarg<narg; ++iarg ) + arg[iarg]->npar_exec( np ); +} + void CNodeFun::set_coord( CCoord& ret, uint k ) const { CCoord r[maxarg]; for ( uint iarg=0; iarg<narg; ++iarg ) @@ -824,7 +789,7 @@ string CNodeFun::tree_info() const //***************************************************************************// CNodeVal::CNodeVal( double _val ) - : CTree( _val ) {} + : val( _val ) {} void CNodeVal::set_coord( CCoord& ret, uint k ) const { ret = CCoord(strg(val), ""); } @@ -835,14 +800,20 @@ string CNodeVal::tree_info() const { return "val[" + strg(val) + "]"; } //***************************************************************************// CNodeIva::CNodeIva( PRef& _ref ) - : CTree( _ref ) {} + : ref( _ref ) {} + +void CNodeIva::npar_exec( uint *np ) const +{ + if ( ref->typ==CRef::_CP ) + *np = max( *np, ref->num+1 ); +} //***************************************************************************// //* CNodeRgr: register reference node *// //***************************************************************************// CNodeRgr::CNodeRgr( PRgr& _rgr ) - : CTree( _rgr ) {} + : rgr( _rgr ) {} void CNodeRgr::tree_val( CResult& ret, const CContext& ctx ) const { ret.set_r( NReg::lastresult ); } @@ -861,7 +832,7 @@ CNodeDummy::CNodeDummy() //***************************************************************************// CNodeCev::CNodeCev( PRef& _ref, PTree a0 ) - : CTree( _ref, a0 ) {} + : CTree( a0 ), ref( _ref ) {} //! A curve evaluation: fc[k,j](arg). @@ -941,6 +912,12 @@ void CNodeConv::kdep_exec( bool *kd ) const arg[iarg]->kdep_exec( kd ); } +void CNodeConv::npar_exec( uint *np ) const +{ + for ( uint iarg=0; iarg<narg; ++iarg ) + arg[iarg]->npar_exec( np ); +} + void CNodeConv::tree_val( CResult& ret, const CContext& ctx ) const { // Return values are requested for n values of _DUMMY ( = t ): @@ -1058,6 +1035,12 @@ void CNodeDirac::kdep_exec( bool *kd ) const arg[iarg]->kdep_exec( kd ); } +void CNodeDirac::npar_exec( uint *np ) const +{ + for ( uint iarg=0; iarg<narg; ++iarg ) + arg[iarg]->npar_exec( np ); +} + //! Convolution or Dirac function: conv(f, shift), dirac(shift). void CNodeDirac::tree_val( CResult& ret, const CContext& ctx ) const diff --git a/pub/src/expr.h b/pub/src/expr.h index 73f2e57c21b9fd8d9093671b008ce92fcde9aacf..9d1b10111f89cde673fc55744ad1691a1ba93ccc 100644 --- a/pub/src/expr.h +++ b/pub/src/expr.h @@ -87,9 +87,6 @@ class CTree { PTree arg[maxarg]; uint narg; const class CFunc* fun; - double val; - PRef ref; - PRgr rgr; public: virtual void npar_exec( uint *np ) const =0; @@ -101,13 +98,10 @@ class CTree { CTree( char _typ ); CTree( char _typ, const PTree& a0 ); CTree( char _typ, const PTree& a0, const PTree& a1 ); - CTree( double v_in ); CTree( const class CFunc *f_in, PTree a0 ); CTree( const class CFunc *f_in, PTree a0, PTree a1 ); CTree( const class CFunc *f_in, PTree a0, PTree a1, PTree a2 ); - CTree( PRef& _ref ); - CTree( PRef& _ref, PTree a0 ); - CTree( PRgr& _rgr ); + CTree( PTree a0 ); uint npar() const; bool k_dependent() const; diff --git a/pub/src/node.h b/pub/src/node.h index ad6fc692c9142f8e21789c3008e3b1d36d510943..13c84c6df76e0f4ae86da55e5a453ecadac3915a 100644 --- a/pub/src/node.h +++ b/pub/src/node.h @@ -27,6 +27,7 @@ class CNodeFun: public CTree { class CNodeVal: public CTree { private: + double val; void npar_exec( uint *np ) const {;} public: CNodeVal( double _val ); @@ -42,6 +43,7 @@ class CNodeVal: public CTree { class CNodeIva: public CTree { private: + PRef ref; void npar_exec( uint *np ) const; public: CNodeIva( PRef& _ref ); @@ -59,6 +61,7 @@ class CNodeIva: public CTree { class CNodeRgr: public CTree { private: + PRgr rgr; void npar_exec( uint *np ) const {;} public: CNodeRgr( PRgr& _rgr ); @@ -90,6 +93,7 @@ class CNodeDummy: public CTree { class CNodeCev: public CTree { private: + PRef ref; void npar_exec( uint *np ) const {;} public: CNodeCev( PRef& _ref, PTree a0 );