Skip to content
Snippets Groups Projects
Commit 55a11702 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

first arithmetic operation work again.

parent cb6028e2
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,8 @@ typedef double (*func_d_di) (double, int);
typedef double (*func_d_dd) (double, double);
typedef void (*func_e_ee) (double&,double&,double,double,double,double);
typedef void (*func_e_eee) (double&,double&,double,double,double,double,double,double);
typedef double (*func_f1) (double);
typedef double (*func_f2) (double, double);
typedef double (*func_f3) (double, double, double);
......
......@@ -185,9 +185,57 @@ const RObj CNodeFun::tree_val( const CContext& ctx ) const
const CTypedFunc* tf = fu->find_tyfu( base_types, ctx.want_error );
if( !tf )
throw "function " + fu->tag + " not implemented for argument types " + base_types;
void* f = tf->f;
if( is_scalar ) {
if ( tf->outtype=="i" ) {
PObjInt pret( new CObjInt() );
if ( tf->intypes=="i" )
pret->val = (*(func_i_i)(f))( pa[0]->to_i() );
else if ( tf->intypes=="d" )
pret->val = (*(func_i_d)(f))( pa[0]->to_r() );
else if ( tf->intypes=="ii" )
pret->val = (*(func_i_ii)(f))( pa[0]->to_i(), pa[1]->to_i() );
else if ( tf->intypes=="dd" )
pret->val = (*(func_i_dd)(f))( pa[0]->to_r(), pa[1]->to_r() );
else
throw "BUG: unexpected intypes";
return pret;
} else if ( tf->outtype=="d" ) {
PObjDble pret( new CObjDble() );
if ( tf->intypes=="i" )
pret->val = (*(func_d_i)(f))( pa[0]->to_i() );
else if ( tf->intypes=="d" )
pret->val = (*(func_d_d)(f))( pa[0]->to_r() );
else if ( tf->intypes=="ii" )
pret->val = (*(func_d_ii)(f))( pa[0]->to_i(), pa[1]->to_i() );
else if ( tf->intypes=="dd" )
pret->val = (*(func_d_dd)(f))( pa[0]->to_r(), pa[1]->to_r() );
else
throw "BUG: unexpected intypes";
return pret;
} else if ( tf->outtype=="e" ) {
PObjDble pret( new CObjDble() );
if ( tf->intypes=="e" )
(*(func_e_e)(f))( pret->val, pret->err,
pa[0]->to_r(), pa[0]->to_dr() );
else if ( tf->intypes=="ee" )
(*(func_e_ee)(f))( pret->val, pret->err,
pa[0]->to_r(), pa[0]->to_dr(),
pa[1]->to_r(), pa[1]->to_dr() );
else if ( tf->intypes=="eee" )
(*(func_e_eee)(f))( pret->val, pret->err,
pa[0]->to_r(), pa[0]->to_dr(),
pa[1]->to_r(), pa[1]->to_dr(),
pa[2]->to_r(), pa[2]->to_dr() );
else
throw "BUG: unexpected intypes";
return pret;
} else
throw "BUG: unexpected outtype";
}
if( is_scalar || 1 )
throw "incomplete";
throw "incomplete";
/*
bool want_err = ctx.want_error && fu->d3 &&
( pa[0]->has_err()||pa[1]->has_err()||pa[2]->has_err());
......
......@@ -19,10 +19,12 @@ class CObj {
virtual bool has_err() const =0;
virtual char base_type() const =0;
virtual string result_info() const =0;
virtual int to_i( int i ) const { throw "to_i(i) not available"; };
virtual double to_r( int i ) const =0;
virtual double to_dr( int i ) const =0;
virtual double to_r() const =0;
virtual double to_dr() const =0;
virtual int to_i() const { throw "to_i() not available"; };
virtual double to_r() const { throw "to_r() not available"; };
virtual double to_dr() const { throw "to_r() not available"; };
virtual bool to_b() const =0;
virtual string to_s() const =0;
};
......@@ -55,8 +57,10 @@ class CObjInt : public CObjNumber {
bool has_err() const { return false; };
char base_type() const { return 'i'; };
string result_info() const { return "CObjInt("+S(val)+")"; };
double to_r( int i ) const { return val ? 0. : 1. ; };
int to_i( int i ) const { return val; };
double to_r( int i ) const { return val; };
double to_dr( int i ) const { return 0. ; };
int to_i() const { return val; };
double to_r() const { return val; };
double to_dr() const { return 0.; } ;
string to_s() const;
......@@ -82,8 +86,6 @@ class CObjVecDble : public CObjVec {
string result_info() const;
double to_r( int i ) const { return v[i]; };
double to_dr( int i ) const { return dv.size() ? dv[i] : 0; } ;
double to_r() const { throw "to_r() not available for vector"; };
double to_dr() const { throw "to_r() not available for vector"; };
string to_s() const;
bool to_b() const { return v.size(); };
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment