Dear all,
this message is a first of a small series where we try to summarize
our difficulties with GiNaC and its (lack of) documentation.
As a general remark, several concepts are defined only through examples
whereas formal definitions would help greatly.
In this message we concentrate on one concept that is central to our
application: the concept of "polynomial". Here are our sources of
information:
1) The tutorial: a bunch of examples are presented that, however
do not clarify the general idea.
2) The method `info(info_flags::polynomial)' should constitute,
we used to believe, the very formal specification of the
notion of "being a polynomial".
3) The message by Christian Bauer (March 7th, 2002,
see http://www.ginac.de/lists/ginac-list/msg00232.html):
"But this is the intended behavior:
If e is of the form e = sum(i=n1..n2, a_i * x^i) with n1, n2
integer and expressions a_i that satisfy has(a_i, x) == false,
then degree(e, x) and ldegree(e, x) are well defined and accurate.
I think this should even cover cases like
degree(sin(y)^3-sin(y),sin(y))
which is guaranteed to return 3."
The problem is that, while 1 is inconclusive, 2 and 3 (with the
correction replacing "integer" by "nonnegative integer") conflict
with each other. Let us consider the expression
e = sqrt(2)*x.
Since, clearly, has(sqrt(2), x) == false, `e' is a polynomial for 3.
But, since e.info(info_flags::polynomial) == false, `e' is not
a polynomial according to 2.
The point here is to decide _exactly_ for which class of expressions
are the functions degree(), ldegree(), coeff(), lcoeff(), tcoeff(),
expand(), collect(), quo(), rem(), prem(), gcd(), lcm(), sqrfree()
and so forth guaranteed to work.
All the best
Roberto Bagnara
Alessandro Zaccagnini
Enea Zaffanella
Tatiana Zolo
/***************************************************************************/
#include <ginac/ginac.h>
#include <iostream>
using namespace GiNaC;
using namespace std;
int
main() {
symbol x("x");
ex coeff = sqrt(ex(2));
ex e = coeff*x;
cout << (e.info(info_flags::polynomial) ? "true" : "false") << endl;
cout << (!has(coeff, x) ? "true" : "false") << endl;
return 0;
}
/***************************************************************************/
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it
CVSROOT: /cvs/purrs
Module name: purrs
Changes by: zolo(a)cs.unipr.it 2002-10-09 11:52:23
Modified files:
. : TODO.tex
Log message:
Added a problem about Gosper's algorithm, in particular about the compute
of the resultant's roots.
Patches:
http://www.cs.unipr.it/cgi-bin/cvsweb.cgi/purrs/TODO.tex.diff?cvsroot=purrs…
CVSROOT: /cvs/purrs
Module name: purrs
Changes by: zolo(a)cs.unipr.it 2002-10-08 15:15:28
Modified files:
src : rr_solver.cc
Log message:
Modified `get_constant_decrement()': now returns also a null decrement.
`eliminate_negative_decrements()' not returns a bool: it never fails.
Patches:
http://www.cs.unipr.it/cgi-bin/cvsweb.cgi/purrs/src/rr_solver.cc.diff?cvsro…
CVSROOT: /cvs/purrs
Module name: purrs
Changes by: zolo(a)cs.unipr.it 2002-10-08 10:04:36
Modified files:
src : simplify.cc
Log message:
Restored an object Expr (instead of a Number) in order to
avoid the rounding of the number.
Patches:
http://www.cs.unipr.it/cgi-bin/cvsweb.cgi/purrs/src/simplify.cc.diff?cvsroo…