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 symbol (e.g. symbol("X")) ca=
n 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 and o=
ther 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, 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 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 "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=0A      
--0-1466814724-1275066925=:59784
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;">This doesn't work.&nbsp; I may be wrong on th=
e explanation, so someone with more experience please correct me.<br><br>On=
 cursory inspection 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 same, which is the case that matters, then b) you test pointe=
r values.&nbsp; But each expression in the expression tree will have its ow=
n pointer, or at least it appears to in practice.<br><br>From http://www.gi=
nac.de/reference/classGiNaC_1_1ex.html#_details<br><br>"[ex] holds a pointe=
r to the other object in order to do garbage collection by the method of re=
ference counting."&nbsp; This means that each occurrence of an expression w=
ill have its own pointer even if they are *referencing* (i.e. pointing to) =
the same expression.<br><br>Also, in an expression tree, it appears that a
 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 tripp=
ed up by class inheritance and other implementation details.<br><br>It was =
trivial to make the change in the code, so I tried it and indeed it does no=
t work.<br><br>-Doug<br><br><br>Support NPR 20 seconds at a time.  www.twen=
tysecondsatatime.org<br><br>--- On <b>Fri, 5/28/10, jros <i>&lt;jros at unavar=
ra.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;jro=
s 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:<br><br>For class GiNaCPrint if<br><br>std::map&lt;std::string,=
 std::string&gt; m_symbols;<br><br>is changed to<br><br>std::map&lt;ex,
 std::string, ex_is_less&gt; m_symbols;<br><br>And the rest of the code acc=
ordingly, we will:<br><br>1) Leave GiNaC improve future performance wheneve=
r ex_is_less&nbsp; is improved<br><br>2) I think that whenever a comparison=
 of two different (as in memory)<br>expresions gives true (they are the sam=
e symbolically), then GiNaC will<br>automatically eliminate from memory one=
 of the instances. This will<br>probably improve memory allocation within G=
iNaC symbolic expresions as<br>well as speed further comparisons.<br><br>I =
suppose that even ex_is_less can be substituted by a custom function<br>tha=
t compares pointers or something similar, if GiNaC implementation is<br>not=
 quick enough for the purposes of accessing the map. So having an<br>implem=
entation as efficient as the one of the ex::gethash(), but<br>avoiding the =
conflicts due to not uniqueness referred by Doug.<br><br>As with std::map, =
that function can have a default of ex_is_less, and<br>if using
 templates, that function can be overridden when constructing<br>the class.=
<br><br>I hope this helps,<br><br>Javier<br><br><br><br>On Fri, 2010-05-28 =
at 09:21 +0200, Martin Ettl wrote:<br>&gt; Hello all,<br>&gt; <br>&gt; i ha=
ve extended the GinacPrint about following functions:<br>&gt; <br>&gt;&nbsp=
; &nbsp;&nbsp;&nbsp;/**<br>&gt;&nbsp; &nbsp; &nbsp; * With this function th=
e default variable name can be changed.<br>&gt;&nbsp; &nbsp; &nbsp; * By de=
fault it is "e"; Passing an empty string resets<br>&gt;&nbsp; &nbsp; &nbsp;=
 * to default.<br>&gt;&nbsp; &nbsp; &nbsp; * <br>&gt;&nbsp; &nbsp; &nbsp; *=
 @param newVarName the new variable name<br>&gt;&nbsp; &nbsp; &nbsp; * <br>=
&gt;&nbsp; &nbsp; &nbsp; */<br>&gt;&nbsp; &nbsp; &nbsp; void setVarName(con=
st std::string &amp;newVarName);<br>&gt; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;/=
**<br>&gt;&nbsp; &nbsp; &nbsp; * This functions returns the current variabl=
e name.<br>&gt;&nbsp; &nbsp; &nbsp; * By default it is
 "e";<br>&gt;&nbsp; &nbsp; &nbsp; * <br>&gt;&nbsp; &nbsp; &nbsp; * @return =
the current variable name<br>&gt;&nbsp; &nbsp; &nbsp; * <br>&gt;&nbsp; &nbs=
p; &nbsp; */<br>&gt;&nbsp; &nbsp; &nbsp; const std::string &amp; getVarName=
() const;<br>&gt; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;/**<br>&gt;&nbsp; &nbsp;=
 &nbsp; * Clears all internal variables. This is a reset to default functio=
n.<br>&gt;&nbsp; &nbsp; &nbsp; * <br>&gt;&nbsp; &nbsp; &nbsp; */<br>&gt;&nb=
sp; &nbsp; &nbsp; void clear();<br>&gt; <br>&gt; I have attached the modifi=
ed version.<br>&gt; <br>&gt; Best regards from Germany<br>&gt; <br>&gt; Mar=
tin<br>&gt; <br>&gt; -------- Original-Nachricht --------<br>&gt; &gt; Datu=
m: Wed, 26 May 2010 17:55:19 -0700 (PDT)<br>&gt; &gt; Von: Doug &lt;<a ymai=
lto=3D"mailto:cape1232 at yahoo.com" href=3D"/mc/compose?to=3Dcape1232 at yahoo.c=
om">cape1232 at yahoo.com</a>&gt;<br>&gt; &gt; An: GiNaC discussion list &lt;<=
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>&gt;<=
br>&gt; &gt; Betreff: Re: [GiNaC-list] Term ordering and compiling 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 ymailto=3D"mailto:ett=
l.martin at gmx.de" href=3D"/mc/compose?to=3Dettl.martin at gmx.de">ettl.martin at g=
mx.de</a>&gt; wrote:<br>&gt; &gt; <br>&gt; &gt; From: Martin Ettl &lt;<a ym=
ailto=3D"mailto:ettl.martin at gmx.de" href=3D"/mc/compose?to=3Dettl.martin at gm=
x.de">ettl.martin at gmx.de</a>&gt;<br>&gt; &gt; <br>&gt; &gt; ...<br>&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; &nbsp; &nbsp;&=
nbsp;&nbsp;<br>&gt; <br>&gt; ______________________________________________=
_<br>&gt; GiNaC-list mailing list<br>&gt; <a ymailto=3D"mailto:GiNaC-list at g=
inac.de" href=3D"/mc/compose?to=3DGiNaC-list at ginac.de">GiNaC-list at ginac.de<=
/a><br>&gt; <a
 href=3D"https://www.cebix.net/mailman/listinfo/ginac-list" target=3D"_blan=
k">https://www.cebix.net/mailman/listinfo/ginac-list</a><br><br>___________=
____________________________________<br>GiNaC-list mailing list<br><a ymail=
to=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/li=
stinfo/ginac-list" target=3D"_blank">https://www.cebix.net/mailman/listinfo=
/ginac-list</a><br></div></blockquote></td></tr></table><br>=0A=0A      
--0-1466814724-1275066925=:59784--


More information about the GiNaC-list mailing list