stats: adds a Formula operator for division
authorNilay Vaish <nilay@cs.wisc.edu>
Fri, 6 Sep 2013 21:21:29 +0000 (16:21 -0500)
committerNilay Vaish <nilay@cs.wisc.edu>
Fri, 6 Sep 2013 21:21:29 +0000 (16:21 -0500)
src/base/statistics.cc
src/base/statistics.hh

index 630205a5913fb17e6ca3ae2e0a10a0941e7ce518..0b44a4ec73fc6983c7f22c648b983196ac73bc7f 100644 (file)
@@ -387,6 +387,16 @@ Formula::operator+=(Temp r)
     return *this;
 }
 
+const Formula &
+Formula::operator/=(Temp r)
+{
+    assert (root);
+    root = NodePtr(new BinaryNode<std::divides<Result> >(root, r));
+
+    assert(size());
+    return *this;
+}
+
 void
 Formula::result(VResult &vec) const
 {
index 3c1a556234604e13c5caf8b55b7a96033f0a5688..f3b6ae39fb0597e88182696789a422dae624a79a 100644 (file)
@@ -2856,6 +2856,14 @@ class Formula : public DataWrapVec<Formula, FormulaInfoProxy>
      * @return a reference to this formula.
      */
     const Formula &operator+=(Temp r);
+
+    /**
+     * Divide the existing tree by the given one.
+     * @param r The root of the expression tree.
+     * @return a reference to this formula.
+     */
+    const Formula &operator/=(Temp r);
+
     /**
      * Return the result of the Fomula in a vector.  If there were no Vector
      * components to the Formula, then the vector is size 1.  If there were,