RFunction Class Reference

#include <mathexpr.h>

Collaboration diagram for RFunction:

Collaboration graph
[legend]

List of all members.

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 ()
RFunctionoperator= (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 &)


Detailed Description

Definition at line 124 of file mathexpr.h.


Constructor & Destructor Documentation

RFunction::RFunction (  ) 

Definition at line 85 of file mathexpr.cpp.

References buf, ErrVal, name, NULL, nvars, op, ppvar, and type.

00086 {
00087     type=-1;name=new char[1];name[0]=0;
00088     nvars=0;ppvar=NULL;pfuncval=NULL;op=ErrVal;buf=NULL;
00089 }

RFunction::RFunction ( float((*)(float))   ) 

RFunction::RFunction ( const ROperation opp,
RVar pvarp 
)

Definition at line 111 of file mathexpr.cpp.

References buf, name, nvars, ppvar, and type.

00111                                                      :op(opp)
00112 {
00113     type=1;name=new char[1];name[0]=0;
00114     nvars=1;ppvar=new PRVar[1];ppvar[0]=pvarp;buf=new float[1];
00115 }

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 }

Here is the call graph for this function:

RFunction::~RFunction (  ) 

Definition at line 128 of file mathexpr.cpp.

References buf, name, NULL, and ppvar.

00129 {
00130     if(name!=NULL)delete[]name;
00131     if(ppvar!=NULL)delete[]ppvar;
00132     if(buf!=NULL)delete[]buf;
00133 }


Member Function Documentation

RFunction::float ( (*)(float)  pfuncval  ) 

RFunction & RFunction::operator= ( const RFunction rfunc  ) 

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 }

Here is the call graph for this function:

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().

00155 {if(name!=NULL)delete[]name;name=CopyStr(s);}

Here is the call graph for this function:

Here is the caller graph for this function:

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 }

Here is the call graph for this function:

Here is the caller graph for this function:

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 }

Here is the call graph for this function:

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 }


Friends And Related Function Documentation

int operator== ( const RFunction f1,
const RFunction f2 
) [friend]

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 }


Member Data Documentation

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().

ROperation RFunction::op

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().

RVar** RFunction::ppvar

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().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:52:40 2008 for Armagetron Advanced by  doxygen 1.5.4