No subject


Fri Mar 19 00:39:14 CET 2010


"[ex] holds a pointer to the other object in order to do garbage collection=
 by the method of reference counting."=A0 This means that each occurrence o=
f an expression will have its own pointer even if they are *referencing* (i=
.e. pointing to) the same expression.

Also, in an expression tree, it appears that a=0A symbol (e.g. symbol("X"))=
 can occur both as a symbol and as an expression that points to the symbol.=
=A0 Thus, by using pointers, you can get tripped up by class inheritance an=
d other implementation details.

It was trivial to make the change in the code, so I tried it and indeed it =
does not work.

-Doug


Support NPR 20 seconds at a time.  www.twentysecondsatatime.org

--- On Fri, 5/28/10, jros <jros at unavarra.es> wrote:

From: jros <jros at unavarra.es>
Subject: Re: [GiNaC-list] Term ordering and compiling C++ code
To: "GiNaC discussion list" <ginac-list at ginac.de>
Date: Friday, May 28, 2010, 12:38 PM

Would this make sense:

For class GiNaCPrint if

std::map<std::string, std::string> m_symbols;

is changed to

std::map<ex,=0A std::string, ex_is_less> m_symbols;

And the rest of the code accordingly, we will:

1) Leave GiNaC improve future performance whenever ex_is_less=A0 is improve=
d

2) I think that whenever a comparison of two different (as in memory)
expresions gives true (they are the same symbolically), then GiNaC will
automatically eliminate from memory one of the instances. This will
probably improve memory allocation within GiNaC symbolic expresions as
well as speed further comparisons.

I suppose that even ex_is_less can be substituted by a custom function
that compares pointers or something similar, if GiNaC implementation is
not quick enough for the purposes of accessing the map. So having an
implementation as efficient as the one of the ex::gethash(), but
avoiding the conflicts due to not uniqueness referred by Doug.

As with std::map, that function can have a default of ex_is_less, and
if using=0A templates, that function can be overridden when constructing
the class.

I hope this helps,

Javier



On Fri, 2010-05-28 at 09:21 +0200, Martin Ettl wrote:
> Hello all,
>=20
> i have extended the GinacPrint about following functions:
>=20
>=A0 =A0=A0=A0/**
>=A0 =A0 =A0 * With this function the default variable name can be changed.
>=A0 =A0 =A0 * By default it is "e"; Passing an empty string resets
>=A0 =A0 =A0 * to default.
>=A0 =A0 =A0 *=20
>=A0 =A0 =A0 * @param newVarName the new variable name
>=A0 =A0 =A0 *=20
>=A0 =A0 =A0 */
>=A0 =A0 =A0 void setVarName(const std::string &newVarName);
>=20
>=A0 =A0=A0=A0/**
>=A0 =A0 =A0 * This functions returns the current variable name.
>=A0 =A0 =A0 * By default it is=0A "e";
>=A0 =A0 =A0 *=20
>=A0 =A0 =A0 * @return the current variable name
>=A0 =A0 =A0 *=20
>=A0 =A0 =A0 */
>=A0 =A0 =A0 const std::string & getVarName() const;
>=20
>=A0 =A0=A0=A0/**
>=A0 =A0 =A0 * Clears all internal variables. This is a reset to default fu=
nction.
>=A0 =A0 =A0 *=20
>=A0 =A0 =A0 */
>=A0 =A0 =A0 void clear();
>=20
> I have attached the modified version.
>=20
> Best regards from Germany
>=20
> Martin
>=20
> -------- Original-Nachricht --------
> > Datum: Wed, 26 May 2010 17:55:19 -0700 (PDT)
> > Von: Doug <cape1232 at yahoo.com>
> > An: GiNaC discussion list <ginac-list at ginac.de>
> > Betreff: Re: [GiNaC-list] Term ordering and compiling C++ code
>=20
> > Beautiful.=A0 Thanks!
> >=20
> >=20
> > --- On Wed, 5/26/10, Martin Ettl <ettl.martin at gmx.de> wrote:
> >=20
> > From: Martin Ettl <ettl.martin at gmx.de>
> >=20
> > ...
> > What do you think about my modifications (see attachment)?
> >=20
> >=20
> >=20
> >=20
> >=A0 =A0 =A0=A0=A0
>=20
> _______________________________________________
> GiNaC-list mailing list
> GiNaC-list at ginac.de
> https://www.cebix.net/mailman/listinfo/ginac-list

_______________________________________________
GiNaC-list mailing list
GiNaC-list at ginac.de
https://www.cebix.net/mailman/listinfo/ginac-list

=0A=0A     =20
-----Inline Attachment Follows-----

_______________________________________________
GiNaC-list mailing list
GiNaC-list at ginac.de
https://www.cebix.net/mailman/listinfo/ginac-list
=0A=0A=0A      
--0-509566004-1275073332=:8498
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<table cellspacing=3D"0" cellpadding=3D"0" border=3D"0" ><tr><td valign=3D"=
top" style=3D"font: inherit;">Actually, the simplest explanation is: since =
hashes aren't unique, ex_is_less doesn't <br>work for GinacPrint.&nbsp; For=
give the verbosity below!&nbsp; ;)<br><br>Support NPR 20 seconds at a time.=
  www.twentysecondsatatime.org<br><br>--- On <b>Fri, 5/28/10, Doug <i>&lt;c=
ape1232 at yahoo.com&gt;</i></b> wrote:<br><blockquote style=3D"border-left: 2=
px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: =
Doug &lt;cape1232 at yahoo.com&gt;<br>Subject: Re: [GiNaC-list] Term ordering =
and compiling C++ code<br>To: jros at unavarra.es, "GiNaC discussion list" &lt=
;ginac-list at ginac.de&gt;<br>Date: Friday, May 28, 2010, 1:15 PM<br><br><div=
 id=3D"yiv1866428886"><table border=3D"0" cellpadding=3D"0" cellspacing=3D"=
0"><tbody><tr><td style=3D"font-family: inherit; font-style: inherit; font-=
variant: inherit; font-weight: inherit; font-size: inherit; line-height: in=
herit;
 font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;" v=
align=3D"top">This doesn't work.&nbsp; I may be wrong on the explanation, s=
o someone with more experience please correct me.<br><br>On cursory inspect=
ion of ex_is_less and the compare functions it references, ex_is_less boils=
 down to a) comparing the expressions hash values.&nbsp; If they are the sa=
me, which is the case that matters, then b) you test pointer values.&nbsp; =
But each expression in the expression tree will have its own pointer, or at=
 least it appears to in practice.<br><br>From http://www.ginac.de/reference=
/classGiNaC_1_1ex.html#_details<br><br>"[ex] holds a pointer to the other o=
bject in order to do garbage collection by the method of reference counting=
."&nbsp; This means that each occurrence of an expression will have its own=
 pointer even if they are *referencing* (i.e. pointing to) the same express=
ion.<br><br>Also, in an expression tree, it appears that a=0A symbol (e.g. =
symbol("X")) can occur both as a symbol and as an expression that points to=
 the symbol.&nbsp; Thus, by using pointers, you can get tripped up by class=
 inheritance and other implementation details.<br><br>It was trivial to mak=
e the change in the code, so I tried it and indeed it does not work.<br><br=
>-Doug<br><br><br>Support NPR 20 seconds at a time.  www.twentysecondsatati=
me.org<br><br>--- On <b>Fri, 5/28/10, jros <i>&lt;jros at unavarra.es&gt;</i><=
/b> wrote:<br><blockquote style=3D"border-left: 2px solid rgb(16, 16, 255);=
 margin-left: 5px; padding-left: 5px;"><br>From: jros &lt;jros at unavarra.es&=
gt;<br>Subject: Re: [GiNaC-list] Term ordering and compiling C++ code<br>To=
: "GiNaC discussion list" &lt;ginac-list at ginac.de&gt;<br>Date: Friday, May =
28, 2010, 12:38 PM<br><br><div class=3D"plainMail">Would this make sense:<b=
r><br>For class GiNaCPrint if<br><br>std::map&lt;std::string, std::string&g=
t; m_symbols;<br><br>is changed to<br><br>std::map&lt;ex,=0A std::string, e=
x_is_less&gt; m_symbols;<br><br>And the rest of the code accordingly, we wi=
ll:<br><br>1) Leave GiNaC improve future performance whenever ex_is_less&nb=
sp; is improved<br><br>2) I think that whenever a comparison of two differe=
nt (as in memory)<br>expresions gives true (they are the same symbolically)=
, then GiNaC will<br>automatically eliminate from memory one of the instanc=
es. This will<br>probably improve memory allocation within GiNaC symbolic e=
xpresions as<br>well as speed further comparisons.<br><br>I suppose that ev=
en ex_is_less can be substituted by a custom function<br>that compares poin=
ters or something similar, if GiNaC implementation is<br>not quick enough f=
or the purposes of accessing the map. So having an<br>implementation as eff=
icient as the one of the ex::gethash(), but<br>avoiding the conflicts due t=
o not uniqueness referred by Doug.<br><br>As with std::map, that function c=
an have a default of ex_is_less, and<br>if using=0A templates, that functio=
n can be overridden when constructing<br>the class.<br><br>I hope this help=
s,<br><br>Javier<br><br><br><br>On Fri, 2010-05-28 at 09:21 +0200, Martin E=
ttl wrote:<br>&gt; Hello all,<br>&gt; <br>&gt; i have extended the GinacPri=
nt about following functions:<br>&gt; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;/**<=
br>&gt;&nbsp; &nbsp; &nbsp; * With this function the default variable name =
can be changed.<br>&gt;&nbsp; &nbsp; &nbsp; * By default it is "e"; Passing=
 an empty string resets<br>&gt;&nbsp; &nbsp; &nbsp; * to default.<br>&gt;&n=
bsp; &nbsp; &nbsp; * <br>&gt;&nbsp; &nbsp; &nbsp; * @param newVarName the n=
ew variable name<br>&gt;&nbsp; &nbsp; &nbsp; * <br>&gt;&nbsp; &nbsp; &nbsp;=
 */<br>&gt;&nbsp; &nbsp; &nbsp; void setVarName(const std::string &amp;newV=
arName);<br>&gt; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;/**<br>&gt;&nbsp; &nbsp; =
&nbsp; * This functions returns the current variable name.<br>&gt;&nbsp; &n=
bsp; &nbsp; * By default it is=0A "e";<br>&gt;&nbsp; &nbsp; &nbsp; * <br>&g=
t;&nbsp; &nbsp; &nbsp; * @return the current variable name<br>&gt;&nbsp; &n=
bsp; &nbsp; * <br>&gt;&nbsp; &nbsp; &nbsp; */<br>&gt;&nbsp; &nbsp; &nbsp; c=
onst std::string &amp; getVarName() const;<br>&gt; <br>&gt;&nbsp; &nbsp;&nb=
sp;&nbsp;/**<br>&gt;&nbsp; &nbsp; &nbsp; * Clears all internal variables. T=
his is a reset to default function.<br>&gt;&nbsp; &nbsp; &nbsp; * <br>&gt;&=
nbsp; &nbsp; &nbsp; */<br>&gt;&nbsp; &nbsp; &nbsp; void clear();<br>&gt; <b=
r>&gt; I have attached the modified version.<br>&gt; <br>&gt; Best regards =
from Germany<br>&gt; <br>&gt; Martin<br>&gt; <br>&gt; -------- Original-Nac=
hricht --------<br>&gt; &gt; Datum: Wed, 26 May 2010 17:55:19 -0700 (PDT)<b=
r>&gt; &gt; Von: Doug &lt;<a rel=3D"nofollow">cape1232 at yahoo.com</a>&gt;<br=
>&gt; &gt; An: GiNaC discussion list &lt;<a rel=3D"nofollow">ginac-list at gin=
ac.de</a>&gt;<br>&gt; &gt; Betreff: Re: [GiNaC-list] Term ordering and comp=
iling C++ code<br>&gt;
 <br>&gt; &gt; Beautiful.&nbsp; Thanks!<br>&gt; &gt; <br>&gt; &gt; <br>&gt;=
 &gt; --- On Wed, 5/26/10, Martin Ettl &lt;<a rel=3D"nofollow">ettl.martin@=
gmx.de</a>&gt; wrote:<br>&gt; &gt; <br>&gt; &gt; From: Martin Ettl &lt;<a r=
el=3D"nofollow">ettl.martin at gmx.de</a>&gt;<br>&gt; &gt; <br>&gt; &gt; ...<b=
r>&gt; &gt; What do you think about my modifications (see attachment)?<br>&=
gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt;&nbsp; &nbs=
p; &nbsp;&nbsp;&nbsp;<br>&gt; <br>&gt; ____________________________________=
___________<br>&gt; GiNaC-list mailing list<br>&gt; <a rel=3D"nofollow">GiN=
aC-list at ginac.de</a><br>&gt; <a rel=3D"nofollow" target=3D"_blank" href=3D"=
https://www.cebix.net/mailman/listinfo/ginac-list">https://www.cebix.net/ma=
ilman/listinfo/ginac-list</a><br><br>______________________________________=
_________<br>GiNaC-list mailing list<br><a rel=3D"nofollow">GiNaC-list at gina=
c.de</a><br><a rel=3D"nofollow" target=3D"_blank"
 href=3D"https://www.cebix.net/mailman/listinfo/ginac-list">https://www.ceb=
ix.net/mailman/listinfo/ginac-list</a><br></div></blockquote></td></tr></tb=
ody></table><br>=0A=0A      </div><br>-----Inline Attachment Follows-----<b=
r><br><div class=3D"plainMail">____________________________________________=
___<br>GiNaC-list mailing list<br><a ymailto=3D"mailto:GiNaC-list at ginac.de"=
 href=3D"/mc/compose?to=3DGiNaC-list at ginac.de">GiNaC-list at ginac.de</a><br><=
a href=3D"https://www.cebix.net/mailman/listinfo/ginac-list" target=3D"_bla=
nk">https://www.cebix.net/mailman/listinfo/ginac-list</a><br></div></blockq=
uote></td></tr></table><br>=0A=0A      
--0-509566004-1275073332=:8498--


More information about the GiNaC-list mailing list