]> www.ginac.de Git - ginac.git/blobdiff - ginac/operators.cpp
fixed a bug where quo() would call vector::reserve() with a negative argument
[ginac.git] / ginac / operators.cpp
index 31c4cf03c3994f39a83b0bb4ffec8197083cf193..e95803a5ef8895dc734815baee08d9523926d592 100644 (file)
@@ -28,7 +28,6 @@
 #include "ncmul.h"
 #include "relational.h"
 #include "print.h"
-#include "debugmsg.h"
 #include "utils.h"
 
 namespace GiNaC {
@@ -55,33 +54,29 @@ static inline const ex exmul(const ex & lh, const ex & rh)
 /** Used internally by operator-() and friends to change the sign of an argument. */
 static inline const ex exminus(const ex & lh)
 {
-       return (new mul(lh,_ex_1()))->setflag(status_flags::dynallocated);
+       return (new mul(lh,_ex_1))->setflag(status_flags::dynallocated);
 }
 
 // binary arithmetic operators ex with ex
 
 const ex operator+(const ex & lh, const ex & rh)
 {
-       debugmsg("operator+(ex,ex)",LOGLEVEL_OPERATOR);
        return exadd(lh, rh);
 }
 
 const ex operator-(const ex & lh, const ex & rh)
 {
-       debugmsg("operator-(ex,ex)",LOGLEVEL_OPERATOR);
        return exadd(lh, exminus(rh));
 }
 
 const ex operator*(const ex & lh, const ex & rh)
 {
-       debugmsg("operator*(ex,ex)",LOGLEVEL_OPERATOR);
        return exmul(lh, rh);
 }
 
 const ex operator/(const ex & lh, const ex & rh)
 {
-       debugmsg("operator/(ex,ex)",LOGLEVEL_OPERATOR);
-       return exmul(lh, power(rh,_ex_1()));
+       return exmul(lh, power(rh,_ex_1));
 }
 
 
@@ -89,25 +84,21 @@ const ex operator/(const ex & lh, const ex & rh)
 
 const numeric operator+(const numeric & lh, const numeric & rh)
 {
-       debugmsg("operator+(numeric,numeric)",LOGLEVEL_OPERATOR);
        return lh.add(rh);
 }
 
 const numeric operator-(const numeric & lh, const numeric & rh)
 {
-       debugmsg("operator-(numeric,numeric)",LOGLEVEL_OPERATOR);
        return lh.sub(rh);
 }
 
 const numeric operator*(const numeric & lh, const numeric & rh)
 {
-       debugmsg("operator*(numeric,numeric)",LOGLEVEL_OPERATOR);
        return lh.mul(rh);
 }
 
 const numeric operator/(const numeric & lh, const numeric & rh)
 {
-       debugmsg("operator/(numeric,ex)",LOGLEVEL_OPERATOR);
        return lh.div(rh);
 }
 
@@ -116,26 +107,22 @@ const numeric operator/(const numeric & lh, const numeric & rh)
 
 ex & operator+=(ex & lh, const ex & rh)
 {
-       debugmsg("operator+=(ex,ex)",LOGLEVEL_OPERATOR);
        return lh = exadd(lh, rh);
 }
 
 ex & operator-=(ex & lh, const ex & rh)
 {
-       debugmsg("operator-=(ex,ex)",LOGLEVEL_OPERATOR);
        return lh = exadd(lh, exminus(rh));
 }
 
 ex & operator*=(ex & lh, const ex & rh)
 {
-       debugmsg("operator*=(ex,ex)",LOGLEVEL_OPERATOR);
        return lh = exmul(lh, rh);
 }
 
 ex & operator/=(ex & lh, const ex & rh)
 {
-       debugmsg("operator/=(ex,ex)",LOGLEVEL_OPERATOR);
-       return lh = exmul(lh, power(rh,_ex_1()));
+       return lh = exmul(lh, power(rh,_ex_1));
 }
 
 
@@ -143,28 +130,24 @@ ex & operator/=(ex & lh, const ex & rh)
 
 numeric & operator+=(numeric & lh, const numeric & rh)
 {
-       debugmsg("operator+=(numeric,numeric)",LOGLEVEL_OPERATOR);
        lh = lh.add(rh);
        return lh;
 }
 
 numeric & operator-=(numeric & lh, const numeric & rh)
 {
-       debugmsg("operator-=(numeric,numeric)",LOGLEVEL_OPERATOR);
        lh = lh.sub(rh);
        return lh;
 }
 
 numeric & operator*=(numeric & lh, const numeric & rh)
 {
-       debugmsg("operator*=(numeric,numeric)",LOGLEVEL_OPERATOR);
        lh = lh.mul(rh);
        return lh;
 }
 
 numeric & operator/=(numeric & lh, const numeric & rh)
 {
-       debugmsg("operator/=(numeric,numeric)",LOGLEVEL_OPERATOR);
        lh = lh.div(rh);
        return lh;
 }
@@ -174,26 +157,22 @@ numeric & operator/=(numeric & lh, const numeric & rh)
 
 const ex operator+(const ex & lh)
 {
-       debugmsg("operator+(ex)",LOGLEVEL_OPERATOR);
        return lh;
 }
 
 const ex operator-(const ex & lh)
 {
-       debugmsg("operator-(ex)",LOGLEVEL_OPERATOR);
        return exminus(lh);
 }
 
 const numeric operator+(const numeric & lh)
 {
-       debugmsg("operator+(numeric)",LOGLEVEL_OPERATOR);
        return lh;
 }
 
 const numeric operator-(const numeric & lh)
 {
-       debugmsg("operator-(numeric)",LOGLEVEL_OPERATOR);
-       return _num_1().mul(lh);
+       return _num_1.mul(lh);
 }
 
 
@@ -202,24 +181,21 @@ const numeric operator-(const numeric & lh)
 /** Expression prefix increment.  Adds 1 and returns incremented ex. */
 ex & operator++(ex & rh)
 {
-       debugmsg("operator++(ex)",LOGLEVEL_OPERATOR);
-       return rh = exadd(rh, _ex1());
+       return rh = exadd(rh, _ex1);
 }
 
 /** Expression prefix decrement.  Subtracts 1 and returns decremented ex. */
 ex & operator--(ex & rh)
 {
-       debugmsg("operator--(ex)",LOGLEVEL_OPERATOR);
-       return rh = exadd(rh, _ex_1());
+       return rh = exadd(rh, _ex_1);
 }
 
 /** Expression postfix increment.  Returns the ex and leaves the original
  *  incremented by 1. */
 const ex operator++(ex & lh, int)
 {
-       debugmsg("operator++(ex,int)",LOGLEVEL_OPERATOR);
        ex tmp(lh);
-       lh = exadd(lh, _ex1());
+       lh = exadd(lh, _ex1);
        return tmp;
 }
 
@@ -227,25 +203,22 @@ const ex operator++(ex & lh, int)
  *  decremented by 1. */
 const ex operator--(ex & lh, int)
 {
-       debugmsg("operator--(ex,int)",LOGLEVEL_OPERATOR);
        ex tmp(lh);
-       lh = exadd(lh, _ex_1());
+       lh = exadd(lh, _ex_1);
        return tmp;
 }
 
 /** Numeric prefix increment.  Adds 1 and returns incremented number. */
 numeric& operator++(numeric & rh)
 {
-       debugmsg("operator++(numeric)",LOGLEVEL_OPERATOR);
-       rh = rh.add(_num1());
+       rh = rh.add(_num1);
        return rh;
 }
 
 /** Numeric prefix decrement.  Subtracts 1 and returns decremented number. */
 numeric& operator--(numeric & rh)
 {
-       debugmsg("operator--(numeric)",LOGLEVEL_OPERATOR);
-       rh = rh.add(_num_1());
+       rh = rh.add(_num_1);
        return rh;
 }
 
@@ -253,9 +226,8 @@ numeric& operator--(numeric & rh)
  *  incremented by 1. */
 const numeric operator++(numeric & lh, int)
 {
-       debugmsg("operator++(numeric,int)",LOGLEVEL_OPERATOR);
        numeric tmp(lh);
-       lh = lh.add(_num1());
+       lh = lh.add(_num1);
        return tmp;
 }
 
@@ -263,9 +235,8 @@ const numeric operator++(numeric & lh, int)
  *  decremented by 1. */
 const numeric operator--(numeric & lh, int)
 {
-       debugmsg("operator--(numeric,int)",LOGLEVEL_OPERATOR);
        numeric tmp(lh);
-       lh = lh.add(_num_1());
+       lh = lh.add(_num_1);
        return tmp;
 }
 
@@ -273,37 +244,31 @@ const numeric operator--(numeric & lh, int)
 
 const relational operator==(const ex & lh, const ex & rh)
 {
-       debugmsg("operator==(ex,ex)",LOGLEVEL_OPERATOR);
        return relational(lh,rh,relational::equal);
 }
 
 const relational operator!=(const ex & lh, const ex & rh)
 {
-       debugmsg("operator!=(ex,ex)",LOGLEVEL_OPERATOR);
        return relational(lh,rh,relational::not_equal);
 }
 
 const relational operator<(const ex & lh, const ex & rh)
 {
-       debugmsg("operator<(ex,ex)",LOGLEVEL_OPERATOR);
        return relational(lh,rh,relational::less);
 }
 
 const relational operator<=(const ex & lh, const ex & rh)
 {
-       debugmsg("operator<=(ex,ex)",LOGLEVEL_OPERATOR);
        return relational(lh,rh,relational::less_or_equal);
 }
 
 const relational operator>(const ex & lh, const ex & rh)
 {
-       debugmsg("operator>(ex,ex)",LOGLEVEL_OPERATOR);
        return relational(lh,rh,relational::greater);
 }
 
 const relational operator>=(const ex & lh, const ex & rh)
 {
-       debugmsg("operator>=(ex,ex)",LOGLEVEL_OPERATOR);
        return relational(lh,rh,relational::greater_or_equal);
 }