]> www.ginac.de Git - ginac.git/blobdiff - ginac/operators.cpp
#ifndef around namespace GiNaC { }
[ginac.git] / ginac / operators.cpp
index b589c3c450b00d1dfb3d504f7866ce19e425082e..c21e0ea62a572c27dd56b735a18054bb026271b1 100644 (file)
@@ -1,7 +1,8 @@
 /** @file operators.cpp
  *
- *  Implementation of GiNaC's overloaded operators.
- *
+ *  Implementation of GiNaC's overloaded operators. */
+
+/*
  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
 #include <iostream>
 #include <stdexcept>
 
-#include "ginac.h"
+#include "operators.h"
+#include "basic.h"
+#include "ex.h"
+#include "numeric.h"
+#include "power.h"
+#include "relational.h"
+#include "debugmsg.h"
+
+#ifndef NO_GINAC_NAMESPACE
+namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
 
 // binary arithmetic operators ex with ex
 
@@ -263,7 +274,39 @@ numeric operator+(numeric const & lh)
 
 numeric operator-(numeric const & lh)
 {
-    return (numeric(-1)*lh);
+    return numMINUSONE()*lh;
+}
+
+/** Numeric prefix increment.  Adds 1 and returns incremented number. */
+numeric& operator++(numeric & rh)
+{
+    rh = rh+numONE();
+    return rh;
+}
+
+/** Numeric prefix decrement.  Subtracts 1 and returns decremented number. */
+numeric& operator--(numeric & rh)
+{
+    rh = rh-numONE();
+    return rh;
+}
+
+/** Numeric postfix increment.  Returns the number and leaves the original
+ *  incremented by 1. */
+numeric operator++(numeric & lh, int)
+{
+    numeric tmp = lh;
+    lh = lh+numONE();
+    return tmp;
+}
+
+/** Numeric Postfix decrement.  Returns the number and leaves the original
+ *  decremented by 1. */
+numeric operator--(numeric & lh, int)
+{
+    numeric tmp = lh;
+    lh = lh-numONE();
+    return tmp;
 }
 
 // binary relational operators ex with ex
@@ -397,3 +440,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