get_name() doesn't returned a name like "symbolNNN"?
Hi, According to the documentation (section 4.5 of the online tutorial), the following code should produce something like z.get_name() = "symbol1" but with ginac 1.5.8, I get an empty string. ----- #include <iostream> #include <ginac/ginac.h> using namespace std; using namespace GiNaC; int main() { symbol z; cout << "z.get_name() = \"" << z.get_name() << "\"" << endl; return 0; } ----- In an older version of ginac, this used to work as documented. Is this a bug, or an expected change in behavior? (Or is it just my installation that is broken?) Regards, Warren
On Sat, Aug 28, 2010 at 2:43 PM, Warren Weckesser < warren.weckesser@gmail.com> wrote:
Hi,
According to the documentation (section 4.5 of the online tutorial), the following code should produce something like
z.get_name() = "symbol1"
but with ginac 1.5.8, I get an empty string.
----- #include <iostream> #include <ginac/ginac.h> using namespace std; using namespace GiNaC;
int main() { symbol z; cout << "z.get_name() = \"" << z.get_name() << "\"" << endl; return 0; } -----
In an older version of ginac, this used to work as documented. Is this a bug, or an expected change in behavior? (Or is it just my installation that is broken?)
Partly answering my own question... it looks like the change was introduced in version 1.5.0.
Hello, On Sat, Aug 28, 2010 at 10:17 PM, Warren Weckesser <warren.weckesser@gmail.com> wrote:
Partly answering my own question... it looks like the change was introduced in version 1.5.0.
From symbol.cpp in version 1.5.0: ----- symbol::symbol() : serial(next_serial++), name(""), TeX_name("") { setflag(status_flags::evaluated | status_flags::expanded); } ----- So the default name is an empty string.
[skipped]
It looks like several things were changed. Was it intentional that the default name is no longer "symbolNNN"?
Yes. This way there's no need to allocate memory for the string "symbolNNN" (unless you print the expression involving that symbol). This improves performance a little bit if there are a lot of short-leaving symbols. get_name() misbehaviour you've noticed is definitely a bug, I'll fix that. Best regards, Alexei
Hi, On 08/28/2010 10:17 PM, Warren Weckesser wrote:
It looks like several things were changed. Was it intentional that the default name is no longer "symbolNNN"?
Yes, as Alexei Sheplyakov explained, this is an optimization for temporary short-lived symbols. It's been fixed in commit c5be6a0d868b7f to be picked up in the next release. -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
participants (3)
-
Alexei Sheplyakov
-
Richard B. Kreckel
-
Warren Weckesser