I am confused by the behavior of possymbols in relations. Consider the following program: ------------------------------------------------ #include <ginac/ginac.h> using namespace GiNaC; int main() { possymbol x("x"); if (x.info(info_flags::positive)) std::cout << "x is positive\n"; else std::cout << "x is _not_ positive\n"; if (x > 0) std::cout << "x is greater than zero\n"; else std::cout << "x is _not_ greater than zero\n"; } ------------------------------------------------ I would expect the output to be: x is positive x is greater than zero But the output I get is: x is positive x is _not_ greater than zero Am I misunderstanding the use of possymbol? Thanks, Michael Boyer
Hi! On 03/22/2011 09:32 PM, Michael Boyer wrote:
I am confused by the behavior of possymbols in relations. Consider the following program:
------------------------------------------------ #include<ginac/ginac.h> using namespace GiNaC;
int main() { possymbol x("x");
if (x.info(info_flags::positive)) std::cout<< "x is positive\n"; else std::cout<< "x is _not_ positive\n";
if (x> 0) std::cout<< "x is greater than zero\n"; else std::cout<< "x is _not_ greater than zero\n"; } ------------------------------------------------
I would expect the output to be: x is positive x is greater than zero
But the output I get is: x is positive x is _not_ greater than zero
Am I misunderstanding the use of possymbol?
Please check the tutorial, in particular the section "Ordering expressions". I hope this answers your question. -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
On Wed, Mar 23, 2011 at 5:28 AM, Richard B. Kreckel <kreckel@ginac.de> wrote:
Please check the tutorial, in particular the section "Ordering expressions". I hope this answers your question.
Richard, Thanks for the pointer. I had read that section before but had not properly understood how it related to what I was doing. Another somewhat related question. Consider the following program: ------------------------------------------------ #include <ginac/ginac.h> using namespace GiNaC; int main() { possymbol x("x"); ex a = x; if (a.info(info_flags::positive)) std::cout << a << " is positive\n"; else std::cout << a << " is _not_ positive\n"; a *= -1; if (a.info(info_flags::negative)) std::cout << a << " is negative\n"; else std::cout << a << " is _not_ negative\n"; } ------------------------------------------------ The output I see is: x is positive -x is _not_ negative Any idea why it cannot determine that -x is in fact negative? - Michael
Hi! On 03/23/2011 03:39 PM, Michael Boyer wrote:
------------------------------------------------ #include<ginac/ginac.h> using namespace GiNaC;
int main() { possymbol x("x"); ex a = x;
if (a.info(info_flags::positive)) std::cout<< a<< " is positive\n"; else std::cout<< a<< " is _not_ positive\n";
a *= -1;
if (a.info(info_flags::negative)) std::cout<< a<< " is negative\n"; else std::cout<< a<< " is _not_ negative\n"; } ------------------------------------------------
The output I see is: x is positive -x is _not_ negative
Any idea why it cannot determine that -x is in fact negative?
It can and does determine that since 1.5.7. You must be using an older release. -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
On Wed, Mar 23, 2011 at 5:41 PM, Richard B. Kreckel <kreckel@ginac.de> wrote:
Any idea why it cannot determine that -x is in fact negative?
It can and does determine that since 1.5.7. You must be using an older release.
Great, thanks! I am using 1.5.5-1, which is the latest version in the Ubuntu 10.04 repository. Looks like I need to upgrade! Thanks, Michael
participants (2)
-
Michael Boyer
-
Richard B. Kreckel