]> www.ginac.de Git - ginac.git/blobdiff - ginac/add.cpp
Remove info_flags::algebraic.
[ginac.git] / ginac / add.cpp
index ed58730941a3c9d062475ef175b44c023010187d..7f7818bc1c8f33dd86ce2970f1e38b8bc59c29a3 100644 (file)
@@ -86,6 +86,13 @@ add::add(const epvector & v, const ex & oc)
        GINAC_ASSERT(is_canonical());
 }
 
+add::add(epvector && vp)
+{
+       overall_coeff = _ex0;
+       construct_from_epvector(std::move(vp));
+       GINAC_ASSERT(is_canonical());
+}
+
 add::add(epvector && vp, const ex & oc)
 {
        overall_coeff = oc;
@@ -240,15 +247,6 @@ bool add::info(unsigned inf) const
                                return true;
                        return overall_coeff.info(inf);
                }
-               case info_flags::algebraic: {
-                       epvector::const_iterator i = seq.begin(), end = seq.end();
-                       while (i != end) {
-                               if ((recombine_pair_to_ex(*i).info(inf)))
-                                       return true;
-                               ++i;
-                       }
-                       return false;
-               }
        }
        return inherited::info(inf);
 }
@@ -326,17 +324,16 @@ ex add::coeff(const ex & s, int n) const
  *  an expression that contain a plain number.
  *  - +(;c) -> c
  *  - +(x;0) -> x
- *
- *  @param level cut-off in recursive evaluation */
-ex add::eval(int level) const
+ */
+ex add::eval() const
 {
-       if ((level == 1) && (flags & status_flags::evaluated)) {
+       if (flags & status_flags::evaluated) {
                GINAC_ASSERT(seq.size()>0);
                GINAC_ASSERT(seq.size()>1 || !overall_coeff.is_zero());
                return *this;
        }
 
-       const epvector evaled = evalchildren(level);
+       const epvector evaled = evalchildren();
        if (unlikely(!evaled.empty())) {
                // start over evaluating a new object
                return dynallocate<add>(std::move(evaled), overall_coeff);
@@ -348,7 +345,7 @@ ex add::eval(int level) const
        }
 #endif // def DO_GINAC_ASSERT
 
-       int seq_size = seq.size();
+       size_t seq_size = seq.size();
        if (seq_size == 0) {
                // +(;c) -> c
                return overall_coeff;
@@ -358,27 +355,7 @@ ex add::eval(int level) const
        } else if (!overall_coeff.is_zero() && seq[0].rest.return_type() != return_types::commutative) {
                throw (std::logic_error("add::eval(): sum of non-commutative objects has non-zero numeric term"));
        }
-       
-       // if any terms in the sum still are purely numeric, then they are more
-       // appropriately collected into the overall coefficient
-       int terms_to_collect = 0;
-       for (auto & it : seq) {
-               if (unlikely(is_a<numeric>(it.rest)))
-                       ++terms_to_collect;
-       }
-       if (terms_to_collect) {
-               epvector s;
-               s.reserve(seq_size - terms_to_collect);
-               numeric oc = *_num1_p;
-               for (auto & it : seq) {
-                       if (unlikely(is_a<numeric>(it.rest)))
-                               oc = oc.mul(ex_to<numeric>(it.rest)).mul(ex_to<numeric>(it.coeff));
-                       else
-                               s.push_back(it);
-               }
-               return dynallocate<add>(std::move(s), ex_to<numeric>(overall_coeff).add_dyn(oc));
-       }
-       
+
        return this->hold();
 }
 
@@ -493,7 +470,7 @@ ex add::derivative(const symbol & y) const
        for (auto & it : seq)
                s.push_back(expair(it.rest.diff(y), it.coeff));
 
-       return dynallocate<add>(std::move(s), _ex0);
+       return dynallocate<add>(std::move(s));
 }
 
 int add::compare_same_type(const basic & other) const