CFunction Class Reference

#include <mathexpr_c.h>

Collaboration diagram for CFunction:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 double_complex ((*pfuncval)(double_complex))
 CFunction ()
 CFunction (double_complex((*pfuncvalp)(double_complex)))
 CFunction (const COperation &opp, CVar *pvarp)
 CFunction (const COperation &opp, int nvarsp, CVar **ppvarp)
 CFunction (const CFunction &)
 ~CFunction ()
CFunctionoperator= (const CFunction &)
void SetName (const char *s)
double_complex Val (double_complex) const
double_complex Val (double_complex *) const
COperation operator() (const COperation &)

Public Attributes

signed char type
COperation op
int nvars
CVar ** ppvar
char * name

Private Attributes

double_complex * buf

Friends

int operator== (const CFunction &, const CFunction &)


Detailed Description

Definition at line 137 of file mathexpr_c.h.


Constructor & Destructor Documentation

CFunction::CFunction (  ) 

Definition at line 95 of file mathexpr_c.cpp.

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

00096 {
00097     type=-1;name=new char[1];name[0]=0;
00098     nvars=0;ppvar=NULL;pfuncval=NULL;op=ErrVal;buf=NULL;
00099 }

CFunction::CFunction ( double_complex((*pfuncvalp)(double_complex))   ) 

Definition at line 101 of file mathexpr_c.cpp.

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

00102 {
00103     type=0;pfuncval=pfuncvalp;name=new char[1];name[0]=0;
00104     nvars=1;ppvar=NULL;op=ErrVal;buf=NULL;
00105 }

CFunction::CFunction ( const COperation opp,
CVar pvarp 
)

Definition at line 121 of file mathexpr_c.cpp.

References buf, double_complex(), name, nvars, ppvar, and type.

00121                                                      :op(opp)
00122 {
00123     type=1;name=new char[1];name[0]=0;
00124     nvars=1;ppvar=new PCVar[1];ppvar[0]=pvarp;buf=new double_complex[1];
00125 }

Here is the call graph for this function:

CFunction::CFunction ( const COperation opp,
int  nvarsp,
CVar **  ppvarp 
)

Definition at line 127 of file mathexpr_c.cpp.

References buf, double_complex(), name, NULL, nvars, ppvar, and type.

00127                                                                   :op(opp)
00128 {
00129     type=1;name=new char[1];name[0]=0;
00130     nvars=nvarsp;
00131     if(nvars){
00132         ppvar=new PCVar[nvars];
00133         int i;for(i=0;i<nvars;i++)ppvar[i]=ppvarp[i];
00134         buf=new double_complex[nvars];
00135     }else {ppvar=NULL;buf=NULL;}
00136 }

Here is the call graph for this function:

CFunction::CFunction ( const CFunction rfunc  ) 

Definition at line 107 of file mathexpr_c.cpp.

References buf, CopyStr(), double_complex(), name, NULL, nvars, op, ppvar, and type.

00108 {
00109     if(this==&rfunc)return;
00110     type=rfunc.type;op=rfunc.op;
00111     pfuncval=rfunc.pfuncval;
00112     name=CopyStr(rfunc.name);
00113     nvars=rfunc.nvars;
00114     if(rfunc.ppvar!=NULL&&nvars){
00115         ppvar=new PCVar[nvars];
00116         int i;for(i=0;i<nvars;i++)ppvar[i]=rfunc.ppvar[i];
00117         buf=new double_complex[nvars];
00118     }else {ppvar=NULL;buf=NULL;}
00119 }

Here is the call graph for this function:

CFunction::~CFunction (  ) 

Definition at line 138 of file mathexpr_c.cpp.

References buf, name, NULL, and ppvar.

00139 {
00140     if(name!=NULL)delete[]name;
00141     if(ppvar!=NULL)delete[]ppvar;
00142     if(buf!=NULL)delete[]buf;
00143 }


Member Function Documentation

CFunction::double_complex ( (*)(double_complex)  pfuncval  ) 

Referenced by CFunction(), operator=(), and Val().

Here is the caller graph for this function:

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

Definition at line 145 of file mathexpr_c.cpp.

References buf, CopyStr(), double_complex(), name, NULL, nvars, op, ppvar, and type.

00146 {
00147     if(this==&rfunc)return *this;
00148     type=rfunc.type;op=rfunc.op;
00149     pfuncval=rfunc.pfuncval;
00150     delete[]name;
00151     name=CopyStr(rfunc.name);
00152     if(ppvar!=NULL)delete[]ppvar;
00153     ppvar=NULL;
00154     if(buf!=NULL)delete[]buf;
00155     buf=NULL;
00156     nvars=rfunc.nvars;
00157     if(type==1&&nvars){
00158         ppvar=new PCVar[nvars];buf=new double_complex[nvars];
00159         int i;for(i=0;i<nvars;i++)ppvar[i]=rfunc.ppvar[i];
00160     }
00161     return *this;
00162 }

Here is the call graph for this function:

void CFunction::SetName ( const char *  s  ) 

Definition at line 164 of file mathexpr_c.cpp.

References CopyStr(), name, and NULL.

Referenced by main(), and COperation::NthMember().

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

Here is the call graph for this function:

Here is the caller graph for this function:

double_complex CFunction::Val ( double_complex  x  )  const

Definition at line 167 of file mathexpr_c.cpp.

References double_complex(), ErrVal, nvars, op, type, and COperation::Val().

Referenced by ApplyRFunc().

00168 {
00169     if(type==-1||nvars>=2)return ErrVal;
00170     if(type==0)return (*pfuncval)(x);
00171     double_complex xb=*(*ppvar)->pval,y;
00172     *(*ppvar)->pval=x;  // Warning : could cause trouble if this value is used in a parallel process
00173     y=op.Val();
00174     *(*ppvar)->pval=xb;
00175     return y;
00176 }

Here is the call graph for this function:

Here is the caller graph for this function:

double_complex CFunction::Val ( double_complex *  pv  )  const

Definition at line 178 of file mathexpr_c.cpp.

References buf, double_complex(), ErrVal, nvars, op, ppvar, CVar::pval, type, and COperation::Val().

00179 {
00180     if(type==-1)return ErrVal;
00181     if(type==0)return (*pfuncval)(*pv);
00182     double_complex y;
00183     int i;
00184     for(i=0;i<nvars;i++){
00185         buf[i]=*ppvar[i]->pval;
00186         // Warning : could cause trouble if this value is used in a parallel process
00187         *ppvar[i]->pval=pv[i];
00188     }
00189     y=op.Val();
00190     for(i=0;i<nvars;i++)*ppvar[i]->pval=buf[i];
00191     return y;
00192 }

Here is the call graph for this function:

COperation CFunction::operator() ( const COperation op  ) 

Definition at line 391 of file mathexpr_c.cpp.

References Fun, COperation::mmb2, COperation::op, and COperation::pfunc.

00392 {
00393     /* Code to use to replace explcitly instead of using a pointer to
00394        if(nvars!=op.NMembers()||type==-1||type==0)return ErrVal;
00395        COperation op2=*pop;int i;
00396        CVar**ppvar2=new PCVar[nvars];char s[11]="";
00397        for(i=0;i<nvars;i++){
00398        sprintf(s,";var%i;",i);
00399        ppvar2[i]=new CVar(s,NULL);
00400        op2=op2.Substitute(*ppvar[i],(COperation)*ppvar2[i]);
00401        }
00402        for(i=0;i<nvars;i++){
00403        op2=op2.Substitute(*ppvar2[i],op.NthMember(i+1));
00404        delete ppvar2[i];
00405        }
00406        delete[]ppvar2;
00407        return op2;
00408     */
00409     COperation op2;op2.op=Fun;op2.pfunc=this;op2.mmb2=new COperation(op);
00410     return op2;
00411 }


Friends And Related Function Documentation

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

Definition at line 730 of file mathexpr_c.cpp.

00731 {
00732     if(f1.type!=f2.type)return 0;
00733     if(f1.type==-1)return 1; // Nonfunction==nonfunction
00734     if(f1.type==0)return (f1.pfuncval==f2.pfuncval&&EqStr(f1.name,f2.name));
00735     if(f1.op!=f2.op)return 0;
00736     if(!EqStr(f1.name,f2.name))return 0;
00737     if(f1.nvars!=f2.nvars)return 0;
00738     int i;
00739     for(i=0;i<f1.nvars;i++)if(!(*f1.ppvar[i]==*f2.ppvar[i]))return 0;
00740     return 1;
00741 }


Member Data Documentation

double_complex* CFunction::buf [private]

Definition at line 138 of file mathexpr_c.h.

Referenced by CFunction(), operator=(), Val(), and ~CFunction().

signed char CFunction::type

Definition at line 140 of file mathexpr_c.h.

Referenced by CFunction(), COperation::Diff(), COperation::DiffConj(), COperation::HasError(), COperation::NMembers(), COperation::NthMember(), operator=(), operator==(), and Val().

COperation CFunction::op

Definition at line 142 of file mathexpr_c.h.

Referenced by CFunction(), COperation::ContainFunc(), COperation::Diff(), COperation::DiffConj(), COperation::HasError(), COperation::NMembers(), COperation::NthMember(), operator=(), operator==(), and Val().

int CFunction::nvars

Definition at line 142 of file mathexpr_c.h.

Referenced by ApplyRFunc(), CFunction(), COperation::COperation(), COperation::Diff(), COperation::DiffConj(), COperation::NthMember(), operator=(), operator==(), and Val().

CVar** CFunction::ppvar

Definition at line 142 of file mathexpr_c.h.

Referenced by CFunction(), COperation::Diff(), COperation::DiffConj(), COperation::NthMember(), operator=(), operator==(), Val(), and ~CFunction().

char* CFunction::name

Definition at line 143 of file mathexpr_c.h.

Referenced by CFunction(), COperation::Expr(), IsFunction(), IsVar(), COperation::NthMember(), operator=(), operator==(), SetName(), and ~CFunction().


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