[GiNaC-devel] patch for power

Chris Dams C.Dams at science.ru.nl
Wed Sep 22 11:06:03 CEST 2004


Dear all,

I found that the program

#include <iostream>
#include <ginac/ginac.h>

using namespace std;
using namespace GiNaC;

int main(int argc, char** argv)
{  symbol x("x"),y("y");

   ex e=sin(x)*sin(x);
   if(e.info(info_flags::polynomial))
      cout << e << " is polynomial" << endl;
   else
      cout << e << " is not polynomial" << endl;

   e=sin(x)*sin(y);
   if(e.info(info_flags::polynomial))
      cout << e << " is polynomial" << endl;
   else
      cout << e << " is not polynomial" << endl;

   return 0;
}

gives the output

	sin(x)^2 is polynomial
	sin(x)*sin(y) is not polynomial

which I find very awkward. The attached patch unpolynomializes sin(x)^2.

Best,
Chris
-------------- next part --------------
Index: power.cpp
===================================================================
RCS file: /home/cvs/GiNaC/ginac/power.cpp,v
retrieving revision 1.93
diff -r1.93 power.cpp
225c225
< 			return exponent.info(info_flags::nonnegint);
---
> 			return exponent.info(info_flags::nonnegint) && basis.info(inf);
227c227
< 			return exponent.info(info_flags::integer);
---
> 			return exponent.info(info_flags::integer) && basis.info(inf);


More information about the GiNaC-devel mailing list