ROperation Class Reference

#include <mathexpr.h>

Collaboration diagram for ROperation:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ROperation ()
 ROperation (const ROperation &)
 ROperation (float)
 ROperation (const RVar &)
 ROperation (char const *sp, int nvarp=0, PRVar *ppvarp=NULL, int nfuncp=0, PRFunction *ppfuncp=NULL)
 ~ROperation ()
float Val () const
signed char ContainVar (const RVar &) const
signed char ContainFunc (const RFunction &) const
signed char ContainFuncNoRec (const RFunction &) const
ROperation NthMember (int) const
int NMembers () const
signed char HasError (const ROperation *=NULL) const
ROperationoperator= (const ROperation &)
ROperation operator+ () const
ROperation operator- () const
ROperation Diff (const RVar &) const
char * Expr () const
ROperation Substitute (const RVar &, const ROperation &) const

Public Attributes

ROperator op
PROperation mmb1
PROperation mmb2
float ValC
const RVarpvar
float * pvarval
RFunctionpfunc

Private Member Functions

void BuildCode ()
void Destroy ()

Private Attributes

pfoncld * pinstr
float ** pvals
float * ppile
RFunction ** pfuncpile
signed char containfuncflag

Friends

int operator== (const ROperation &, const float)
int operator== (const ROperation &, const ROperation &)
int operator!= (const ROperation &, const ROperation &)
ROperation operator, (const ROperation &, const ROperation &)
ROperation operator+ (const ROperation &, const ROperation &)
ROperation operator- (const ROperation &, const ROperation &)
ROperation operator * (const ROperation &, const ROperation &)
ROperation operator/ (const ROperation &, const ROperation &)
ROperation operator^ (const ROperation &, const ROperation &)
ROperation sqrt (const ROperation &)
ROperation abs (const ROperation &)
ROperation sin (const ROperation &)
ROperation cos (const ROperation &)
ROperation tan (const ROperation &)
ROperation log (const ROperation &)
ROperation exp (const ROperation &)
ROperation acos (const ROperation &)
ROperation asin (const ROperation &)
ROperation atan (const ROperation &)
ROperation ApplyOperator (int, ROperation **, ROperation(*)(const ROperation &, const ROperation &))


Detailed Description

Definition at line 75 of file mathexpr.h.


Constructor & Destructor Documentation

ROperation::ROperation (  ) 

Definition at line 184 of file mathexpr.cpp.

References BuildCode(), containfuncflag, ErrOp, ErrVal, mmb1, mmb2, NULL, op, pfunc, pfuncpile, pinstr, ppile, pvals, pvar, pvarval, and ValC.

Referenced by abs(), acos(), asin(), atan(), cos(), Diff(), exp(), log(), operator *(), operator+(), operator,(), operator-(), operator-(), operator/(), operator=(), operator^(), ROperation(), sin(), sqrt(), Substitute(), and tan().

Here is the call graph for this function:

Here is the caller graph for this function:

ROperation::ROperation ( const ROperation ROp  ) 

Definition at line 192 of file mathexpr.cpp.

References BuildCode(), containfuncflag, mmb1, mmb2, NULL, op, pfunc, pfuncpile, pinstr, ppile, pvals, pvar, pvarval, ROperation(), and ValC.

00193 {
00194     op=ROp.op;pvar=ROp.pvar;pvarval=ROp.pvarval;ValC=ROp.ValC;pfunc=ROp.pfunc;containfuncflag=0;pinstr=NULL;pvals=NULL;ppile=NULL;pfuncpile=NULL;
00195     if(ROp.mmb1!=NULL)mmb1=new ROperation(*(ROp.mmb1));else mmb1=NULL;
00196     if(ROp.mmb2!=NULL)mmb2=new ROperation(*(ROp.mmb2));else mmb2=NULL;
00197     BuildCode();
00198 }

Here is the call graph for this function:

ROperation::ROperation ( float  x  ) 

Definition at line 200 of file mathexpr.cpp.

References BuildCode(), containfuncflag, ErrOp, ErrVal, mmb1, mmb2, NULL, Num, op, Opp, pfunc, pfuncpile, pinstr, ppile, pvals, pvar, pvarval, ROperation(), and ValC.

Here is the call graph for this function:

ROperation::ROperation ( const RVar varp  ) 

Definition at line 209 of file mathexpr.cpp.

References BuildCode(), containfuncflag, ErrVal, mmb1, mmb2, NULL, op, pfunc, pfuncpile, pinstr, ppile, RVar::pval, pvals, pvar, pvarval, ValC, and Var.

Here is the call graph for this function:

ROperation::ROperation ( char const *  sp,
int  nvarp = 0,
PRVar ppvarp = NULL,
int  nfuncp = 0,
PRFunction ppfuncp = NULL 
)

Definition at line 530 of file mathexpr.cpp.

References Abs, Acos, Add, Asin, Atan, BuildCode(), CompStr(), containfuncflag, CopyStr(), Cos, Div, E10, EqStr(), ErrOp, ErrVal, Exp, Fun, InsStr(), IsFunction(), IsolateNumbers(), IsolateVars(), IsTNumeric(), IsVar(), Juxt, Ln, MidStr(), mmb1, mmb2, Mult, NMembers(), NthRoot, NULL, Num, RFunction::nvars, op, Opp, pfunc, pfuncpile, pinstr, Pow, ppile, RVar::pval, pvals, pvar, pvarval, ROperation(), SearchCorOpenbracket(), SearchOperator(), SimplifyStr(), Sin, Sqrt, Sub, SupprSpaces(), Tg, ValC, and Var.

00531 {
00532     ValC=ErrVal;mmb1=NULL;mmb2=NULL;pvar=NULL;op=ErrOp;pvarval=NULL;containfuncflag=0;pfunc=NULL;pinstr=NULL;pvals=NULL;ppile=NULL;pfuncpile=NULL;
00533     int i,j,k,l;signed char flag=1;
00534     char*s=CopyStr(sp),*s1=NULL,*s2=NULL;
00535     SimplifyStr(s);if(!s[0]||!strcmp(s,"Error")){goto fin;}
00536     while(s[0]==':'||s[0]==';'){
00537         s1=CopyStr(s+1);delete[]s;s=s1;s1=NULL;
00538         SimplifyStr(s);if(!s[0]||!strcmp(s,"Error")){goto fin;}
00539     }
00540     if(IsTNumeric(s)){op=Num;ValC=atof(s);mmb1=NULL;mmb2=NULL;goto fin;};
00541     if(EqStr(s,"pi")||EqStr(s,"PI")||EqStr(s,"Pi"))
00542     {op=Num;ValC=3.141592653589793238462643383279L;mmb1=NULL;mmb2=NULL;goto fin;};
00543     if(IsFunction(s,0,nfuncp,ppfuncp)<IsVar(s,0,nvar,ppvarp))
00544         for(i=0;i<nvar;i++)if(EqStr(s,(*(ppvarp+i))->name))
00545             {pvar=ppvarp[i];pvarval=pvar->pval;op=Var;mmb1=NULL;mmb2=NULL;goto fin;};
00546     for(k=0;s[k];k++){
00547         if(s[k]=='('){k=SearchCorOpenbracket(s,k);if(k==-1)break;continue;};
00548         if((l=IsFunction(s,k,nfuncp,ppfuncp))&&l>=IsVar(s,k,nvar,ppvarp)){
00549             i=k+l;while(s[i]==' ')i++;
00550             if(s[i]=='('){
00551                 j=SearchCorOpenbracket(s,i);
00552                 if(j!=-1){InsStr(s,i,';');k=j+1;}else break;
00553             }else if(s[i]!=':'&&s[i]!=';'){InsStr(s,i,':');k=i;}
00554         }
00555     }
00556     IsolateNumbers(s,nvar,ppvarp,nfuncp,ppfuncp);
00557     if(nvar)IsolateVars(s,nvar,ppvarp,nfuncp,ppfuncp);
00558     SupprSpaces(s);
00559     i=SearchOperator(s,Juxt);
00560     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00561         op=Juxt;mmb1=new ROperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00562         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00563     };
00564     i=SearchOperator(s,Add);
00565     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00566         op=Add;mmb1=new ROperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00567         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00568     };
00569     i=SearchOperator(s,Sub);
00570     if(i!=-1){
00571         s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00572         op=Sub;mmb1=new ROperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00573         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00574     };
00575     if(s[0]=='-'){s2=MidStr(s,1,strlen(s)-1);
00576         op=Opp;mmb1=NULL;
00577         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00578     };
00579     for(i=0;s[i];i++){
00580         if(s[i]=='('){i=SearchCorOpenbracket(s,i);if(i==-1)break;continue;};
00581         if(IsFunction(s,i,nfuncp,ppfuncp)){
00582             k=i+IsFunction(s,i,nfuncp,ppfuncp);while(s[k]==' ')k++;
00583             if(s[k]==';'){
00584                 //      s=DelStr(s,k);
00585                 j=k;while(s[j]!='(')j++;
00586                 j=SearchCorOpenbracket(s,j);
00587                 if(j!=-1){InsStr(s,j,')');InsStr(s,i,'(');i=j+2;}
00588             }else if(s[k]==':'){
00589                 //      s=DelStr(s,k);
00590                 for(j=k;s[j];j++)
00591                 if(s[j]=='('){j=SearchCorOpenbracket(s,j);break;}
00592                 if(j==-1)break;
00593                 for(j++;s[j];j++){
00594                     if(s[j]=='('){j=SearchCorOpenbracket(s,j);if(j==-1){flag=0;break;};continue;};
00595                     if(IsFunction(s,j,nfuncp,ppfuncp))break;
00596                 }
00597             if(flag==0){flag=1;break;}
00598                 while(j>i&&s[j-1]!=')')j--;if(j<=i+1)break;
00599                 InsStr(s,i,'(');InsStr(s,j+1,')');
00600                 i=j+1;
00601             }
00602         }
00603     }
00604     for(i=0;s[i]&&s[i+1];i++)if(s[i]==')'&&s[i+1]=='(')
00605             InsStr(s,++i,'*');
00606     if(s[0]=='('&&SearchCorOpenbracket(s,0)==(int)strlen(s)-1){
00607         if(CompStr(s,1,"exp")){op=Exp;s2=MidStr(s,4,strlen(s)-2);}
00608         else if(CompStr(s,1,"abs")){op=Abs;s2=MidStr(s,4,strlen(s)-2);}
00609         else if(CompStr(s,1,"sin")){op=Sin;s2=MidStr(s,4,strlen(s)-2);}
00610         else if(CompStr(s,1,"cos")){op=Cos;s2=MidStr(s,4,strlen(s)-2);}
00611         else if(CompStr(s,1,"tan")){op=Tg;s2=MidStr(s,4,strlen(s)-2);}
00612         else if(CompStr(s,1,"log")){op=Ln;s2=MidStr(s,4,strlen(s)-2);}
00613         else if(CompStr(s,1,"atg")){op=Atan;s2=MidStr(s,4,strlen(s)-2);}
00614         else if(CompStr(s,1,"tg")){op=Tg;s2=MidStr(s,3,strlen(s)-2);}
00615         else if(CompStr(s,1,"ln")){op=Ln;s2=MidStr(s,3,strlen(s)-2);}
00616         else if(CompStr(s,1,"asin")){op=Asin;s2=MidStr(s,5,strlen(s)-2);}
00617         else if(CompStr(s,1,"acos")){op=Acos;s2=MidStr(s,5,strlen(s)-2);}
00618         else if(CompStr(s,1,"atan")){op=Atan;s2=MidStr(s,5,strlen(s)-2);}
00619         else if(CompStr(s,1,"sqrt")){op=Sqrt;s2=MidStr(s,5,strlen(s)-2);}
00620         else if(CompStr(s,1,"arcsin")){op=Asin;s2=MidStr(s,7,strlen(s)-2);}
00621         else if(CompStr(s,1,"arccos")){op=Acos;s2=MidStr(s,7,strlen(s)-2);}
00622         else if(CompStr(s,1,"arctan")){op=Atan;s2=MidStr(s,7,strlen(s)-2);}
00623         else if(CompStr(s,1,"arctg")){op=Atan;s2=MidStr(s,6,strlen(s)-2);}
00624         else {
00625             for(i=-1,k=0,j=0;j<nfuncp;j++)if(CompStr(s,1,ppfuncp[j]->name)&&k<(int)strlen(ppfuncp[j]->name)){k=strlen(ppfuncp[j]->name);i=j;}
00626             if(i>-1){
00627                 op=Fun;s2=MidStr(s,strlen(ppfuncp[i]->name)+1,strlen(s)-2);
00628                 pfunc=ppfuncp[i];
00629             }
00630         }
00631         mmb1=NULL;mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);
00632         if(op==Fun)if(mmb2->NMembers()!=pfunc->nvars){op=ErrOp;mmb1=NULL;mmb2=NULL;goto fin;}
00633         goto fin;
00634     };
00635     i=SearchOperator(s,Mult);
00636     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00637         op=Mult;mmb1=new ROperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00638         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00639     };
00640     i=SearchOperator(s,Div);
00641     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00642         op=Div;mmb1=new ROperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00643         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00644     };
00645     i=SearchOperator(s,Pow);
00646     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00647         op=Pow;mmb1=new ROperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00648         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00649     };
00650     i=SearchOperator(s,NthRoot);
00651     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00652         if(i==0||s[i-1]!=')')
00653         {op=Sqrt;mmb1=NULL;}else
00654         {op=NthRoot;mmb1=new ROperation(s1,nvar,ppvarp,nfuncp,ppfuncp);};
00655         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00656     };
00657     i=SearchOperator(s,E10);
00658     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00659         op=E10;mmb1=new ROperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00660         mmb2=new ROperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00661     };
00662     op=ErrOp;mmb1=NULL;mmb2=NULL;
00663 fin:
00664     BuildCode();
00665     delete[]s;if(s1!=NULL)delete[] s1;if(s2!=NULL)delete[]s2;
00666 }

Here is the call graph for this function:

ROperation::~ROperation (  ) 

Definition at line 187 of file mathexpr.cpp.

References Destroy().

00188 {
00189     Destroy();
00190 }

Here is the call graph for this function:


Member Function Documentation

void ROperation::BuildCode (  )  [private]

Definition at line 1164 of file mathexpr.cpp.

References Abs, Absolu(), Acos, Add, Addition(), ArcCosinus(), ArcSinus(), ArcTangente(), ArcTangente2(), Asin, Atan, BCDouble(), BCFun(), BCSimple(), Cos, Cosinus(), Div, Division(), E10, ErrOp, ErrVal, Exp, Exponentielle(), FonctionError(), Fun, Juxt, JuxtF(), Ln, Logarithme(), mmb1, mmb2, Mult, Multiplication(), NextVal(), NMembers(), NthRoot, NULL, Num, op, Opp, Oppose(), pfunc, pfuncpile, pinstr, Pow, ppile, Puiss10(), Puissance(), pvals, pvarval, Racine(), RacineN(), Sin, Sinus(), Soustraction(), Sqrt, Sub, Tangente(), Tg, ValC, and Var.

Referenced by operator=(), and ROperation().

01165 {
01166     //  if(mmb1!=NULL)mmb1->BuildCode();if(mmb2!=NULL)mmb2->BuildCode();
01167     if(pinstr!=NULL){delete[]pinstr;pinstr=NULL;}
01168     if(pvals!=NULL){delete[]pvals;pvals=NULL;}//does not delete pvals[0] in case it was to be deleted... (no way to know)
01169     if(ppile!=NULL){delete[]ppile;ppile=NULL;}
01170     if(pfuncpile!=NULL){delete[]pfuncpile;pfuncpile=NULL;}
01171     switch(op){
01172     case ErrOp:pinstr=new pfoncld[2];pinstr[0]=&NextVal;pinstr[1]=NULL;
01173         pvals=new float*[2];pvals[0]=new float(ErrVal);pvals[1]=NULL;
01174         ppile=new float[2];ppile[0]=0;ppile[1]=ErrVal;
01175         pfuncpile=new RFunction*[1];pfuncpile[0]=NULL;
01176         break;
01177     case Num:pinstr=new pfoncld[2];pinstr[0]=&NextVal;pinstr[1]=NULL;
01178         pvals=new float*[2];pvals[0]=new float(ValC);pvals[1]=NULL;
01179         ppile=new float[2];ppile[0]=0;ppile[1]=ErrVal;
01180         pfuncpile=new RFunction*[1];pfuncpile[0]=NULL;break;
01181     case Var:pinstr=new pfoncld[2];pinstr[0]=&NextVal;pinstr[1]=NULL;
01182         pvals=new float*[2];pvals[0]=pvarval;pvals[1]=NULL;
01183         ppile=new float[2];ppile[0]=0;ppile[1]=ErrVal;
01184         pfuncpile=new RFunction*[1];pfuncpile[0]=NULL;break;
01185     case Juxt:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01186                            pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&JuxtF);
01187 break;case Add:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01188                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Addition);
01189 break;case Sub:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01190                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Soustraction);
01191 break;case Mult:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01192                                  pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Multiplication);
01193 break;case Div:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01194                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Division);
01195 break;case Pow:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01196                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Puissance);
01197 break;case NthRoot:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01198                                     pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&RacineN);
01199 break;case E10:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01200                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Puiss10);
01201 break;case Opp:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01202                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Oppose);
01203 break;case Sin:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01204                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Sinus);
01205 break;case Sqrt:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01206                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Racine);
01207 break;case Ln:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01208                                ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Logarithme);
01209 break;case Exp:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01210                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Exponentielle);
01211 break;case Cos:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01212                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Cosinus);
01213 break;case Tg:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01214                                ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Tangente);
01215 break;case Atan:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01216                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,(mmb2->NMembers()>1?&ArcTangente2:&ArcTangente));
01217 break;case Asin:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01218                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&ArcSinus);
01219 break;case Acos:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01220                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&ArcCosinus);
01221 break;case Abs:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01222                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Absolu);
01223 break;case Fun:BCFun(pinstr,mmb2->pinstr,pvals,mmb2->pvals,ppile,
01224                              mmb2->ppile,pfuncpile,mmb2->pfuncpile,pfunc);
01225 break;default:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01226                                ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&FonctionError);
01227     }
01228 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ROperation::Destroy ( void   )  [private]

Definition at line 668 of file mathexpr.cpp.

References ErrOp, mmb1, mmb2, NULL, Num, op, pfuncpile, pinstr, ppile, and pvals.

Referenced by operator=(), and ~ROperation().

00669 {
00670     if(mmb1!=NULL&&mmb2!=NULL&&mmb1!=mmb2){delete mmb1;delete mmb2;mmb1=NULL;mmb2=NULL;}
00671     else if(mmb1!=NULL){delete mmb1;mmb1=NULL;}else if(mmb2!=NULL){delete mmb2;mmb2=NULL;}
00672     if(pinstr!=NULL){delete[]pinstr;pinstr=NULL;}
00673     if(pvals!=NULL){
00674         if(op==ErrOp||op==Num)delete pvals[0];
00675         delete[]pvals;pvals=NULL;
00676     }
00677 if(ppile!=NULL){delete[]ppile;ppile=NULL;}
00678     if(pfuncpile!=NULL){delete[]pfuncpile;pfuncpile=NULL;}
00679 }

Here is the caller graph for this function:

float ROperation::Val (  )  const

Definition at line 1072 of file mathexpr.cpp.

References ApplyRFunc(), NextVal(), NULL, pfuncpile, pinstr, ppile, pvals, and RFunc().

Referenced by main(), and RFunction::Val().

01073 {
01074     pfoncld*p1=pinstr;float**p2=pvals,*p3=ppile-1;PRFunction*p4=pfuncpile;
01075     for(;*p1!=NULL;p1++)
01076         if(*p1==&NextVal)*(++p3)=**(p2++);else
01077     if(*p1==&RFunc) ApplyRFunc(*(p4++),p3);
01078     else (**p1)(p3);
01079     return *p3;
01080 }

Here is the call graph for this function:

Here is the caller graph for this function:

signed char ROperation::ContainVar ( const RVar varp  )  const

Definition at line 734 of file mathexpr.cpp.

References ContainVar(), EqStr(), mmb1, mmb2, RVar::name, NULL, op, RVar::pval, pvar, and Var.

Referenced by ContainVar(), Diff(), and Substitute().

00735     {if(op==Var){if(EqStr(pvar->name,varp.name)&&pvar->pval==varp.pval)
00736         return 1;else return 0;};
00737     if(mmb1!=NULL&&mmb1->ContainVar(varp))return 1;
00738     if(mmb2!=NULL&&mmb2->ContainVar(varp))return 1;
00739     return 0;
00740 }

Here is the call graph for this function:

Here is the caller graph for this function:

signed char ROperation::ContainFunc ( const RFunction func  )  const

Definition at line 750 of file mathexpr.cpp.

References ContainFunc(), containfuncflag, Fun, mmb1, mmb2, NULL, RFunction::op, op, and pfunc.

Referenced by ContainFunc().

00751 {
00752     if(containfuncflag)return 0;
00753     if(op==Fun&&*pfunc==func)return 1;
00754     containfuncflag=1;
00755 if(op==Fun)if(pfunc->op.ContainFunc(func)){containfuncflag=0;return 1;}
00756     if(mmb1!=NULL&&mmb1->ContainFunc(func)){containfuncflag=0;return 1;}
00757     if(mmb2!=NULL&&mmb2->ContainFunc(func)){containfuncflag=0;return 1;}
00758     containfuncflag=0;return 0;
00759 }

Here is the call graph for this function:

Here is the caller graph for this function:

signed char ROperation::ContainFuncNoRec ( const RFunction func  )  const

Definition at line 742 of file mathexpr.cpp.

References ContainFuncNoRec(), Fun, mmb1, mmb2, NULL, op, and pfunc.

Referenced by ContainFuncNoRec().

00743     {if(op==Fun){if(*pfunc==func)
00744         return 1;else return 0;}
00745     if(mmb1!=NULL&&mmb1->ContainFuncNoRec(func))return 1;
00746     if(mmb2!=NULL&&mmb2->ContainFuncNoRec(func))return 1;
00747     return 0;
00748 }

Here is the call graph for this function:

Here is the caller graph for this function:

ROperation ROperation::NthMember ( int  n  )  const

Definition at line 778 of file mathexpr.cpp.

References ErrVal, Fun, Juxt, mmb1, mmb2, RFunction::name, NMembers(), NthMember(), NULL, RFunction::nvars, RFunction::op, op, pfunc, RFunction::ppvar, RFunction::SetName(), and RFunction::type.

Referenced by Diff(), and NthMember().

00779 {
00780     PRFunction prf;
00781     if(op==Fun&&pfunc->type==1&&pfunc->op.NMembers()>1){
00782         prf=new RFunction(pfunc->op.NthMember(n),pfunc->nvars,pfunc->ppvar);
00783         char*s=new char[strlen(pfunc->name)+10];
00784         sprintf(s,"(%s_%i)",pfunc->name,n);prf->SetName(s);delete[]s;
00785         return(*prf)(*mmb2);
00786     }
00787     if(n==1){
00788         if(op!=Juxt)return *this; else if(mmb1!=NULL)return *mmb1;else return ErrVal;
00789     };
00790     if(op!=Juxt)return ErrVal;
00791     if(n>1&&mmb2!=NULL)return mmb2->NthMember(n-1);
00792     return ErrVal;
00793 }

Here is the call graph for this function:

Here is the caller graph for this function:

int ROperation::NMembers (  )  const

Definition at line 772 of file mathexpr.cpp.

References Fun, Juxt, mmb2, NMembers(), NULL, RFunction::op, op, pfunc, and RFunction::type.

Referenced by BuildCode(), Diff(), NMembers(), NthMember(), and ROperation().

00773 {
00774     if(op==Fun)return(pfunc->type==1?pfunc->op.NMembers():pfunc->type==0?1:0);
00775     if(op!=Juxt)return 1;else if(mmb2==NULL)return 0;else return 1+mmb2->NMembers();
00776 }

Here is the call graph for this function:

Here is the caller graph for this function:

signed char ROperation::HasError ( const ROperation pop = NULL  )  const

Definition at line 761 of file mathexpr.cpp.

References ErrOp, Fun, HasError(), mmb1, mmb2, NULL, RFunction::op, op, pfunc, and RFunction::type.

Referenced by HasError().

00762 {
00763     if(op==ErrOp)return 1;
00764     if(op==Fun&&pfunc->type==1&&pfunc->op==*(pop==NULL?this:pop))return 1;
00765     if(op==Fun&&pfunc->type==1&&pfunc->op.HasError((pop==NULL?this:pop)))return 1;
00766     if(mmb1!=NULL&&mmb1->HasError((pop==NULL?this:pop)))return 1;
00767     if(mmb2!=NULL&&mmb2->HasError((pop==NULL?this:pop)))return 1;
00768     if(op==Fun&&pfunc->type==-1)return 1;
00769     return 0;
00770 }

Here is the call graph for this function:

Here is the caller graph for this function:

ROperation & ROperation::operator= ( const ROperation ROp  ) 

Definition at line 212 of file mathexpr.cpp.

References BuildCode(), containfuncflag, Destroy(), mmb1, mmb2, NULL, op, pfunc, pfuncpile, pinstr, ppile, pvals, pvar, pvarval, ROperation(), and ValC.

00213 {
00214     if(this==&ROp)return *this;
00215     Destroy();
00216     op=ROp.op;pvar=ROp.pvar;pvarval=ROp.pvarval;ValC=ROp.ValC;pfunc=ROp.pfunc;containfuncflag=0;pinstr=NULL;pvals=NULL;ppile=NULL;pfuncpile=NULL;
00217     if(ROp.mmb1!=NULL)mmb1=new ROperation(*(ROp.mmb1));else mmb1=NULL;
00218     if(ROp.mmb2!=NULL)mmb2=new ROperation(*(ROp.mmb2));else mmb2=NULL;
00219     BuildCode();
00220     return *this;
00221 }

Here is the call graph for this function:

ROperation ROperation::operator+ (  )  const

Definition at line 253 of file mathexpr.cpp.

00254 {return *this;}

ROperation ROperation::operator- (  )  const

Definition at line 256 of file mathexpr.cpp.

References mmb2, Num, op, Opp, ROperation(), and ValC.

00257 {if(op==Num)return -ValC;
00258     ROperation resultat;
00259     if(op==Opp)resultat=*mmb2;else{resultat.op=Opp;resultat.mmb2=new ROperation(*this);};
00260     return resultat;
00261 }

Here is the call graph for this function:

ROperation ROperation::Diff ( const RVar var  )  const

Definition at line 806 of file mathexpr.cpp.

References Abs, Acos, Add, ApplyOperator, Asin, Atan, ContainVar(), Cos, cos, Diff(), Div, E10, ErrVal, Exp, Fun, Juxt, Ln, log, mmb1, mmb2, Mult, NMembers(), NthMember(), NthRoot, RFunction::nvars, RFunction::op, op, Opp, pfunc, Pow, RFunction::ppvar, ROperation(), sin, Sin, sqrt, Sqrt, Sub, Substitute(), Tg, RFunction::type, and Var.

Referenced by Diff(), and main().

00807 {
00808     if(!ContainVar(var))return 0.0;
00809     if(op==Var)return 1.0;
00810     ROperation **ppop1,op2;int i,j;
00811     switch(op){
00812     case Juxt:return(mmb1->Diff(var),mmb2->Diff(var));
00813     case Add:return(mmb1->Diff(var)+mmb2->Diff(var));
00814     case Sub:return(mmb1->Diff(var)-mmb2->Diff(var));
00815     case Opp:return(-mmb2->Diff(var));
00816     case Mult:return((*mmb1)*(mmb2->Diff(var))+(*mmb2)*(mmb1->Diff(var)));
00817     case Div:if(mmb2->ContainVar(var))return(((*mmb2)*(mmb1->Diff(var))-(*mmb1)*(mmb2->Diff(var)))/((*mmb2)^2));
00818         else return(mmb1->Diff(var)/(*mmb2));
00819     case Pow:if(mmb2->ContainVar(var))return((*this)*(log(*mmb1)*mmb2->Diff(var)+
00820                                                 (*mmb2)*mmb1->Diff(var)/(*mmb1)));else
00821         return (*mmb2)*mmb1->Diff(var)*((*mmb1)^(*mmb2-1));
00822     case Sqrt:return(mmb2->Diff(var)/(2*sqrt(*mmb2)));
00823 case NthRoot:{ROperation interm=(*mmb2)^(1/(*mmb1));return interm.Diff(var);};
00824     case E10:{ROperation interm=(*mmb1)*(10^(*mmb2));return interm.Diff(var);};;
00825     case Ln:return (mmb2->Diff(var)/(*mmb2));
00826     case Exp:return (mmb2->Diff(var)*(*this));
00827     case Sin:return (mmb2->Diff(var)*cos(*mmb2));
00828     case Cos:return (-mmb2->Diff(var)*sin(*mmb2));
00829     case Tg:return (mmb2->Diff(var)*(1+((*this)^2)));
00830     case Atan:
00831         if(mmb2->op!=Juxt)return(mmb2->Diff(var)/(1+((*mmb2)^2)));
00832         else return ((mmb2->NthMember(1).Diff(var))*(mmb2->NthMember(2))-(mmb2->NthMember(2).Diff(var))*(mmb2->NthMember(1)))/(((mmb2->NthMember(1))^2)+((mmb2->NthMember(2))^2));
00833     case Asin:return(mmb2->Diff(var)/sqrt(1-((*mmb2)^2)));
00834     case Acos:return(-mmb2->Diff(var)/sqrt(1-((*mmb2)^2)));
00835     case Abs:return(mmb2->Diff(var)*(*mmb2)/(*this));
00836     case Fun:if(pfunc->type==-1||pfunc->type==0)return ErrVal;
00837         if(pfunc->nvars==0)return 0.;
00838         else if(pfunc->op.NMembers()>1){
00839             j=pfunc->op.NMembers();
00840             ppop1=new ROperation*[j];
00841             for(i=0;i<j;i++)ppop1[i]=new ROperation(NthMember(i+1).Diff(var));
00842             op2=ApplyOperator(pfunc->nvars,ppop1,&operator,);
00843             for(i=0;i<pfunc->nvars;i++)delete ppop1[i];
00844             delete[]ppop1;
00845             return op2;
00846         }else{
00847             ppop1=new ROperation*[pfunc->nvars];
00848             for(i=0;i<pfunc->nvars;i++){
00849                 ppop1[i]=new ROperation(pfunc->op.Diff(*pfunc->ppvar[i]));
00850                 for(j=0;j<pfunc->nvars;j++)
00851                     *ppop1[i]=ppop1[i]->Substitute(*pfunc->ppvar[j],mmb2->NthMember(j+1));
00852                 *ppop1[i]=(mmb2->NthMember(i+1).Diff(var))*(*ppop1[i]);
00853             }
00854             op2=ApplyOperator(pfunc->nvars,ppop1,&::operator+);
00855             for(i=0;i<pfunc->nvars;i++)delete ppop1[i];
00856             delete[]ppop1;
00857             return op2;
00858             // In the obtained expression, f' will have been replaced with its expression but f will remain pointing to itself ; this could cause some trouble if changing f afterwards
00859         }
00860     default:return ErrVal;
00861     };
00862 }

Here is the call graph for this function:

Here is the caller graph for this function:

char * ROperation::Expr (  )  const

Definition at line 871 of file mathexpr.cpp.

References Abs, Acos, Add, Asin, Atan, CopyStr(), Cos, Div, E10, Exp, Expr(), Fun, IsFunction(), Juxt, Ln, mmb1, mmb2, Mult, RVar::name, RFunction::name, NthRoot, NULL, Num, op, Opp, pfunc, Pow, pvar, Sin, Sqrt, Sub, Tg, ValC, ValToStr(), and Var.

Referenced by Expr(), and main().

00872 {
00873     char*s=NULL,*s1=NULL,*s2=NULL;int n=10;signed char f=0,g=0;
00874     if(op==Fun)if(strlen(pfunc->name)>4)n+=strlen(pfunc->name)-4;
00875 if(mmb1!=NULL){s1=mmb1->Expr();n+=strlen(s1);f=IsFunction(mmb1->op);}
00876     if(mmb2!=NULL){s2=mmb2->Expr();n+=strlen(s2);g=IsFunction(mmb2->op);}
00877     s=new char[n];
00878     switch(op){
00879     case Num:return ValToStr(ValC);
00880     case Var:return CopyStr(pvar->name);
00881     case Juxt:sprintf(s,"%s , %s",s1,s2);break;
00882     case Add:
00883         f=f||(mmb1->op==Juxt);
00884         g=g||(mmb2->op==Juxt);
00885         if(f&&g)sprintf(s,"(%s)+(%s)",s1,s2);else
00886         if(f)sprintf(s,"(%s)+%s",s1,s2);else
00887         if(g)sprintf(s,"%s+(%s)",s1,s2);else
00888         sprintf(s,"%s+%s",s1,s2);
00889         break;
00890     case Sub:
00891         f=f||(mmb1->op==Juxt);
00892         g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub);
00893         if(f&&g)sprintf(s,"(%s)-(%s)",s1,s2);else
00894         if(f)sprintf(s,"(%s)-%s",s1,s2);else
00895         if(g)sprintf(s,"%s-(%s)",s1,s2);else
00896         sprintf(s,"%s-%s",s1,s2);
00897         break;
00898     case Opp:
00899         if(mmb2->op==Add||mmb2->op==Sub||mmb2->op==Juxt)sprintf(s,"-(%s)",s2);else
00900         sprintf(s,"-%s",s2);
00901         break;
00902     case Mult:
00903         f=f||(mmb1->op==Juxt||mmb1->op==Add||mmb1->op==Sub||mmb1->op==Opp||mmb1->op==Div);
00904         g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub||mmb2->op==Opp);
00905         if(f&&g)sprintf(s,"(%s)*(%s)",s1,s2);else
00906         if(f)sprintf(s,"(%s)*%s",s1,s2);else
00907         if(g)sprintf(s,"%s*(%s)",s1,s2);else
00908         sprintf(s,"%s*%s",s1,s2);
00909         break;
00910     case Div:
00911         f=f||(mmb1->op==Juxt||mmb1->op==Add||mmb1->op==Sub||mmb1->op==Opp||mmb1->op==Div);
00912         g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub||mmb2->op==Opp||mmb2->op==Mult||mmb2->op==Div);
00913         if(f&&g)sprintf(s,"(%s)/(%s)",s1,s2);else
00914         if(f)sprintf(s,"(%s)/%s",s1,s2);else
00915         if(g)sprintf(s,"%s/(%s)",s1,s2);else
00916         sprintf(s,"%s/%s",s1,s2);
00917         break;
00918     case Pow:
00919         f=(mmb1->op!=Num&&mmb1->op!=Var);
00920         g=(mmb2->op!=Num&&mmb2->op!=Var);
00921         if(f&&g)sprintf(s,"(%s)^(%s)",s1,s2);else
00922         if(f)sprintf(s,"(%s)^%s",s1,s2);else
00923         if(g)sprintf(s,"%s^(%s)",s1,s2);else
00924         sprintf(s,"%s^%s",s1,s2);
00925         break;
00926     case Sqrt:
00927         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00928         if(g)sprintf(s,"sqrt(%s)",s2);
00929         else sprintf(s,"sqrt %s",s2);
00930         break;
00931     case NthRoot:
00932         f=(mmb1->op!=Num&&mmb1->op!=Var);
00933         g=(mmb2->op!=Num&&mmb2->op!=Var);
00934         if(f&&g)sprintf(s,"(%s)#(%s)",s1,s2);else
00935         if(f)sprintf(s,"(%s)#%s",s1,s2);else
00936         if(g)sprintf(s,"%s#(%s)",s1,s2);else
00937         sprintf(s,"%s#%s",s1,s2);
00938         break;
00939     case E10:
00940         f=(mmb1->op!=Num&&mmb1->op!=Var);
00941         g=(mmb2->op!=Num&&mmb2->op!=Var);
00942         if(f&&g)sprintf(s,"(%s)E(%s)",s1,s2);else
00943         if(f)sprintf(s,"(%s)E%s",s1,s2);else
00944         if(g)sprintf(s,"%sE(%s)",s1,s2);else
00945         sprintf(s,"%sE%s",s1,s2);
00946         break;
00947     case Ln:
00948         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00949         if(g)sprintf(s,"log(%s)",s2);
00950         else sprintf(s,"log %s",s2);
00951         break;
00952     case Exp:
00953         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00954         if(g)sprintf(s,"exp(%s)",s2);
00955         else sprintf(s,"exp %s",s2);
00956         break;
00957     case Sin:
00958         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00959         if(g)sprintf(s,"sin(%s)",s2);
00960         else sprintf(s,"sin %s",s2);
00961         break;
00962     case Cos:
00963         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00964         if(g)sprintf(s,"cos(%s)",s2);
00965         else sprintf(s,"cos %s",s2);
00966         break;
00967     case Tg:
00968         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00969         if(g)sprintf(s,"tan(%s)",s2);
00970         else sprintf(s,"tan %s",s2);
00971         break;
00972     case Atan:
00973         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00974         if(g)sprintf(s,"atan(%s)",s2);
00975         else sprintf(s,"atan %s",s2);
00976         break;
00977     case Asin:
00978         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00979         if(g)sprintf(s,"asin(%s)",s2);
00980         else sprintf(s,"asin %s",s2);
00981         break;
00982     case Acos:
00983         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00984         if(g)sprintf(s,"acos(%s)",s2);
00985         else sprintf(s,"acos %s",s2);
00986         break;
00987     case Abs:
00988         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
00989         if(g)sprintf(s,"abs(%s)",s2);
00990         else sprintf(s,"abs %s",s2);
00991         break;
00992     case Fun:
00993         sprintf(s,"%s(%s)",pfunc->name,s2);
00994         break;
00995     default:return CopyStr("Error");
00996     };
00997     if(s1!=NULL)delete[] s1;if(s2!=NULL)delete[] s2;
00998     return s;
00999 }

Here is the call graph for this function:

Here is the caller graph for this function:

ROperation ROperation::Substitute ( const RVar var,
const ROperation rop 
) const

Definition at line 795 of file mathexpr.cpp.

References ContainVar(), mmb1, mmb2, NULL, op, pfunc, pvar, pvarval, ROperation(), Substitute(), ValC, and Var.

Referenced by Diff(), and Substitute().

00796 {
00797     if(!ContainVar(var))return *this;
00798     if(op==Var)return rop;
00799     ROperation r;
00800     r.op=op;r.pvar=pvar;r.pvarval=pvarval;r.ValC=ValC;r.pfunc=pfunc;
00801     if(mmb1!=NULL)r.mmb1=new ROperation(mmb1->Substitute(var,rop));else r.mmb1=NULL;
00802     if(mmb2!=NULL)r.mmb2=new ROperation(mmb2->Substitute(var,rop));else r.mmb2=NULL;
00803     return r;
00804 }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

int operator== ( const ROperation op,
const   float 
) [friend]

Definition at line 223 of file mathexpr.cpp.

00224 {return(op.op==Num&&op.ValC==v);}

int operator== ( const ROperation op1,
const ROperation op2 
) [friend]

Definition at line 226 of file mathexpr.cpp.

00227 {if(op1.op!=op2.op)return 0;
00228     if(op1.op==Var)return(*(op1.pvar)==*(op2.pvar));
00229     if(op1.op==Fun)return(op1.pfunc==op2.pfunc); // *op1.pfunc==*op2.pfunc could imply infinite loops in cases of self-dependence
00230     if(op1.op==Num)return(op1.ValC==op2.ValC);
00231     if(op1.mmb1==NULL&&op2.mmb1!=NULL)return 0;
00232     if(op1.mmb2==NULL&&op2.mmb2!=NULL)return 0;
00233     if(op2.mmb1==NULL&&op1.mmb1!=NULL)return 0;
00234     if(op2.mmb2==NULL&&op1.mmb2!=NULL)return 0;
00235     return(((op1.mmb1==NULL&&op2.mmb1==NULL)||(*(op1.mmb1)==*(op2.mmb1)))&&
00236            ((op1.mmb2==NULL&&op2.mmb2==NULL)||(*(op1.mmb2)==*(op2.mmb2))));
00237 }

int operator!= ( const ROperation op1,
const ROperation op2 
) [friend]

Definition at line 239 of file mathexpr.cpp.

00240 {
00241     if(op1.op!=op2.op)return 1;
00242     if(op1.op==Var)return(op1.pvar!=op2.pvar);
00243     if(op1.op==Fun)return(!(op1.pfunc==op2.pfunc)); // *op1.pfunc==*op2.pfunc could imply infinite loops in cases of self-dependence
00244     if(op1.op==Num)return(op1.ValC!=op2.ValC);
00245     if(op1.mmb1==NULL&&op2.mmb1!=NULL)return 1;
00246     if(op1.mmb2==NULL&&op2.mmb2!=NULL)return 1;
00247     if(op2.mmb1==NULL&&op1.mmb1!=NULL)return 1;
00248     if(op2.mmb2==NULL&&op1.mmb2!=NULL)return 1;
00249     return(((op1.mmb1!=NULL||op2.mmb1!=NULL)&&(*(op1.mmb1)!=*(op2.mmb1)))||
00250            ((op1.mmb2!=NULL||op2.mmb2!=NULL)&&(*(op1.mmb2)!=*(op2.mmb2))));
00251 }

ROperation operator, ( const ROperation op1,
const ROperation op2 
) [friend]

Definition at line 263 of file mathexpr.cpp.

00264 {ROperation resultat;
00265     resultat.op=Juxt;resultat.mmb1=new ROperation(op1);
00266     resultat.mmb2=new ROperation(op2);
00267     return resultat;
00268 }

ROperation operator+ ( const ROperation op1,
const ROperation op2 
) [friend]

Definition at line 270 of file mathexpr.cpp.

00271 {
00272     if(op1.op==Num&&op2.op==Num)return op1.ValC+op2.ValC;
00273     if(op1==0.)return op2;if(op2==0.)return op1;
00274     if(op1.op==Opp)return op2-*(op1.mmb2);if(op2.op==Opp)return op1-*(op2.mmb2);
00275     ROperation resultat;
00276     resultat.op=Add;resultat.mmb1=new ROperation(op1);
00277     resultat.mmb2=new ROperation(op2);
00278     return resultat;
00279 }

ROperation operator- ( const ROperation op1,
const ROperation op2 
) [friend]

Definition at line 281 of file mathexpr.cpp.

00282 {
00283     if(op1.op==Num&&op2.op==Num)return op1.ValC-op2.ValC;
00284     if(op1==0.)return -op2;if(op2==0.)return op1;
00285     if(op1.op==Opp)return -(op2+*(op1.mmb2));if(op2.op==Opp)return op1+*(op2.mmb2);
00286     ROperation resultat;
00287     resultat.op=Sub;resultat.mmb1=new ROperation(op1);
00288     resultat.mmb2=new ROperation(op2);
00289     return resultat;
00290 }

ROperation operator * ( const ROperation op1,
const ROperation op2 
) [friend]

Definition at line 292 of file mathexpr.cpp.

00293 {
00294     if(op1.op==Num&&op2.op==Num)return op1.ValC*op2.ValC;
00295     if(op1==0.||op2==0.)return 0.;
00296     if(op1==1.)return op2;if(op2==1.)return op1;
00297     if(op1.op==Opp)return -(*(op1.mmb2)*op2);if(op2.op==Opp)return -(op1**(op2.mmb2));
00298     ROperation resultat;
00299     resultat.op=Mult;resultat.mmb1=new ROperation(op1);
00300     resultat.mmb2=new ROperation(op2);
00301     return resultat;
00302 }

ROperation operator/ ( const ROperation op1,
const ROperation op2 
) [friend]

Definition at line 304 of file mathexpr.cpp.

00305 {if(op1.op==Num&&op2.op==Num)return (op2.ValC?op1.ValC/op2.ValC:ErrVal);
00306     if(op1==0.0)return 0.;if(op2==1.)return op1;if(op2==0.)return ErrVal;
00307     if(op1.op==Opp)return -(*(op1.mmb2)/op2);if(op2.op==Opp)return -(op1/(*(op2.mmb2)));
00308     ROperation resultat;
00309     resultat.op=Div;resultat.mmb1=new ROperation(op1);
00310     resultat.mmb2=new ROperation(op2);
00311     return resultat;
00312 }

ROperation operator^ ( const ROperation op1,
const ROperation op2 
) [friend]

Definition at line 314 of file mathexpr.cpp.

00315 {if(op1==0.)return 0.;
00316     if(op2==0.)return 1.;
00317     if(op2==1.)return op1;
00318     ROperation resultat;
00319     resultat.op=Pow;resultat.mmb1=new ROperation(op1);
00320     resultat.mmb2=new ROperation(op2);
00321     return resultat;
00322 }

ROperation sqrt ( const ROperation op  )  [friend]

Definition at line 324 of file mathexpr.cpp.

Referenced by Diff(), and Racine().

00325 {ROperation rop;rop.op=Sqrt;rop.mmb2=new ROperation(op);return rop;}

ROperation abs ( const ROperation op  )  [friend]

Definition at line 326 of file mathexpr.cpp.

00327 {ROperation rop;rop.op=Abs;rop.mmb2=new ROperation(op);return rop;}

ROperation sin ( const ROperation op  )  [friend]

Definition at line 328 of file mathexpr.cpp.

Referenced by Diff(), and Sinus().

00329 {ROperation rop;rop.op=Sin;rop.mmb2=new ROperation(op);return rop;}

ROperation cos ( const ROperation op  )  [friend]

Definition at line 330 of file mathexpr.cpp.

Referenced by Cosinus(), and Diff().

00331 {ROperation rop;rop.op=Cos;rop.mmb2=new ROperation(op);return rop;}

ROperation tan ( const ROperation op  )  [friend]

Definition at line 332 of file mathexpr.cpp.

Referenced by Tangente().

00333 {ROperation rop;rop.op=Tg;rop.mmb2=new ROperation(op);return rop;}

ROperation log ( const ROperation op  )  [friend]

Definition at line 334 of file mathexpr.cpp.

Referenced by Diff(), Logarithme(), Puissance(), and RacineN().

00335 {ROperation rop;rop.op=Ln;rop.mmb2=new ROperation(op);return rop;}

ROperation exp ( const ROperation op  )  [friend]

Definition at line 336 of file mathexpr.cpp.

Referenced by Exponentielle().

00337 {ROperation rop;rop.op=Exp;rop.mmb2=new ROperation(op);return rop;}

ROperation acos ( const ROperation op  )  [friend]

Definition at line 338 of file mathexpr.cpp.

Referenced by ArcCosinus().

00339 {ROperation rop;rop.op=Acos;rop.mmb2=new ROperation(op);return rop;}

ROperation asin ( const ROperation op  )  [friend]

Definition at line 340 of file mathexpr.cpp.

Referenced by ArcSinus().

00341 {ROperation rop;rop.op=Asin;rop.mmb2=new ROperation(op);return rop;}

ROperation atan ( const ROperation op  )  [friend]

Definition at line 342 of file mathexpr.cpp.

Referenced by ArcTangente().

00343 {ROperation rop;rop.op=Atan;rop.mmb2=new ROperation(op);return rop;}

ROperation ApplyOperator ( int  n,
ROperation **  pops,
ROperation(*)(const ROperation &, const ROperation &)  func 
) [friend]

Definition at line 345 of file mathexpr.cpp.

Referenced by ApplyOperator(), and Diff().

00346 {
00347     if(n<=0)return ErrVal;
00348     if(n==1)return *pops[0];
00349     if(n==2)return (*func)(*pops[0],*pops[1]);
00350     return (*func)(*pops[0],ApplyOperator(n-1,pops+1,func));
00351 }


Member Data Documentation

pfoncld* ROperation::pinstr [private]

Definition at line 76 of file mathexpr.h.

Referenced by BuildCode(), Destroy(), operator=(), ROperation(), and Val().

float** ROperation::pvals [private]

Definition at line 76 of file mathexpr.h.

Referenced by BuildCode(), Destroy(), operator=(), ROperation(), and Val().

float* ROperation::ppile [private]

Definition at line 76 of file mathexpr.h.

Referenced by BuildCode(), Destroy(), operator=(), ROperation(), and Val().

RFunction** ROperation::pfuncpile [private]

Definition at line 76 of file mathexpr.h.

Referenced by BuildCode(), Destroy(), operator=(), ROperation(), and Val().

signed char ROperation::containfuncflag [mutable, private]

Definition at line 77 of file mathexpr.h.

Referenced by ContainFunc(), operator=(), and ROperation().

ROperator ROperation::op

Definition at line 81 of file mathexpr.h.

Referenced by abs(), acos(), asin(), atan(), BuildCode(), ContainFunc(), ContainFuncNoRec(), ContainVar(), cos(), Destroy(), Diff(), exp(), Expr(), HasError(), log(), NMembers(), NthMember(), operator *(), operator!=(), RFunction::operator()(), operator+(), operator,(), operator-(), operator-(), operator/(), operator=(), operator==(), operator^(), ROperation(), sin(), sqrt(), Substitute(), and tan().

PROperation ROperation::mmb1

Definition at line 82 of file mathexpr.h.

Referenced by BuildCode(), ContainFunc(), ContainFuncNoRec(), ContainVar(), Destroy(), Diff(), Expr(), HasError(), NthMember(), operator *(), operator!=(), operator,(), operator/(), operator=(), operator==(), operator^(), ROperation(), and Substitute().

PROperation ROperation::mmb2

Definition at line 82 of file mathexpr.h.

Referenced by abs(), acos(), asin(), atan(), BuildCode(), ContainFunc(), ContainFuncNoRec(), ContainVar(), cos(), Destroy(), Diff(), exp(), Expr(), HasError(), log(), NMembers(), NthMember(), operator *(), operator!=(), RFunction::operator()(), operator+(), operator,(), operator-(), operator-(), operator/(), operator=(), operator==(), operator^(), ROperation(), sin(), sqrt(), Substitute(), and tan().

float ROperation::ValC

Definition at line 83 of file mathexpr.h.

Referenced by BuildCode(), Expr(), operator *(), operator!=(), operator+(), operator-(), operator-(), operator/(), operator=(), operator==(), ROperation(), and Substitute().

const RVar* ROperation::pvar

Definition at line 83 of file mathexpr.h.

Referenced by ContainVar(), Expr(), operator!=(), operator=(), operator==(), ROperation(), and Substitute().

float* ROperation::pvarval

Definition at line 83 of file mathexpr.h.

Referenced by BuildCode(), operator=(), ROperation(), and Substitute().

RFunction* ROperation::pfunc

Definition at line 84 of file mathexpr.h.

Referenced by BuildCode(), ContainFunc(), ContainFuncNoRec(), Diff(), Expr(), HasError(), NMembers(), NthMember(), operator!=(), RFunction::operator()(), operator=(), operator==(), ROperation(), and Substitute().


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