1 /** @file collect_vargs.h
3 * Interface to utility functions. */
6 * GiNaC Copyright (C) 1999-2022 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef GINAC_COLLECT_VARGS_H
24 #define GINAC_COLLECT_VARGS_H
28 #include <cln/integer.h>
29 #include <utility> // for std::pair
31 #include <algorithm> // std::lexicographical_compare
35 typedef std::vector<int> exp_vector_t;
37 static inline bool operator<(const exp_vector_t& v1, const exp_vector_t& v2)
39 return std::lexicographical_compare(v1.rbegin(), v1.rend(),
40 v2.rbegin(), v2.rend());
43 static inline bool operator>(const exp_vector_t& v1, const exp_vector_t& v2)
50 static inline bool zerop(const exp_vector_t& v)
59 typedef std::vector<std::pair<exp_vector_t, ex>> ex_collect_t;
62 collect_vargs(ex_collect_t& ec, const ex& e, const exvector& x);
64 ex_collect_to_ex(const ex_collect_t& ec, const exvector& x);
67 * Leading coefficient of a multivariate polynomial e, considering it
68 * as a multivariate polynomial in x_0, \ldots x_{n-1} with coefficients
69 * being univariate polynomials in R[x_n] (where R is some ring)
71 extern ex lcoeff_wrt(ex e, const exvector& x);
75 * Degree vector of a leading term of a multivariate polynomial.
76 * (generalization of degree(expr, var))
78 extern exp_vector_t degree_vector(ex e, const exvector& vars);
81 * Leading coefficient c \in R (where R = Z or Z_p) of a multivariate
82 * polynomial e \in R[x_0, \ldots, x_n]
84 extern cln::cl_I integer_lcoeff(const ex& e, const exvector& vars);
88 #endif // ndef GINAC_COLLECT_VARGS_H