]> www.ginac.de Git - ginac.git/blobdiff - ginac/polynomial/collect_vargs.cpp
Update copyright statements.
[ginac.git] / ginac / polynomial / collect_vargs.cpp
index 259326873bf1da4fd6866a8d2267ec0a13665264..083dfdbb5c374cb39944b49ec1cdf0d8a0ba8867 100644 (file)
@@ -3,7 +3,7 @@
  *  Utility functions. */
 
 /*
- *  GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2014 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
@@ -69,7 +69,7 @@ struct compare_terms
 };
 
 template<typename T, typename CoeffCMP>
-static struct compare_terms<T, CoeffCMP>
+static compare_terms<T, CoeffCMP>
 make_compare_terms(const T& dummy, const CoeffCMP& coeff_cmp)
 {
        return compare_terms<T, CoeffCMP>(coeff_cmp);
@@ -177,6 +177,18 @@ ex lcoeff_wrt(ex e, const exvector& x)
        return ec.rbegin()->second;
 }
 
+exp_vector_t degree_vector(ex e, const exvector& vars)
+{
+       e = e.expand();
+       exp_vector_t dvec(vars.size());
+       for (std::size_t i = vars.size(); i-- != 0; ) {
+               const int deg_i = e.degree(vars[i]);
+               e = e.coeff(vars[i], deg_i);
+               dvec[i] = deg_i;
+       }
+       return dvec;
+}
+
 cln::cl_I integer_lcoeff(const ex& e, const exvector& vars)
 {
        ex_collect_t ec;