COperation Class Reference

#include <mathexpr_c.h>

Collaboration diagram for COperation:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 COperation ()
 COperation (const COperation &)
 COperation (double)
 COperation (double_complex)
 COperation (const CVar &)
 COperation (char *sp, int nvarp=0, PCVar *ppvarp=NULL, int nfuncp=0, PCFunction *ppfuncp=NULL)
 ~COperation ()
double_complex Val () const
signed char ContainVar (const CVar &) const
signed char ContainFunc (const CFunction &) const
signed char ContainFuncNoRec (const CFunction &) const
COperation NthMember (int) const
int NMembers () const
signed char HasError (const COperation *=NULL) const
COperationoperator= (const COperation &)
COperation operator+ () const
COperation operator- () const
COperation Diff (const CVar &) const
COperation DiffConj (const CVar &) const
char * Expr () const
COperation Substitute (const CVar &, const COperation &) const

Public Attributes

COperator op
PCOperation mmb1
PCOperation mmb2
double_complex ValC
const CVarpvar
double_complex * pvarval
CFunctionpfunc

Private Member Functions

void BuildCode ()
void Destroy ()

Private Attributes

pfoncld * pinstr
double_complex ** pvals
double_complex * ppile
CFunction ** pfuncpile
signed char containfuncflag

Friends

int operator== (const COperation &, const double)
int operator== (const COperation &, const double_complex)
int operator== (const COperation &, const COperation &)
int operator!= (const COperation &, const COperation &)
COperation operator, (const COperation &, const COperation &)
COperation operator+ (const COperation &, const COperation &)
COperation operator- (const COperation &, const COperation &)
COperation operator * (const COperation &, const COperation &)
COperation operator/ (const COperation &, const COperation &)
COperation operator^ (const COperation &, const COperation &)
COperation real (const COperation &)
COperation imag (const COperation &)
COperation conj (const COperation &)
COperation arg (const COperation &)
COperation sqrt (const COperation &)
COperation abs (const COperation &)
COperation sin (const COperation &)
COperation cos (const COperation &)
COperation tan (const COperation &)
COperation log (const COperation &)
COperation exp (const COperation &)
COperation acos (const COperation &)
COperation asin (const COperation &)
COperation atan (const COperation &)
COperation ApplyOperator (int, COperation **, COperation(*)(const COperation &, const COperation &))


Detailed Description

Definition at line 82 of file mathexpr_c.h.


Constructor & Destructor Documentation

COperation::COperation (  ) 

Definition at line 194 of file mathexpr_c.cpp.

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

Referenced by abs(), acos(), arg(), asin(), atan(), conj(), COperation(), cos(), Diff(), DiffConj(), exp(), imag(), log(), operator *(), operator+(), operator,(), operator-(), operator-(), operator/(), operator=(), operator^(), real(), sin(), sqrt(), Substitute(), and tan().

Here is the call graph for this function:

Here is the caller graph for this function:

COperation::COperation ( const COperation COp  ) 

Definition at line 202 of file mathexpr_c.cpp.

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

00203 {
00204     op=COp.op;pvar=COp.pvar;pvarval=COp.pvarval;ValC=COp.ValC;pfunc=COp.pfunc;containfuncflag=0;pinstr=NULL;pvals=NULL;ppile=NULL;pfuncpile=NULL;
00205     if(COp.mmb1!=NULL)mmb1=new COperation(*(COp.mmb1));else mmb1=NULL;
00206     if(COp.mmb2!=NULL)mmb2=new COperation(*(COp.mmb2));else mmb2=NULL;
00207     BuildCode();
00208 }

Here is the call graph for this function:

COperation::COperation ( double  x  ) 

Definition at line 218 of file mathexpr_c.cpp.

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

Here is the call graph for this function:

COperation::COperation ( double_complex  x  ) 

Definition at line 210 of file mathexpr_c.cpp.

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

Here is the call graph for this function:

COperation::COperation ( const CVar varp  ) 

Definition at line 227 of file mathexpr_c.cpp.

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

Here is the call graph for this function:

COperation::COperation ( char *  sp,
int  nvarp = 0,
PCVar ppvarp = NULL,
int  nfuncp = 0,
PCFunction ppfuncp = NULL 
)

Definition at line 569 of file mathexpr_c.cpp.

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

00570 {
00571     ValC=ErrVal;mmb1=NULL;mmb2=NULL;pvar=NULL;op=ErrOp;pvarval=NULL;containfuncflag=0;pfunc=NULL;pinstr=NULL;pvals=NULL;ppile=NULL;pfuncpile=NULL;
00572     int i,j,k,l;signed char flag=1;
00573     char*s=CopyStr(sp),*s1=NULL,*s2=NULL;
00574     SimplifyStr(s);if(!s[0]||!strcmp(s,"Error")){goto fin;}
00575     while(s[0]==':'||s[0]==';'){
00576         s1=CopyStr(s+1);delete[]s;s=s1;s1=NULL;
00577         SimplifyStr(s);if(!s[0]||!strcmp(s,"Error")){goto fin;}
00578     }
00579     if(IsTNumeric(s)){op=Num;ValC=atof(s);mmb1=NULL;mmb2=NULL;goto fin;};
00580     if(EqStr(s,"pi")||EqStr(s,"PI")||EqStr(s,"Pi"))
00581     {op=Num;ValC=3.141592653589793238462643383279L;mmb1=NULL;mmb2=NULL;goto fin;};
00582     if(EqStr(s,"i")||EqStr(s,"I"))
00583     {op=Num;ValC=double_complex(0,1);mmb1=NULL;mmb2=NULL;goto fin;};
00584     if(IsFunction(s,0,nfuncp,ppfuncp)<IsVar(s,0,nvar,ppvarp))
00585         for(i=0;i<nvar;i++)if(EqStr(s,(*(ppvarp+i))->name))
00586             {pvar=ppvarp[i];pvarval=pvar->pval;op=Var;mmb1=NULL;mmb2=NULL;goto fin;};
00587     for(k=0;s[k];k++){
00588         if(s[k]=='('){k=SearchCorOpenbracket(s,k);if(k==-1)break;continue;};
00589         if((l=IsFunction(s,k,nfuncp,ppfuncp))&&l>=IsVar(s,k,nvar,ppvarp)){
00590             i=k+l;while(s[i]==' ')i++;
00591             if(s[i]=='('){
00592                 j=SearchCorOpenbracket(s,i);
00593                 if(j!=-1){InsStr(s,i,';');k=j+1;}
00594             }else if(s[i]!=':'&&s[i]!=';'){InsStr(s,i,':');k=i;}
00595         }
00596     }
00597     IsolateNumbers(s,nvar,ppvarp,nfuncp,ppfuncp);
00598     if(nvar)IsolateVars(s,nvar,ppvarp,nfuncp,ppfuncp);
00599     SupprSpaces(s);
00600     i=SearchOperator(s,Juxt);
00601     if(i!=-1){char*s1="",*s2="";s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00602         op=Juxt;mmb1=new COperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00603         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00604     };
00605     i=SearchOperator(s,Add);
00606     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00607         op=Add;mmb1=new COperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00608         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00609     };
00610     i=SearchOperator(s,Sub);
00611     if(i!=-1){
00612         s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00613         op=Sub;mmb1=new COperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00614         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00615     };
00616     if(s[0]=='-'){s2=MidStr(s,1,strlen(s)-1);
00617         op=Opp;mmb1=NULL;
00618         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00619     };
00620     for(i=0;s[i];i++){
00621         if(s[i]=='('){i=SearchCorOpenbracket(s,i);if(i==-1)break;continue;};
00622         if(IsFunction(s,i,nfuncp,ppfuncp)){
00623             k=i+IsFunction(s,i,nfuncp,ppfuncp);while(s[k]==' ')k++;
00624             if(s[k]==';'){
00625                 //      s=DelStr(s,k);
00626                 j=k;while(s[j]!='(')j++;
00627                 j=SearchCorOpenbracket(s,j);
00628                 if(j!=-1){InsStr(s,j,')');InsStr(s,i,'(');i=j+2;}
00629             }else if(s[k]==':'){
00630                 //      s=DelStr(s,k);
00631                 for(j=k;s[j];j++)
00632                 if(s[j]=='('){j=SearchCorOpenbracket(s,j);break;}
00633                 if(j==-1)break;
00634                 for(j++;s[j];j++){
00635                     if(s[j]=='('){j=SearchCorOpenbracket(s,j);if(j==-1){flag=0;break;};continue;};
00636                     if(IsFunction(s,j,nfuncp,ppfuncp))break;
00637                 }
00638             if(flag==0){flag=1;break;}
00639                 while(j>i&&s[j-1]!=')')j--;if(j<=i+1)break;
00640                 InsStr(s,i,'(');InsStr(s,j+1,')');
00641                 i=j+1;
00642             }
00643         }
00644     }
00645     for(i=0;s[i]&&s[i+1];i++)if(s[i]==')'&&s[i+1]=='(')
00646             InsStr(s,++i,'*');
00647     if(s[0]=='('&&SearchCorOpenbracket(s,0)==(int)strlen(s)-1){
00648         if(CompStr(s,1,"exp")){op=Exp;s2=MidStr(s,4,strlen(s)-2);}
00649         else if(CompStr(s,1,"real")){op=Real;s2=MidStr(s,5,strlen(s)-2);}
00650         else if(CompStr(s,1,"imag")){op=Imag;s2=MidStr(s,5,strlen(s)-2);}
00651         else if(CompStr(s,1,"conj")){op=Conj;s2=MidStr(s,5,strlen(s)-2);}
00652         else if(CompStr(s,1,"arg")){op=Arg;s2=MidStr(s,4,strlen(s)-2);}
00653         else if(CompStr(s,1,"abs")){op=Abs;s2=MidStr(s,4,strlen(s)-2);}
00654         else if(CompStr(s,1,"sin")){op=Sin;s2=MidStr(s,4,strlen(s)-2);}
00655         else if(CompStr(s,1,"cos")){op=Cos;s2=MidStr(s,4,strlen(s)-2);}
00656         else if(CompStr(s,1,"tan")){op=Tg;s2=MidStr(s,4,strlen(s)-2);}
00657         else if(CompStr(s,1,"log")){op=Ln;s2=MidStr(s,4,strlen(s)-2);}
00658         else if(CompStr(s,1,"atg")){op=Atan;s2=MidStr(s,4,strlen(s)-2);}
00659         else if(CompStr(s,1,"tg")){op=Tg;s2=MidStr(s,3,strlen(s)-2);}
00660         else if(CompStr(s,1,"ln")){op=Ln;s2=MidStr(s,3,strlen(s)-2);}
00661         else if(CompStr(s,1,"asin")){op=Asin;s2=MidStr(s,5,strlen(s)-2);}
00662         else if(CompStr(s,1,"acos")){op=Acos;s2=MidStr(s,5,strlen(s)-2);}
00663         else if(CompStr(s,1,"atan")){op=Atan;s2=MidStr(s,5,strlen(s)-2);}
00664         else if(CompStr(s,1,"sqrt")){op=Sqrt;s2=MidStr(s,5,strlen(s)-2);}
00665         else if(CompStr(s,1,"arcsin")){op=Asin;s2=MidStr(s,7,strlen(s)-2);}
00666         else if(CompStr(s,1,"arccos")){op=Acos;s2=MidStr(s,7,strlen(s)-2);}
00667         else if(CompStr(s,1,"arctan")){op=Atan;s2=MidStr(s,7,strlen(s)-2);}
00668         else if(CompStr(s,1,"arctg")){op=Atan;s2=MidStr(s,6,strlen(s)-2);}
00669         else {
00670             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;}
00671             if(i>-1){
00672                 op=Fun;s2=MidStr(s,strlen(ppfuncp[i]->name)+1,strlen(s)-2);
00673                 pfunc=ppfuncp[i];
00674             }
00675         }
00676         mmb1=NULL;mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);
00677         if(op==Fun)if(mmb2->NMembers()!=pfunc->nvars){op=ErrOp;mmb1=NULL;mmb2=NULL;goto fin;}
00678         goto fin;
00679     };
00680     i=SearchOperator(s,Mult);
00681     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00682         op=Mult;mmb1=new COperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00683         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00684     };
00685     i=SearchOperator(s,Div);
00686     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00687         op=Div;mmb1=new COperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00688         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00689     };
00690     i=SearchOperator(s,Pow);
00691     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00692         op=Pow;mmb1=new COperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00693         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00694     };
00695     i=SearchOperator(s,NthRoot);
00696     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00697         if(i==0||s[i-1]!=')')
00698         {op=Sqrt;mmb1=NULL;}else
00699         {op=NthRoot;mmb1=new COperation(s1,nvar,ppvarp,nfuncp,ppfuncp);};
00700         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00701     };
00702     i=SearchOperator(s,E10);
00703     if(i!=-1){s1=MidStr(s,0,i-1);s2=MidStr(s,i+1,strlen(s)-1);
00704         op=E10;mmb1=new COperation(s1,nvar,ppvarp,nfuncp,ppfuncp);
00705         mmb2=new COperation(s2,nvar,ppvarp,nfuncp,ppfuncp);goto fin;
00706     };
00707     op=ErrOp;mmb1=NULL;mmb2=NULL;
00708 fin:
00709     BuildCode();
00710     delete[]s;if(s1!=NULL)delete[] s1;if(s2!=NULL)delete[]s2;
00711 }

Here is the call graph for this function:

COperation::~COperation (  ) 

Definition at line 197 of file mathexpr_c.cpp.

References Destroy().

00198 {
00199     Destroy();
00200 }

Here is the call graph for this function:


Member Function Documentation

void COperation::BuildCode (  )  [private]

Definition at line 1334 of file mathexpr_c.cpp.

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

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

01335 {
01336     //  if(mmb1!=NULL)mmb1->BuildCode();if(mmb2!=NULL)mmb2->BuildCode();
01337     if(pinstr!=NULL){delete[]pinstr;pinstr=NULL;}
01338     if(pvals!=NULL){delete[]pvals;pvals=NULL;}
01339     if(ppile!=NULL){delete[]ppile;ppile=NULL;}
01340     if(pfuncpile!=NULL){delete[]pfuncpile;pfuncpile=NULL;}
01341     switch(op){
01342     case ErrOp:pinstr=new pfoncld[2];pinstr[0]=&NextVal;pinstr[1]=NULL;
01343         pvals=new double_complex*[2];pvals[0]=new double_complex(ErrVal);pvals[1]=NULL;
01344         ppile=new double_complex[2];ppile[0]=0;ppile[1]=ErrVal;
01345         pfuncpile=new CFunction*[1];pfuncpile[0]=NULL;
01346         break;
01347     case Num:pinstr=new pfoncld[2];pinstr[0]=&NextVal;pinstr[1]=NULL;
01348         pvals=new double_complex*[2];pvals[0]=new double_complex(ValC);pvals[1]=NULL;
01349         ppile=new double_complex[2];ppile[0]=0;ppile[1]=ErrVal;
01350         pfuncpile=new CFunction*[1];pfuncpile[0]=NULL;break;
01351     case Var:pinstr=new pfoncld[2];pinstr[0]=&NextVal;pinstr[1]=NULL;
01352         pvals=new double_complex*[2];pvals[0]=pvarval;pvals[1]=NULL;
01353         ppile=new double_complex[2];ppile[0]=0;ppile[1]=ErrVal;
01354         pfuncpile=new CFunction*[1];pfuncpile[0]=NULL;break;
01355     case Juxt:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01356                            pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&JuxtF);
01357 break;case Add:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01358                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Addition);
01359 break;case Sub:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01360                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Soustraction);
01361 break;case Mult:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01362                                  pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Multiplication);
01363 break;case Div:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01364                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Division);
01365 break;case Pow:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01366                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Puissance);
01367 break;case NthRoot:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01368                                     pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&RacineN);
01369 break;case E10:BCDouble(pinstr,mmb1->pinstr,mmb2->pinstr,
01370                                 pvals,mmb1->pvals,mmb2->pvals,ppile,mmb1->ppile,mmb2->ppile,pfuncpile,mmb1->pfuncpile,mmb2->pfuncpile,&Puiss10);
01371 break;case Opp:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01372                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Oppose);
01373 break;case Sin:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01374                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Sinus);
01375 break;case Sqrt:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01376                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Racine);
01377 break;case Ln:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01378                                ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Logarithme);
01379 break;case Exp:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01380                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Exponentielle);
01381 break;case Cos:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01382                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Cosinus);
01383 break;case Tg:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01384                                ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Tangente);
01385 break;case Atan:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01386                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&ArcTangente);
01387 break;case Asin:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01388                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&ArcSinus);
01389 break;case Acos:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01390                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&ArcCosinus);
01391 break;case Abs:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01392                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Absolu);
01393 break;case Real:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01394                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Reelle);
01395 break;case Imag:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01396                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Imaginaire);
01397 break;case Conj:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01398                                  ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Conjugue);
01399 break;case Arg:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01400                                 ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&Argument);
01401 break;case Fun:BCFun(pinstr,mmb2->pinstr,pvals,mmb2->pvals,ppile,
01402                              mmb2->ppile,pfuncpile,mmb2->pfuncpile,pfunc);
01403 break;default:BCSimple(pinstr,mmb2->pinstr,pvals,mmb2->pvals,
01404                                ppile,mmb2->ppile,pfuncpile,mmb2->pfuncpile,&FonctionError);
01405     }
01406 }

Here is the call graph for this function:

Here is the caller graph for this function:

void COperation::Destroy ( void   )  [private]

Definition at line 713 of file mathexpr_c.cpp.

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

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

00714 {
00715     if(mmb1!=NULL&&mmb2!=NULL&&mmb1!=mmb2){delete mmb1;delete mmb2;mmb1=NULL;mmb2=NULL;}
00716     else if(mmb1!=NULL){delete mmb1;mmb1=NULL;}else if(mmb2!=NULL){delete mmb2;mmb2=NULL;}
00717     if(pinstr!=NULL){delete[]pinstr;pinstr=NULL;}
00718     if(pvals!=NULL){
00719         if(op==ErrOp||op==Num)delete pvals[0];
00720         delete[]pvals;pvals=NULL;
00721     }
00722 if(ppile!=NULL){delete[]ppile;ppile=NULL;}
00723     if(pfuncpile!=NULL){delete[]pfuncpile;pfuncpile=NULL;}
00724 }

Here is the caller graph for this function:

double_complex COperation::Val (  )  const

Definition at line 1242 of file mathexpr_c.cpp.

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

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

01243 {
01244     pfoncld*p1=pinstr;double_complex**p2=pvals,*p3=ppile-1;PCFunction*p4=pfuncpile;
01245     for(;*p1!=NULL;p1++)
01246         if(*p1==&NextVal)*(++p3)=**(p2++);else
01247     if(*p1==&RFunc) ApplyRFunc(*(p4++),p3);
01248     else (**p1)(p3);
01249     return *p3;
01250 }

Here is the call graph for this function:

Here is the caller graph for this function:

signed char COperation::ContainVar ( const CVar varp  )  const

Definition at line 785 of file mathexpr_c.cpp.

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

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

00786     {if(op==Var){if(EqStr(pvar->name,varp.name)&&pvar->pval==varp.pval)
00787         return 1;else return 0;};
00788     if(mmb1!=NULL&&mmb1->ContainVar(varp))return 1;
00789     if(mmb2!=NULL&&mmb2->ContainVar(varp))return 1;
00790     return 0;
00791 }

Here is the call graph for this function:

Here is the caller graph for this function:

signed char COperation::ContainFunc ( const CFunction func  )  const

Definition at line 801 of file mathexpr_c.cpp.

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

Referenced by ContainFunc().

00802 {
00803     if(containfuncflag)return 0;
00804     if(op==Fun&&*pfunc==func)return 1;
00805     containfuncflag=1;
00806 if(op==Fun)if(pfunc->op.ContainFunc(func)){containfuncflag=0;return 1;}
00807     if(mmb1!=NULL&&mmb1->ContainFunc(func)){containfuncflag=0;return 1;}
00808     if(mmb2!=NULL&&mmb2->ContainFunc(func)){containfuncflag=0;return 1;}
00809     containfuncflag=0;return 0;
00810 }

Here is the call graph for this function:

Here is the caller graph for this function:

signed char COperation::ContainFuncNoRec ( const CFunction func  )  const

Definition at line 793 of file mathexpr_c.cpp.

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

Referenced by ContainFuncNoRec().

00794     {if(op==Fun){if(*pfunc==func)
00795         return 1;else return 0;}
00796     if(mmb1!=NULL&&mmb1->ContainFuncNoRec(func))return 1;
00797     if(mmb2!=NULL&&mmb2->ContainFuncNoRec(func))return 1;
00798     return 0;
00799 }

Here is the call graph for this function:

Here is the caller graph for this function:

COperation COperation::NthMember ( int  n  )  const

Definition at line 829 of file mathexpr_c.cpp.

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

Referenced by Diff(), DiffConj(), and NthMember().

00830 {
00831     PCFunction prf;
00832     if(op==Fun&&pfunc->type==1&&pfunc->op.NMembers()>1){
00833         prf=new CFunction(pfunc->op.NthMember(n),pfunc->nvars,pfunc->ppvar);
00834         char*s=new char[strlen(pfunc->name)+10];
00835         sprintf(s,"(%s_%i)",pfunc->name,n);prf->SetName(s);delete[]s;
00836         return(*prf)(*mmb2);
00837     }
00838     if(n==1){
00839         if(op!=Juxt)return *this; else if(mmb1!=NULL)return *mmb1;else return ErrVal;
00840     };
00841     if(op!=Juxt)return ErrVal;
00842     if(n>1&&mmb2!=NULL)return mmb2->NthMember(n-1);
00843     return ErrVal;
00844 }

Here is the call graph for this function:

Here is the caller graph for this function:

int COperation::NMembers (  )  const

Definition at line 823 of file mathexpr_c.cpp.

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

Referenced by COperation(), Diff(), DiffConj(), NMembers(), and NthMember().

00824 {
00825     if(op==Fun)return(pfunc->type==1?pfunc->op.NMembers():pfunc->type==0?1:0);
00826     if(op!=Juxt)return 1;else if(mmb2==NULL)return 0;else return 1+mmb2->NMembers();
00827 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 812 of file mathexpr_c.cpp.

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

Referenced by HasError().

00813 {
00814     if(op==ErrOp)return 1;
00815     if(op==Fun&&pfunc->type==1&&pfunc->op==*(pop==NULL?this:pop))return 1;
00816     if(op==Fun&&pfunc->type==1&&pfunc->op.HasError((pop==NULL?this:pop)))return 1;
00817     if(mmb1!=NULL&&mmb1->HasError((pop==NULL?this:pop)))return 1;
00818     if(mmb2!=NULL&&mmb2->HasError((pop==NULL?this:pop)))return 1;
00819     if(op==Fun&&pfunc->type==-1)return 1;
00820     return 0;
00821 }

Here is the call graph for this function:

Here is the caller graph for this function:

COperation & COperation::operator= ( const COperation COp  ) 

Definition at line 230 of file mathexpr_c.cpp.

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

00231 {
00232     if(this==&COp)return *this;
00233     Destroy();
00234     op=COp.op;pvar=COp.pvar;pvarval=COp.pvarval;ValC=COp.ValC;pfunc=COp.pfunc;containfuncflag=0;pinstr=NULL;pvals=NULL;ppile=NULL;pfuncpile=NULL;
00235     if(COp.mmb1!=NULL)mmb1=new COperation(*(COp.mmb1));else mmb1=NULL;
00236     if(COp.mmb2!=NULL)mmb2=new COperation(*(COp.mmb2));else mmb2=NULL;
00237     BuildCode();
00238     return *this;
00239 }

Here is the call graph for this function:

COperation COperation::operator+ (  )  const

Definition at line 274 of file mathexpr_c.cpp.

00275 {return *this;}

COperation COperation::operator- (  )  const

Definition at line 277 of file mathexpr_c.cpp.

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

00278 {if(op==Num)return -ValC;
00279     COperation resultat;
00280     if(op==Opp)resultat=*mmb2;else{resultat.op=Opp;resultat.mmb2=new COperation(*this);};
00281     return resultat;
00282 }

Here is the call graph for this function:

COperation COperation::Diff ( const CVar var  )  const

Definition at line 857 of file mathexpr_c.cpp.

References abs, Abs, Acos, Add, ApplyOperator, Arg, Asin, Atan, Conj, conj, ContainVar(), COperation(), Cos, cos, Diff(), DiffConj(), Div, double_complex, E10, ErrVal, Exp, Fun, Imag, Juxt, Ln, log, mmb1, mmb2, Mult, NMembers(), NthMember(), NthRoot, CFunction::nvars, CFunction::op, op, Opp, pfunc, Pow, CFunction::ppvar, Real, sin, Sin, sqrt, Sqrt, Sub, Substitute(), Tg, CFunction::type, and Var.

Referenced by Diff(), DiffConj(), and main().

00858 {
00859     if(!ContainVar(var))return 0.0;
00860     if(op==Var)return 1.0;
00861     COperation **ppop1,op2;int i,j;
00862     switch(op){
00863     case Juxt:return(mmb1->Diff(var),mmb2->Diff(var));
00864     case Add:return(mmb1->Diff(var)+mmb2->Diff(var));
00865     case Sub:return(mmb1->Diff(var)-mmb2->Diff(var));
00866     case Opp:return(-mmb2->Diff(var));
00867     case Mult:return((*mmb1)*(mmb2->Diff(var))+(*mmb2)*(mmb1->Diff(var)));
00868     case Div:if(mmb2->ContainVar(var))return(((*mmb2)*(mmb1->Diff(var))-(*mmb1)*(mmb2->Diff(var)))/((*mmb2)^2));
00869         else return(mmb1->Diff(var)/(*mmb2));
00870     case Pow:if(mmb2->ContainVar(var))return((*this)*(log(*mmb1)*mmb2->Diff(var)+
00871                                                 (*mmb2)*mmb1->Diff(var)/(*mmb1)));else
00872         return (*mmb2)*mmb1->Diff(var)*((*mmb1)^(*mmb2-1));
00873     case Sqrt:return(mmb2->Diff(var)/(2*sqrt(*mmb2)));
00874 case NthRoot:{COperation interm=(*mmb2)^(1/(*mmb1));return interm.Diff(var);};
00875     case E10:{COperation interm=(*mmb1)*(10^(*mmb2));return interm.Diff(var);};;
00876     case Ln:return (mmb2->Diff(var)/(*mmb2));
00877     case Exp:return (mmb2->Diff(var)*(*this));
00878     case Sin:return (mmb2->Diff(var)*cos(*mmb2));
00879     case Cos:return (-mmb2->Diff(var)*sin(*mmb2));
00880     case Tg:return (mmb2->Diff(var)*(1+((*this)^2)));
00881     case Atan:return(mmb2->Diff(var)/(1+((*mmb2)^2)));
00882     case Asin:return(mmb2->Diff(var)/sqrt(1-((*mmb2)^2)));
00883     case Acos:return(-mmb2->Diff(var)/sqrt(1-((*mmb2)^2)));
00884     case Abs:return ((conj(*mmb2)*mmb2->Diff(var)+(*mmb2)*conj(mmb2->DiffConj(var)))/(2*abs(*mmb2)));
00885     case Conj:return(conj(mmb2->DiffConj(var)));
00886     case Real:return ((mmb2->Diff(var)+conj(mmb2->DiffConj(var)))/2);
00887     case Imag:return ((mmb2->Diff(var)-conj(mmb2->DiffConj(var)))/double_complex(0,2));
00888     case Arg:return (double_complex(0,-.5)*(mmb2->Diff(var)/(*mmb2)-conj(mmb2->DiffConj(var)/(*mmb2))));
00889     case Fun:if(pfunc->type==-1||pfunc->type==0)return ErrVal;
00890         if(pfunc->nvars==0)return 0.;
00891         else if(pfunc->op.NMembers()>1){
00892             j=pfunc->op.NMembers();
00893             ppop1=new COperation*[j];
00894             for(i=0;i<j;i++)ppop1[i]=new COperation(NthMember(i+1).Diff(var));
00895             op2=ApplyOperator(pfunc->nvars,ppop1,&operator,);
00896             for(i=0;i<pfunc->nvars;i++)delete ppop1[i];
00897             delete[]ppop1;
00898             return op2;
00899         }else{
00900             ppop1=new COperation*[2*pfunc->nvars];
00901             for(i=0;i<pfunc->nvars;i++){
00902                 ppop1[i]=new COperation(pfunc->op.Diff(*pfunc->ppvar[i]));
00903                 for(j=0;j<pfunc->nvars;j++)
00904                     *ppop1[i]=ppop1[i]->Substitute(*pfunc->ppvar[j],mmb2->NthMember(j+1));
00905                 *ppop1[i]=(mmb2->NthMember(i+1).Diff(var))*(*ppop1[i]);
00906             }
00907             for(i=pfunc->nvars;i<2*pfunc->nvars;i++){
00908                 ppop1[i]=new COperation(pfunc->op.DiffConj(*pfunc->ppvar[i-pfunc->nvars]));
00909                 for(j=0;j<pfunc->nvars;j++)
00910                     *ppop1[i]=ppop1[i]->Substitute(*pfunc->ppvar[j],mmb2->NthMember(j+1));
00911                 *ppop1[i]=((conj(mmb2->NthMember(i+1-pfunc->nvars))).Diff(var))*(*ppop1[i]);
00912             }
00913             op2=ApplyOperator(2*pfunc->nvars,ppop1,&::operator+);
00914             for(i=0;i<2*pfunc->nvars;i++)delete ppop1[i];
00915             delete[]ppop1;
00916             return op2;
00917             // 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
00918         }
00919     default:return ErrVal;
00920     };
00921 }

Here is the call graph for this function:

Here is the caller graph for this function:

COperation COperation::DiffConj ( const CVar var  )  const

Definition at line 923 of file mathexpr_c.cpp.

References abs, Abs, Acos, Add, ApplyOperator, Arg, Asin, Atan, Conj, conj, ContainVar(), COperation(), Cos, cos, Diff(), DiffConj(), Div, double_complex, E10, ErrVal, Exp, Fun, Imag, Juxt, Ln, log, mmb1, mmb2, Mult, NMembers(), NthMember(), NthRoot, CFunction::nvars, CFunction::op, op, Opp, pfunc, Pow, CFunction::ppvar, Real, sin, Sin, sqrt, Sqrt, Sub, Substitute(), Tg, CFunction::type, and Var.

Referenced by Diff(), DiffConj(), and main().

00924 {
00925     if(!ContainVar(var))return 0.0;
00926     if(op==Var)return 0.0;
00927     COperation **ppop1,op2;int i,j;
00928     switch(op){
00929     case Juxt:return(mmb1->DiffConj(var),mmb2->DiffConj(var));
00930     case Add:return(mmb1->DiffConj(var)+mmb2->DiffConj(var));
00931     case Sub:return(mmb1->DiffConj(var)-mmb2->DiffConj(var));
00932     case Opp:return(-mmb2->DiffConj(var));
00933     case Mult:return((*mmb1)*(mmb2->DiffConj(var))+(*mmb2)*(mmb1->DiffConj(var)));
00934     case Div:if(mmb2->ContainVar(var))return(((*mmb2)*(mmb1->DiffConj(var))-(*mmb1)*(mmb2->DiffConj(var)))/((*mmb2)^2));
00935         else return(mmb1->DiffConj(var)/(*mmb2));
00936     case Pow:if(mmb2->ContainVar(var))return((*this)*(log(*mmb1)*mmb2->DiffConj(var)+
00937                                                 (*mmb2)*mmb1->DiffConj(var)/(*mmb1)));else
00938         return (*mmb2)*mmb1->DiffConj(var)*((*mmb1)^(*mmb2-1));
00939     case Sqrt:return(mmb2->DiffConj(var)/(2*sqrt(*mmb2)));
00940 case NthRoot:{COperation interm=(*mmb2)^(1/(*mmb1));return interm.DiffConj(var);};
00941     case E10:{COperation interm=(*mmb1)*(10^(*mmb2));return interm.DiffConj(var);};;
00942     case Ln:return (mmb2->DiffConj(var)/(*mmb2));
00943     case Exp:return (mmb2->DiffConj(var)*(*this));
00944     case Sin:return (mmb2->DiffConj(var)*cos(*mmb2));
00945     case Cos:return (-mmb2->DiffConj(var)*sin(*mmb2));
00946     case Tg:return (mmb2->DiffConj(var)*(1+((*this)^2)));
00947     case Atan:return(mmb2->DiffConj(var)/(1+((*mmb2)^2)));
00948     case Asin:return(mmb2->DiffConj(var)/sqrt(1-((*mmb2)^2)));
00949     case Acos:return(-mmb2->DiffConj(var)/sqrt(1-((*mmb2)^2)));
00950     case Abs:return ((conj(*mmb2)*mmb2->DiffConj(var)+(*mmb2)*conj(mmb2->Diff(var)))/(2*abs(*mmb2)));
00951     case Conj:return(conj(mmb2->Diff(var)));
00952     case Real:return ((mmb2->DiffConj(var)+conj(mmb2->Diff(var)))/2);
00953     case Imag:return ((mmb2->DiffConj(var)-conj(mmb2->Diff(var)))/double_complex(0,2));
00954     case Arg:return (double_complex(0,-.5)*(mmb2->DiffConj(var)/(*mmb2)-conj(mmb2->Diff(var)/(*mmb2))));
00955     case Fun:if(pfunc->type==-1||pfunc->type==0)return ErrVal;
00956         if(pfunc->nvars==0)return 0.;
00957         else if(pfunc->op.NMembers()>1){
00958             j=pfunc->op.NMembers();
00959             ppop1=new COperation*[j];
00960             for(i=0;i<j;i++)ppop1[i]=new COperation(NthMember(i+1).DiffConj(var));
00961             op2=ApplyOperator(pfunc->nvars,ppop1,&operator,);
00962             for(i=0;i<pfunc->nvars;i++)delete ppop1[i];
00963             delete[]ppop1;
00964             return op2;
00965         }else{
00966             ppop1=new COperation*[2*pfunc->nvars];
00967             for(i=0;i<pfunc->nvars;i++){
00968                 ppop1[i]=new COperation(pfunc->op.DiffConj(*pfunc->ppvar[i]));
00969                 for(j=0;j<pfunc->nvars;j++)
00970                     *ppop1[i]=ppop1[i]->Substitute(*pfunc->ppvar[j],mmb2->NthMember(j+1));
00971                 *ppop1[i]=(conj(mmb2->NthMember(i+1).Diff(var)))*(*ppop1[i]);
00972             }
00973             for(i=pfunc->nvars;i<2*pfunc->nvars;i++){
00974                 ppop1[i]=new COperation(pfunc->op.Diff(*pfunc->ppvar[i-pfunc->nvars]));
00975                 for(j=0;j<pfunc->nvars;j++)
00976                     *ppop1[i]=ppop1[i]->Substitute(*pfunc->ppvar[j],mmb2->NthMember(j+1));
00977                 *ppop1[i]=(mmb2->NthMember(i+1-pfunc->nvars).DiffConj(var))*(*ppop1[i]);
00978             }
00979             op2=ApplyOperator(2*pfunc->nvars,ppop1,&::operator+);
00980             for(i=0;i<2*pfunc->nvars;i++)delete ppop1[i];
00981             delete[]ppop1;
00982             return op2;
00983             // 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
00984         }
00985     default:return ErrVal;
00986     };
00987 }

Here is the call graph for this function:

Here is the caller graph for this function:

char * COperation::Expr (  )  const

Definition at line 1023 of file mathexpr_c.cpp.

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

Referenced by Expr(), and main().

01024 {
01025     char*s=NULL,*s1=NULL,*s2=NULL;int n=10;signed char f=0,g=0;
01026     if(op==Fun)if(strlen(pfunc->name)>4)n+=strlen(pfunc->name)-4;
01027 if(mmb1!=NULL){s1=mmb1->Expr();n+=strlen(s1);f=IsFunction(mmb1->op);}
01028     if(mmb2!=NULL){s2=mmb2->Expr();n+=strlen(s2);g=IsFunction(mmb2->op);}
01029     s=new char[n];
01030     switch(op){
01031     case Num:return PrettyPrint(ValC);
01032     case Var:return CopyStr(pvar->name);
01033     case Juxt:sprintf(s,"%s , %s",s1,s2);break;
01034     case Add:
01035         f=f||(mmb1->op==Juxt);
01036         g=g||(mmb2->op==Juxt);
01037         if(f&&g)sprintf(s,"(%s)+(%s)",s1,s2);else
01038         if(f)sprintf(s,"(%s)+%s",s1,s2);else
01039         if(g)sprintf(s,"%s+(%s)",s1,s2);else
01040         sprintf(s,"%s+%s",s1,s2);
01041         break;
01042     case Sub:
01043         f=f||(mmb1->op==Juxt);
01044         g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub);
01045         if(f&&g)sprintf(s,"(%s)-(%s)",s1,s2);else
01046         if(f)sprintf(s,"(%s)-%s",s1,s2);else
01047         if(g)sprintf(s,"%s-(%s)",s1,s2);else
01048         sprintf(s,"%s-%s",s1,s2);
01049         break;
01050     case Opp:
01051         if(mmb2->op==Add||mmb2->op==Sub||mmb2->op==Juxt)sprintf(s,"-(%s)",s2);else
01052         sprintf(s,"-%s",s2);
01053         break;
01054     case Mult:
01055         f=f||(mmb1->op==Juxt||mmb1->op==Add||mmb1->op==Sub||mmb1->op==Opp);
01056         g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub||mmb2->op==Opp);
01057         if(f&&g)sprintf(s,"(%s)*(%s)",s1,s2);else
01058         if(f)sprintf(s,"(%s)*%s",s1,s2);else
01059         if(g)sprintf(s,"%s*(%s)",s1,s2);else
01060         sprintf(s,"%s*%s",s1,s2);
01061         break;
01062     case Div:
01063         f=f||(mmb1->op==Juxt||mmb1->op==Add||mmb1->op==Sub||mmb1->op==Opp||mmb1->op==Div);
01064         g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub||mmb2->op==Opp||mmb2->op==Mult||mmb2->op==Div);
01065         if(f&&g)sprintf(s,"(%s)/(%s)",s1,s2);else
01066         if(f)sprintf(s,"(%s)/%s",s1,s2);else
01067         if(g)sprintf(s,"%s/(%s)",s1,s2);else
01068         sprintf(s,"%s/%s",s1,s2);
01069         break;
01070     case Pow:
01071         f=(mmb1->op!=Num&&mmb1->op!=Var);
01072         g=(mmb2->op!=Num&&mmb2->op!=Var);
01073         if(f&&g)sprintf(s,"(%s)^(%s)",s1,s2);else
01074         if(f)sprintf(s,"(%s)^%s",s1,s2);else
01075         if(g)sprintf(s,"%s^(%s)",s1,s2);else
01076         sprintf(s,"%s^%s",s1,s2);
01077         break;
01078     case Sqrt:
01079         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01080         if(g)sprintf(s,"sqrt(%s)",s2);
01081         else sprintf(s,"sqrt %s",s2);
01082         break;
01083     case NthRoot:
01084         f=(mmb1->op!=Num&&mmb1->op!=Var);
01085         g=(mmb2->op!=Num&&mmb2->op!=Var);
01086         if(f&&g)sprintf(s,"(%s)#(%s)",s1,s2);else
01087         if(f)sprintf(s,"(%s)#%s",s1,s2);else
01088         if(g)sprintf(s,"%s#(%s)",s1,s2);else
01089         sprintf(s,"%s#%s",s1,s2);
01090         break;
01091     case E10:
01092         f=(mmb1->op!=Num&&mmb1->op!=Var);
01093         g=(mmb2->op!=Num&&mmb2->op!=Var);
01094         if(f&&g)sprintf(s,"(%s)E(%s)",s1,s2);else
01095         if(f)sprintf(s,"(%s)E%s",s1,s2);else
01096         if(g)sprintf(s,"%sE(%s)",s1,s2);else
01097         sprintf(s,"%sE%s",s1,s2);
01098         break;
01099     case Ln:
01100         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01101         if(g)sprintf(s,"log(%s)",s2);
01102         else sprintf(s,"log %s",s2);
01103         break;
01104     case Exp:
01105         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01106         if(g)sprintf(s,"exp(%s)",s2);
01107         else sprintf(s,"exp %s",s2);
01108         break;
01109     case Sin:
01110         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01111         if(g)sprintf(s,"sin(%s)",s2);
01112         else sprintf(s,"sin %s",s2);
01113         break;
01114     case Cos:
01115         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01116         if(g)sprintf(s,"cos(%s)",s2);
01117         else sprintf(s,"cos %s",s2);
01118         break;
01119     case Tg:
01120         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01121         if(g)sprintf(s,"tan(%s)",s2);
01122         else sprintf(s,"tan %s",s2);
01123         break;
01124     case Atan:
01125         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01126         if(g)sprintf(s,"atan(%s)",s2);
01127         else sprintf(s,"atan %s",s2);
01128         break;
01129     case Asin:
01130         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01131         if(g)sprintf(s,"asin(%s)",s2);
01132         else sprintf(s,"asin %s",s2);
01133         break;
01134     case Acos:
01135         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01136         if(g)sprintf(s,"acos(%s)",s2);
01137         else sprintf(s,"acos %s",s2);
01138         break;
01139     case Abs:
01140         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01141         if(g)sprintf(s,"abs(%s)",s2);
01142         else sprintf(s,"abs %s",s2);
01143         break;
01144     case Real:
01145         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01146         if(g)sprintf(s,"real(%s)",s2);
01147         else sprintf(s,"real %s",s2);
01148         break;
01149     case Imag:
01150         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01151         if(g)sprintf(s,"imag(%s)",s2);
01152         else sprintf(s,"imag %s",s2);
01153         break;
01154     case Conj:
01155         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01156         if(g)sprintf(s,"conj(%s)",s2);
01157         else sprintf(s,"conj %s",s2);
01158         break;
01159     case Arg:
01160         g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
01161         if(g)sprintf(s,"arg(%s)",s2);
01162         else sprintf(s,"arg %s",s2);
01163         break;
01164     case Fun:
01165         sprintf(s,"%s(%s)",pfunc->name,s2);
01166         break;
01167     default:return CopyStr("Error");
01168     };
01169     if(s1!=NULL)delete[] s1;if(s2!=NULL)delete[] s2;
01170     return s;
01171 }

Here is the call graph for this function:

Here is the caller graph for this function:

COperation COperation::Substitute ( const CVar var,
const COperation rop 
) const

Definition at line 846 of file mathexpr_c.cpp.

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

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

00847 {
00848     if(!ContainVar(var))return *this;
00849     if(op==Var)return rop;
00850     COperation r;
00851     r.op=op;r.pvar=pvar;r.pvarval=pvarval;r.ValC=ValC;r.pfunc=pfunc;
00852     if(mmb1!=NULL)r.mmb1=new COperation(mmb1->Substitute(var,rop));else r.mmb1=NULL;
00853     if(mmb2!=NULL)r.mmb2=new COperation(mmb2->Substitute(var,rop));else r.mmb2=NULL;
00854     return r;
00855 }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

int operator== ( const COperation op,
const   double 
) [friend]

Definition at line 241 of file mathexpr_c.cpp.

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

int operator== ( const COperation op,
const   double_complex 
) [friend]

Definition at line 244 of file mathexpr_c.cpp.

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

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

Definition at line 247 of file mathexpr_c.cpp.

00248 {if(op1.op!=op2.op)return 0;
00249     if(op1.op==Var)return(*(op1.pvar)==*(op2.pvar));
00250     if(op1.op==Fun)return(op1.pfunc==op2.pfunc); // *op1.pfunc==*op2.pfunc could imply infinite loops in cases of self-dependence
00251     if(op1.op==Num)return(op1.ValC==op2.ValC);
00252     if(op1.mmb1==NULL&&op2.mmb1!=NULL)return 0;
00253     if(op1.mmb2==NULL&&op2.mmb2!=NULL)return 0;
00254     if(op2.mmb1==NULL&&op1.mmb1!=NULL)return 0;
00255     if(op2.mmb2==NULL&&op1.mmb2!=NULL)return 0;
00256     return(((op1.mmb1==NULL&&op2.mmb1==NULL)||(*(op1.mmb1)==*(op2.mmb1)))&&
00257            ((op1.mmb2==NULL&&op2.mmb2==NULL)||(*(op1.mmb2)==*(op2.mmb2))));
00258 }

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

Definition at line 260 of file mathexpr_c.cpp.

00261 {
00262     if(op1.op!=op2.op)return 1;
00263     if(op1.op==Var)return(op1.pvar!=op2.pvar);
00264     if(op1.op==Fun)return(!(op1.pfunc==op2.pfunc)); // *op1.pfunc==*op2.pfunc could imply infinite loops in cases of self-dependence
00265     if(op1.op==Num)return(op1.ValC!=op2.ValC);
00266     if(op1.mmb1==NULL&&op2.mmb1!=NULL)return 1;
00267     if(op1.mmb2==NULL&&op2.mmb2!=NULL)return 1;
00268     if(op2.mmb1==NULL&&op1.mmb1!=NULL)return 1;
00269     if(op2.mmb2==NULL&&op1.mmb2!=NULL)return 1;
00270     return(((op1.mmb1!=NULL||op2.mmb1!=NULL)&&(*(op1.mmb1)!=*(op2.mmb1)))||
00271            ((op1.mmb2!=NULL||op2.mmb2!=NULL)&&(*(op1.mmb2)!=*(op2.mmb2))));
00272 }

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

Definition at line 284 of file mathexpr_c.cpp.

00285 {COperation resultat;
00286     resultat.op=Juxt;resultat.mmb1=new COperation(op1);
00287     resultat.mmb2=new COperation(op2);
00288     return resultat;
00289 }

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

Definition at line 291 of file mathexpr_c.cpp.

00292 {
00293     if(op1.op==Num&&op2.op==Num)return op1.ValC+op2.ValC;
00294     if(op1==0.)return op2;if(op2==0.)return op1;
00295     if(op1.op==Opp)return op2-*(op1.mmb2);if(op2.op==Opp)return op1-*(op2.mmb2);
00296     COperation resultat;
00297     resultat.op=Add;resultat.mmb1=new COperation(op1);
00298     resultat.mmb2=new COperation(op2);
00299     return resultat;
00300 }

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

Definition at line 302 of file mathexpr_c.cpp.

00303 {
00304     if(op1.op==Num&&op2.op==Num)return op1.ValC-op2.ValC;
00305     if(op1==0.)return -op2;if(op2==0.)return op1;
00306     if(op1.op==Opp)return -(op2+*(op1.mmb2));if(op2.op==Opp)return op1+*(op2.mmb2);
00307     COperation resultat;
00308     resultat.op=Sub;resultat.mmb1=new COperation(op1);
00309     resultat.mmb2=new COperation(op2);
00310     return resultat;
00311 }

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

Definition at line 313 of file mathexpr_c.cpp.

00314 {
00315     if(op1.op==Num&&op2.op==Num)return op1.ValC*op2.ValC;
00316     if(op1==0.||op2==0.)return 0.;
00317     if(op1==1.)return op2;if(op2==1.)return op1;
00318     if(op1.op==Opp)return -(*(op1.mmb2)*op2);if(op2.op==Opp)return -(op1**(op2.mmb2));
00319     COperation resultat;
00320     resultat.op=Mult;resultat.mmb1=new COperation(op1);
00321     resultat.mmb2=new COperation(op2);
00322     return resultat;
00323 }

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

Definition at line 325 of file mathexpr_c.cpp.

00326 {if(op1.op==Num&&op2.op==Num)return (op2.ValC!=double_complex(0,0)?op1.ValC/op2.ValC:ErrVal);
00327     if(op1==0.0)return 0.;if(op2==1.)return op1;if(op2==0.)return ErrVal;
00328     if(op1.op==Opp)return -(*(op1.mmb2)/op2);if(op2.op==Opp)return -(op1/(*(op2.mmb2)));
00329     COperation resultat;
00330     resultat.op=Div;resultat.mmb1=new COperation(op1);
00331     resultat.mmb2=new COperation(op2);
00332     return resultat;
00333 }

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

Definition at line 335 of file mathexpr_c.cpp.

00336 {if(op1==0.)return 0.;
00337     if(op2==0.)return 1.;
00338     if(op2==1.)return op1;
00339     COperation resultat;
00340     resultat.op=Pow;resultat.mmb1=new COperation(op1);
00341     resultat.mmb2=new COperation(op2);
00342     return resultat;
00343 }

COperation real ( const COperation op  )  [friend]

Definition at line 345 of file mathexpr_c.cpp.

Referenced by PrettyPrint(), real(), and Reelle().

00346 {
00347     if(op.op==Num)return real(op.ValC);
00348     COperation rop;rop.op=Real;rop.mmb2=new COperation(op);return rop;
00349 }

COperation imag ( const COperation op  )  [friend]

Definition at line 350 of file mathexpr_c.cpp.

Referenced by imag(), Imaginaire(), and PrettyPrint().

00351 {
00352     if(op.op==Num)return imag(op.ValC);
00353     COperation rop;rop.op=Imag;rop.mmb2=new COperation(op);return rop;
00354 }

COperation conj ( const COperation op  )  [friend]

Definition at line 355 of file mathexpr_c.cpp.

Referenced by conj(), Conjugue(), Diff(), and DiffConj().

00356 {
00357     if(op.op==Num)return conj(op.ValC);
00358     COperation rop;rop.op=Conj;rop.mmb2=new COperation(op);return rop;
00359 }

COperation arg ( const COperation op  )  [friend]

Definition at line 360 of file mathexpr_c.cpp.

Referenced by Argument().

00361 {COperation rop;rop.op=Arg;rop.mmb2=new COperation(op);return rop;}

COperation sqrt ( const COperation op  )  [friend]

Definition at line 362 of file mathexpr_c.cpp.

Referenced by Diff(), DiffConj(), and Racine().

00363 {COperation rop;rop.op=Sqrt;rop.mmb2=new COperation(op);return rop;}

COperation abs ( const COperation op  )  [friend]

Definition at line 364 of file mathexpr_c.cpp.

Referenced by Diff(), and DiffConj().

00365 {COperation rop;rop.op=Abs;rop.mmb2=new COperation(op);return rop;}

COperation sin ( const COperation op  )  [friend]

Definition at line 366 of file mathexpr_c.cpp.

Referenced by Diff(), DiffConj(), and Sinus().

00367 {COperation rop;rop.op=Sin;rop.mmb2=new COperation(op);return rop;}

COperation cos ( const COperation op  )  [friend]

Definition at line 368 of file mathexpr_c.cpp.

Referenced by Cosinus(), Diff(), and DiffConj().

00369 {COperation rop;rop.op=Cos;rop.mmb2=new COperation(op);return rop;}

COperation tan ( const COperation op  )  [friend]

Definition at line 370 of file mathexpr_c.cpp.

Referenced by Tangente().

00371 {COperation rop;rop.op=Tg;rop.mmb2=new COperation(op);return rop;}

COperation log ( const COperation op  )  [friend]

Definition at line 372 of file mathexpr_c.cpp.

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

00373 {COperation rop;rop.op=Ln;rop.mmb2=new COperation(op);return rop;}

COperation exp ( const COperation op  )  [friend]

Definition at line 374 of file mathexpr_c.cpp.

Referenced by Exponentielle().

00375 {COperation rop;rop.op=Exp;rop.mmb2=new COperation(op);return rop;}

COperation acos ( const COperation op  )  [friend]

Definition at line 376 of file mathexpr_c.cpp.

Referenced by ArcCosinus().

00377 {COperation rop;rop.op=Acos;rop.mmb2=new COperation(op);return rop;}

COperation asin ( const COperation op  )  [friend]

Definition at line 378 of file mathexpr_c.cpp.

Referenced by ArcSinus().

00379 {COperation rop;rop.op=Asin;rop.mmb2=new COperation(op);return rop;}

COperation atan ( const COperation op  )  [friend]

Definition at line 380 of file mathexpr_c.cpp.

Referenced by ArcTangente().

00381 {COperation rop;rop.op=Atan;rop.mmb2=new COperation(op);return rop;}

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

Definition at line 383 of file mathexpr_c.cpp.

Referenced by ApplyOperator(), Diff(), and DiffConj().

00384 {
00385     if(n<=0)return ErrVal;
00386     if(n==1)return *pops[0];
00387     if(n==2)return (*func)(*pops[0],*pops[1]);
00388     return (*func)(*pops[0],ApplyOperator(n-1,pops+1,func));
00389 }


Member Data Documentation

pfoncld* COperation::pinstr [private]

Definition at line 83 of file mathexpr_c.h.

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

double_complex** COperation::pvals [private]

Definition at line 83 of file mathexpr_c.h.

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

double_complex* COperation::ppile [private]

Definition at line 83 of file mathexpr_c.h.

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

CFunction** COperation::pfuncpile [private]

Definition at line 83 of file mathexpr_c.h.

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

signed char COperation::containfuncflag [mutable, private]

Definition at line 84 of file mathexpr_c.h.

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

COperator COperation::op

Definition at line 88 of file mathexpr_c.h.

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

PCOperation COperation::mmb1

Definition at line 89 of file mathexpr_c.h.

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

PCOperation COperation::mmb2

Definition at line 89 of file mathexpr_c.h.

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

double_complex COperation::ValC

Definition at line 90 of file mathexpr_c.h.

Referenced by BuildCode(), conj(), COperation(), Expr(), imag(), operator *(), operator!=(), operator+(), operator-(), operator-(), operator/(), operator=(), operator==(), real(), and Substitute().

const CVar* COperation::pvar

Definition at line 90 of file mathexpr_c.h.

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

double_complex* COperation::pvarval

Definition at line 90 of file mathexpr_c.h.

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

CFunction* COperation::pfunc

Definition at line 91 of file mathexpr_c.h.

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


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