#include <mathexpr.h>
Public Member Functions | |
float ((*pfuncval)(float)) | |
RFunction () | |
RFunction (float((*)(float))) | |
RFunction (const ROperation &opp, RVar *pvarp) | |
RFunction (const ROperation &opp, int nvarsp, RVar **ppvarp) | |
RFunction (const RFunction &) | |
~RFunction () | |
RFunction & | operator= (const RFunction &) |
void | SetName (const char *s) |
float | Val (float) const |
float | Val (float *) const |
ROperation | operator() (const ROperation &) |
Public Attributes | |
signed char | type |
ROperation | op |
int | nvars |
RVar ** | ppvar |
char * | name |
Private Attributes | |
float * | buf |
Friends | |
int | operator== (const RFunction &, const RFunction &) |
Definition at line 124 of file mathexpr.h.
RFunction::RFunction | ( | ) |
RFunction::RFunction | ( | float((*)(float)) | ) |
RFunction::RFunction | ( | const ROperation & | opp, | |
RVar * | pvarp | |||
) |
RFunction::RFunction | ( | const ROperation & | opp, | |
int | nvarsp, | |||
RVar ** | ppvarp | |||
) |
Definition at line 117 of file mathexpr.cpp.
References buf, name, NULL, nvars, ppvar, and type.
00117 :op(opp) 00118 { 00119 type=1;name=new char[1];name[0]=0; 00120 nvars=nvarsp; 00121 if(nvars){ 00122 ppvar=new PRVar[nvars]; 00123 int i;for(i=0;i<nvars;i++)ppvar[i]=ppvarp[i]; 00124 buf=new float[nvars]; 00125 }else {ppvar=NULL;buf=NULL;} 00126 }
RFunction::RFunction | ( | const RFunction & | rfunc | ) |
Definition at line 97 of file mathexpr.cpp.
References buf, CopyStr(), name, NULL, nvars, op, ppvar, and type.
00098 { 00099 if(this==&rfunc)return; 00100 type=rfunc.type;op=rfunc.op; 00101 pfuncval=rfunc.pfuncval; 00102 name=CopyStr(rfunc.name); 00103 nvars=rfunc.nvars; 00104 if(rfunc.ppvar!=NULL&&nvars){ 00105 ppvar=new PRVar[nvars]; 00106 int i;for(i=0;i<nvars;i++)ppvar[i]=rfunc.ppvar[i]; 00107 buf=new float[nvars]; 00108 }else {ppvar=NULL;buf=NULL;} 00109 }
RFunction::~RFunction | ( | ) |
RFunction::float | ( | (*)(float) | pfuncval | ) |
Definition at line 135 of file mathexpr.cpp.
References buf, CopyStr(), name, NULL, nvars, op, ppvar, and type.
00136 { 00137 if(this==&rfunc)return *this; 00138 type=rfunc.type;op=rfunc.op; 00139 pfuncval=rfunc.pfuncval; 00140 delete[]name; 00141 name=CopyStr(rfunc.name); 00142 if(ppvar!=NULL)delete[]ppvar; 00143 ppvar=NULL; 00144 if(buf!=NULL)delete[]buf; 00145 buf=NULL; 00146 nvars=rfunc.nvars; 00147 if(type==1&&nvars){ 00148 ppvar=new PRVar[nvars];buf=new float[nvars]; 00149 int i;for(i=0;i<nvars;i++)ppvar[i]=rfunc.ppvar[i]; 00150 } 00151 return *this; 00152 }
void RFunction::SetName | ( | const char * | s | ) |
Definition at line 154 of file mathexpr.cpp.
References CopyStr(), name, and NULL.
Referenced by vValue::Expr::Bindings::MathExpr::MathExpr(), and ROperation::NthMember().
float RFunction::Val | ( | float | x | ) | const |
Definition at line 157 of file mathexpr.cpp.
References ErrVal, nvars, op, type, and ROperation::Val().
Referenced by ApplyRFunc().
00158 { 00159 if(type==-1||nvars>=2)return ErrVal; 00160 if(type==0)return (*pfuncval)(x); 00161 float xb=*(*ppvar)->pval,y; 00162 *(*ppvar)->pval=x; // Warning : could cause trouble if this value is used in a parallel process 00163 y=op.Val(); 00164 *(*ppvar)->pval=xb; 00165 return y; 00166 }
float RFunction::Val | ( | float * | pv | ) | const |
Definition at line 168 of file mathexpr.cpp.
References buf, ErrVal, nvars, op, ppvar, RVar::pval, type, and ROperation::Val().
00169 { 00170 if(type==-1)return ErrVal; 00171 if(type==0)return (*pfuncval)(*pv); 00172 float y; 00173 int i; 00174 for(i=0;i<nvars;i++){ 00175 buf[i]=*ppvar[i]->pval; 00176 // Warning : could cause trouble if this value is used in a parallel process 00177 *ppvar[i]->pval=pv[i]; 00178 } 00179 y=op.Val(); 00180 for(i=0;i<nvars;i++)*ppvar[i]->pval=buf[i]; 00181 return y; 00182 }
ROperation RFunction::operator() | ( | const ROperation & | op | ) |
Definition at line 353 of file mathexpr.cpp.
References Fun, ROperation::mmb2, ROperation::op, and ROperation::pfunc.
00354 { 00355 /* Code to use to replace expcitly instead of using a pointer to 00356 if(nvars!=op.NMembers()||type==-1||type==0)return ErrVal; 00357 ROperation op2=*pop;int i; 00358 RVar**ppvar2=new PRVar[nvars];char s[11]=""; 00359 for(i=0;i<nvars;i++){ 00360 sprintf(s,";var%i;",i); 00361 ppvar2[i]=new RVar(s,NULL); 00362 op2=op2.Substitute(*ppvar[i],(ROperation)*ppvar2[i]); 00363 } 00364 for(i=0;i<nvars;i++){ 00365 op2=op2.Substitute(*ppvar2[i],op.NthMember(i+1)); 00366 delete ppvar2[i]; 00367 } 00368 delete[]ppvar2; 00369 return op2; 00370 */ 00371 ROperation op2;op2.op=Fun;op2.pfunc=this;op2.mmb2=new ROperation(op); 00372 return op2; 00373 }
Definition at line 685 of file mathexpr.cpp.
00686 { 00687 if(f1.type!=f2.type)return 0; 00688 if(f1.type==-1)return 1; // Nonfunction==nonfunction 00689 if(f1.type==0)return (f1.pfuncval==f2.pfuncval&&EqStr(f1.name,f2.name)); 00690 if(f1.op!=f2.op)return 0; 00691 if(!EqStr(f1.name,f2.name))return 0; 00692 if(f1.nvars!=f2.nvars)return 0; 00693 int i; 00694 for(i=0;i<f1.nvars;i++)if(!(*f1.ppvar[i]==*f2.ppvar[i]))return 0; 00695 return 1; 00696 }
float* RFunction::buf [private] |
Definition at line 125 of file mathexpr.h.
Referenced by operator=(), RFunction(), Val(), and ~RFunction().
signed char RFunction::type |
Definition at line 127 of file mathexpr.h.
Referenced by ROperation::Diff(), ROperation::HasError(), ROperation::NMembers(), ROperation::NthMember(), operator=(), operator==(), RFunction(), and Val().
Definition at line 129 of file mathexpr.h.
Referenced by ROperation::ContainFunc(), ROperation::Diff(), ROperation::HasError(), ROperation::NMembers(), ROperation::NthMember(), operator=(), operator==(), RFunction(), and Val().
int RFunction::nvars |
Definition at line 129 of file mathexpr.h.
Referenced by ApplyRFunc(), ROperation::Diff(), ROperation::NthMember(), operator=(), operator==(), RFunction(), ROperation::ROperation(), and Val().
Definition at line 129 of file mathexpr.h.
Referenced by ROperation::Diff(), ROperation::NthMember(), operator=(), operator==(), RFunction(), Val(), and ~RFunction().
char* RFunction::name |
Definition at line 130 of file mathexpr.h.
Referenced by ROperation::Expr(), IsFunction(), IsVar(), ROperation::NthMember(), operator=(), operator==(), RFunction(), SetName(), and ~RFunction().