[GiNaC-list] Include Guards

Chris Dams C.Dams at science.ru.nl
Fri Jan 21 18:00:04 CET 2005


Dear Jason,

On Fri, 21 Jan 2005, Jason Dusek wrote:

> > using "extern ex x;" in the header file and "ex x(symbol("x"));"
> > in the cpp file is more efficient.
>
> Why is it more efficient?

Try, for instance,

symbol x("x");
ex x1=x;
ex x2=x;

Asking the debugger what x1 and x2 are gives

(gdb) print x1
$1 = {bp = {p = 0x804eb40}}
(gdb) print x2
$2 = {bp = {p = 0x804ec30}}

Two symbols have dynamically allocated and are considered the same because
they have the same serial number.

Let us now try:

ex x(symbol("x"));
ex x1=x;
ex x2=x;

Now the debugger says

(gdb) print x1
$1 = {bp = {p = 0x804eb70}}
(gdb) print x2
$2 = {bp = {p = 0x804eb70}}

Only one symbol has been dynamically allocated. That should be more
efficient.

Beste wishes,
Chris




More information about the GiNaC-list mailing list