X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Foperators.cpp;h=ee240174f6ad0f5cac9a5daee41d69316e0ecb29;hb=d508ca04e9c2f4ee103c9f21f33a98c87116df13;hp=506f47b7a77e9d9b9072c4fca09e1e4683908f4f;hpb=703c6cebb5d3d395437e73e6935f3691aed68e0a;p=ginac.git diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 506f47b7..ee240174 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's overloaded operators. */ /* - * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,21 +20,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include - #include "operators.h" -#include "basic.h" -#include "ex.h" #include "numeric.h" #include "power.h" #include "relational.h" +#include "print.h" #include "debugmsg.h" #include "utils.h" -#ifndef NO_NAMESPACE_GINAC namespace GiNaC { -#endif // ndef NO_NAMESPACE_GINAC // binary arithmetic operators ex with ex @@ -62,12 +56,6 @@ ex operator/(const ex & lh, const ex & rh) return lh.exmul(power(rh,_ex_1())); } -ex operator%(const ex & lh, const ex & rh) -{ - debugmsg("operator%(ex,ex)",LOGLEVEL_OPERATOR); - return lh.exncmul(rh); -} - // binary arithmetic operators numeric with numeric @@ -101,31 +89,25 @@ numeric operator/(const numeric & lh, const numeric & rh) const ex & operator+=(ex & lh, const ex & rh) { debugmsg("operator+=(ex,ex)",LOGLEVEL_OPERATOR); - return (lh=lh+rh); + return (lh=lh.exadd(rh)); } const ex & operator-=(ex & lh, const ex & rh) { debugmsg("operator-=(ex,ex)",LOGLEVEL_OPERATOR); - return (lh=lh-rh); + return (lh=lh.exadd(rh.exmul(_ex_1()))); } const ex & operator*=(ex & lh, const ex & rh) { debugmsg("operator*=(ex,ex)",LOGLEVEL_OPERATOR); - return (lh=lh*rh); + return (lh=lh.exmul(rh)); } const ex & operator/=(ex & lh, const ex & rh) { debugmsg("operator/=(ex,ex)",LOGLEVEL_OPERATOR); - return (lh=lh/rh); -} - -const ex & operator%=(ex & lh, const ex & rh) -{ - debugmsg("operator%=(ex,ex)",LOGLEVEL_OPERATOR); - return (lh=lh%rh); + return (lh=lh.exmul(power(rh,_ex_1()))); } @@ -178,14 +160,14 @@ numeric operator+(const numeric & lh) numeric operator-(const numeric & lh) { debugmsg("operator-(numeric)",LOGLEVEL_OPERATOR); - return _num_1()*lh; + return _num_1().mul(lh); } /** Numeric prefix increment. Adds 1 and returns incremented number. */ numeric& operator++(numeric & rh) { debugmsg("operator++(numeric)",LOGLEVEL_OPERATOR); - rh = rh+_num1(); + rh = rh.add(_num1()); return rh; } @@ -193,7 +175,7 @@ numeric& operator++(numeric & rh) numeric& operator--(numeric & rh) { debugmsg("operator--(numeric)",LOGLEVEL_OPERATOR); - rh = rh-_num1(); + rh = rh.add(_num_1()); return rh; } @@ -202,8 +184,8 @@ numeric& operator--(numeric & rh) numeric operator++(numeric & lh, int) { debugmsg("operator++(numeric,int)",LOGLEVEL_OPERATOR); - numeric tmp = lh; - lh = lh+_num1(); + numeric tmp(lh); + lh = lh.add(_num1()); return tmp; } @@ -212,8 +194,8 @@ numeric operator++(numeric & lh, int) numeric operator--(numeric & lh, int) { debugmsg("operator--(numeric,int)",LOGLEVEL_OPERATOR); - numeric tmp = lh; - lh = lh-_num1(); + numeric tmp(lh); + lh = lh.add(_num_1()); return tmp; } @@ -259,7 +241,7 @@ relational operator>=(const ex & lh, const ex & rh) std::ostream & operator<<(std::ostream & os, const ex & e) { - e.print(os); + e.print(print_context(os)); return os; } @@ -268,6 +250,4 @@ std::istream & operator>>(std::istream & is, ex & e) throw (std::logic_error("expression input from streams not implemented")); } -#ifndef NO_NAMESPACE_GINAC } // namespace GiNaC -#endif // ndef NO_NAMESPACE_GINAC