Re: Patch for TeX_name and domain for symbols

18 views
Skip to first unread message

Burcin Erocal

unread,
Jul 19, 2009, 3:49:21 PM7/19/09
to Golam Mortuza Hossain, pynac...@googlegroups.com
Hi Golam,

On Sun, July 19, 2009 3:52 am, Golam Mortuza Hossain wrote:
> Hi Burcin,
>
> Here is a patch that exposes TeX_name and domain of
> Pynac (0.1.9.a1) symbols to Sage. Please feel free to modify
> it.

Thank you for your work. I think we should go through the standard review
process, so you make the modifications yourself. See below for my
comments.

> I also see a limitation. I couldn't find a way to update either
> domain or texname of an already defined symbol. Is there
> a way to do so?

I don't see any easy way.

It seems that the GiNaC developers chose to subclass symbol to represent
real and positive symbols for speed, instead of storing the domain in an
internal variable and testing in each call to get_domain(), conjugate(),
etc.

The question is if we still wan't to keep the unique symbol concept in Sage.

Now, we have:

sage: t = var('x')
sage: var('x')
sage: bool(x == t)
True

If we drop the symbol directory, we won't have the last equality any more.
I believe this will be very confusing for users.

Having variables with the same name, but different domain at the same time
would also be confusing. I don't think we can avoid this without a serious
sacrifice in speed though.

I would still expect this behavior:

sage: x_complex = var('x')
sage: t = x_complex + 2
sage: x_real = var('x', domain=RR)
sage: u = x+2
sage: bool(t == u)
False
sage: x1 = var('x')
sage: bool(x_complex == x1)
True
sage: bool(x_real == x1)
False

So we need to use the domain as a key in the symbol directory as well. I
suggest we move the directory completely to python, and hash the symbol
name and the domain. I don't know if adding the latex name to the keys is
desirable.

When you move the symbol directory to Sage, you can reduce your patch to
only the first 3 hunks, since get_symbol() will not be used any more.

For reference, when giving a new argument to get_symbol(), it's better to
pass the domain not as a string, but the enum defined here:

http://www.ginac.de/reference/classGiNaC_1_1domain.html


Cheers,
Burcin

TeX_name-and-domain-of-symbols.patch

Golam Mortuza Hossain

unread,
Sep 5, 2009, 6:05:54 PM9/5/09
to pynac...@googlegroups.com
Hi,


On Sun, Jul 19, 2009 at 4:49 PM, Burcin Erocal<bur...@erocal.org> wrote:

> When you move the symbol directory to Sage, you can reduce your patch to
> only the first 3 hunks, since get_symbol() will not be used any more.


Attached is an updated pynac patch. This now allows one to update
TeX_name and domain of an already defined symbols.

Sage patch posted at

http://trac.sagemath.org/sage_trac/ticket/6559

Thanks,
Golam

texname-and-domain-of-symbols-pynac.patch
Reply all
Reply to author
Forward
0 new messages