ldegree changes after expand
Dear All, I've just hit an unexpected behavior of the ex.ldegree() method in my application. The problem is that ldegree() gives 0 before and 1 (the expected value) after calling expand() on the expression. I did not expect this, as the tutorial says that degree() and ldegree() "work reliably on non-expanded input polynomials". A small running example and its output are attached. The expression is the one I encountered in my application. This looks like a bug to me, or is it necessary to call expand() before using ldegree()? A related question: What about coeff(), should I call expand() before using coeff()? GiNaC version: 1.7.4 g++ version: 7.3.1 openSUSE (tumbleweed) Thanks in advance for any help on these questions Matthias
Dear Alexey, thanks for your reply, that answers my question. Since I mostly relied on the (otherwise quite helpful) tutorial when learning about GiNaC, I would appreciate it if the wording in the tutorial could be clarified. Best regards, Matthias Am 04.06.2018 um 10:31 schrieb Alexey Sheplyakov:
I've just hit an unexpected behavior of the ex.ldegree() method in my application. The problem is that ldegree() gives 0 before and 1 (the expected value) after calling expand() on the expression. I did not expect this, as the tutorial says that degree() and ldegree() "work reliably on non-expanded input polynomials". The tutorial is misleading. The only reason why one could claim that [l]degree() "works reliably" with non-expanded inputs is that the program won't crash. Proof: try this in ginsh: ldegree(x*(x^2-1) - x^2*(x - 1), x) The code [1] does not expect different terms to cancel each other, hence
Hi, 02.06.2018, 01:50, "Matthias Naaf via GiNaC-list" <ginac-list@ginac.de>: the problem [1] https://www.ginac.de/ginac.git/?p=ginac.git;a=blob;f=ginac/add.cpp;h=25de6cd...
A small running example and its output are attached. The expression is the one I encountered in my application. This looks like a bug to me, or is it necessary to call expand() before using ldegree()? One should expand the expression before using degree(), ldegree(), coeff() Best regards, Alexey
participants (2)
-
Alexey Sheplyakov
-
Matthias Naaf