[GiNaC-list] bug with is_polynomial?
Jonathan Cross
jacross at u.washington.edu
Tue Aug 5 22:58:59 CEST 2008
Hello,
I'm using GiNaC 1.4.3 built on Mac OS X.
I think I've found a problem with is_polynomial when powers are
involved.
When there is an expression involving a non-integer power---even when
the expression is independent of the dummy variable of the polynomial---
then the expression is not considered a polynomial by GiNaC.
The following code illustrates the problem: (or perhaps I don't
fully understand "is_polynomial"?)
-------------------------
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
int main()
{
GiNaC::symbol x("x");
GiNaC::symbol s("s");
// here are two expressions that are both polynomials with respect
to s.
GiNaC::ex expr1 = sin(x) + 2*s;
GiNaC::ex expr2 = pow(2,x) + 2*s;
// works as expected
if (expr1.is_polynomial(s))
cout << expr1 << " is a polynomial with respect to " << s << endl;
else
cout << expr1 << " is NOT a polynomial with respect to " << s <<
endl;
// reports 2^x + 2s is not a polynomial in s?
if (expr2.is_polynomial(s))
cout << expr2 << " is a polynomial with respect to " << s << endl;
else
cout << expr2 << " is NOT a polynomial with respect to " << s <<
endl;
return 0;
}
------------------------
I'm not familiar enough with the internal workings of GiNaC to make a
patch, but this seems like the changes required would be fairly small.
Thanks!
More information about the GiNaC-list
mailing list