X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Foperators.cpp;h=0fc42e78a6393b04a0d00ad64f67d942c971d728;hp=4d762b305c2424ccb623ad5a6e11a61bfa65681e;hb=d40e9201f3373ca3f5e97fb4d4480826b9f854ab;hpb=48b41ea321ed9fa6115a1061d1a1d2f8d8ad0400 diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 4d762b30..0fc42e78 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -30,8 +30,11 @@ #include "power.h" #include "relational.h" #include "debugmsg.h" +#include "utils.h" +#ifndef NO_GINAC_NAMESPACE namespace GiNaC { +#endif // ndef NO_GINAC_NAMESPACE // binary arithmetic operators ex with ex @@ -44,7 +47,7 @@ ex operator+(ex const & lh, ex const & rh) ex operator-(ex const & lh, ex const & rh) { debugmsg("operator-(ex,ex)",LOGLEVEL_OPERATOR); - return lh.exadd(rh.exmul(exMINUSONE())); + return lh.exadd(rh.exmul(_ex_1())); } ex operator*(ex const & lh, ex const & rh) @@ -56,7 +59,7 @@ ex operator*(ex const & lh, ex const & rh) ex operator/(ex const & lh, ex const & rh) { debugmsg("operator*(ex,ex)",LOGLEVEL_OPERATOR); - return lh.exmul(power(rh,exMINUSONE())); + return lh.exmul(power(rh,_ex_1())); } ex operator%(ex const & lh, ex const & rh) @@ -65,73 +68,6 @@ ex operator%(ex const & lh, ex const & rh) return lh.exncmul(rh); } -/* - -// binary arithmetic operators ex with numeric - -ex operator+(ex const & lh, numeric const & rh) -{ - debugmsg("operator+(ex,numeric)",LOGLEVEL_OPERATOR); - return lh+ex(rh); -} - -ex operator-(ex const & lh, numeric const & rh) -{ - debugmsg("operator-(ex,numeric)",LOGLEVEL_OPERATOR); - return lh-ex(rh); -} - -ex operator*(ex const & lh, numeric const & rh) -{ - debugmsg("operator*(ex,numeric)",LOGLEVEL_OPERATOR); - return lh*ex(rh); -} - -ex operator/(ex const & lh, numeric const & rh) -{ - debugmsg("operator/(ex,numeric)",LOGLEVEL_OPERATOR); - return lh/ex(rh); -} - -ex operator%(ex const & lh, numeric const & rh) -{ - debugmsg("operator%(ex,numeric)",LOGLEVEL_OPERATOR); - return lh%ex(rh); -} - -// binary arithmetic operators numeric with ex - -ex operator+(numeric const & lh, ex const & rh) -{ - debugmsg("operator+(numeric,ex)",LOGLEVEL_OPERATOR); - return ex(lh)+rh; -} - -ex operator-(numeric const & lh, ex const & rh) -{ - debugmsg("operator-(numeric,ex)",LOGLEVEL_OPERATOR); - return ex(lh)-rh; -} - -ex operator*(numeric const & lh, ex const & rh) -{ - debugmsg("operator*(numeric,ex)",LOGLEVEL_OPERATOR); - return ex(lh)*rh; -} - -ex operator/(numeric const & lh, ex const & rh) -{ - debugmsg("operator/(numeric,ex)",LOGLEVEL_OPERATOR); - return ex(lh)/rh; -} - -ex operator%(numeric const & lh, ex const & rh) -{ - debugmsg("operator%(numeric,ex)",LOGLEVEL_OPERATOR); - return ex(lh)%rh; -} - -*/ // binary arithmetic operators numeric with numeric @@ -159,6 +95,7 @@ numeric operator/(numeric const & lh, numeric const & rh) return lh.div(rh); } + // binary arithmetic assignment operators with ex ex const & operator+=(ex & lh, ex const & rh) @@ -191,41 +128,6 @@ ex const & operator%=(ex & lh, ex const & rh) return (lh=lh%rh); } -/* - -// binary arithmetic assignment operators with numeric - -ex const & operator+=(ex & lh, numeric const & rh) -{ - debugmsg("operator+=(ex,numeric)",LOGLEVEL_OPERATOR); - return (lh=lh+ex(rh)); -} - -ex const & operator-=(ex & lh, numeric const & rh) -{ - debugmsg("operator-=(ex,numeric)",LOGLEVEL_OPERATOR); - return (lh=lh-ex(rh)); -} - -ex const & operator*=(ex & lh, numeric const & rh) -{ - debugmsg("operator*=(ex,numeric)",LOGLEVEL_OPERATOR); - return (lh=lh*ex(rh)); -} - -ex const & operator/=(ex & lh, numeric const & rh) -{ - debugmsg("operator/=(ex,numeric)",LOGLEVEL_OPERATOR); - return (lh=lh/ex(rh)); -} - -ex const & operator%=(ex & lh, numeric const & rh) -{ - debugmsg("operator%=(ex,numeric)",LOGLEVEL_OPERATOR); - return (lh=lh%ex(rh)); -} - -*/ // binary arithmetic assignment operators with numeric @@ -262,7 +164,7 @@ ex operator+(ex const & lh) ex operator-(ex const & lh) { - return exMINUSONE()*lh; + return lh.exmul(_ex_1()); } numeric operator+(numeric const & lh) @@ -272,20 +174,20 @@ numeric operator+(numeric const & lh) numeric operator-(numeric const & lh) { - return numMINUSONE()*lh; + return _num_1()*lh; } /** Numeric prefix increment. Adds 1 and returns incremented number. */ numeric& operator++(numeric & rh) { - rh = rh+numONE(); + rh = rh+_num1(); return rh; } /** Numeric prefix decrement. Subtracts 1 and returns decremented number. */ numeric& operator--(numeric & rh) { - rh = rh-numONE(); + rh = rh-_num1(); return rh; } @@ -294,7 +196,7 @@ numeric& operator--(numeric & rh) numeric operator++(numeric & lh, int) { numeric tmp = lh; - lh = lh+numONE(); + lh = lh+_num1(); return tmp; } @@ -303,7 +205,7 @@ numeric operator++(numeric & lh, int) numeric operator--(numeric & lh, int) { numeric tmp = lh; - lh = lh-numONE(); + lh = lh-_num1(); return tmp; } @@ -438,4 +340,6 @@ istream & operator>>(istream & is, ex & e) throw(std::logic_error("input from streams not yet implemented")); } +#ifndef NO_GINAC_NAMESPACE } // namespace GiNaC +#endif // ndef NO_GINAC_NAMESPACE