Christian Bauer wrote:
Hi!
On Thu, Mar 07, 2002 at 12:58:59PM +0100, Roberto Bagnara wrote:
if (is_a_polynomial(e, x)) {
if (e.info(info_flags::polynomial)) {
(there's also info_flags::integer_polynomial and a couple of others; the complete list is in the GiNaC tutorial)
Hmmm... the notion of polynomial in x that is implemented by degree, ldegree, and so forth, is more general (and rightly so, we believe). For instance, sqrt(2)*x is a polynomial in x of degree 1 accordind to degree(), whereas the info() methods would simply classify is as a non-polynomial. I see two possibilities (but I may be wrong, of course): 1) it is illegal to say degree(sqrt(2)*x) and the fact that now this evaluates to the sensible value 1 is just an accident: it may stop working at any time. In other words, degree() and friends would be granted to work only for expressions e such that e.info(info_flags::polynomial) is true. 2) It is legal to say degree(sqrt(2)*x). But then it would be useful to precisely characterize the class of expressions e and x such that degree(e, x) is well defined. Am I missing something? Thanks a lot Roberto -- Prof. Roberto Bagnara Computer Science Group Department of Mathematics, University of Parma, Italy http://www.cs.unipr.it/~bagnara/ mailto:bagnara@cs.unipr.it