Re: [GiNaC-list] Term ordering and compiling C++ code
Hello all, i have extended the GinacPrint about following functions: /** * With this function the default variable name can be changed. * By default it is "e"; Passing an empty string resets * to default. * * @param newVarName the new variable name * */ void setVarName(const std::string &newVarName); /** * This functions returns the current variable name. * By default it is "e"; * * @return the current variable name * */ const std::string & getVarName() const; /** * Clears all internal variables. This is a reset to default function. * */ void clear(); I have attached the modified version. Best regards from Germany Martin -------- Original-Nachricht --------
Datum: Wed, 26 May 2010 17:55:19 -0700 (PDT) Von: Doug <cape1232@yahoo.com> An: GiNaC discussion list <ginac-list@ginac.de> Betreff: Re: [GiNaC-list] Term ordering and compiling C++ code
Beautiful. Thanks!
--- On Wed, 5/26/10, Martin Ettl <ettl.martin@gmx.de> wrote:
From: Martin Ettl <ettl.martin@gmx.de>
... What do you think about my modifications (see attachment)?
-- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
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 is improved 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,
i have extended the GinacPrint about following functions:
/** * With this function the default variable name can be changed. * By default it is "e"; Passing an empty string resets * to default. * * @param newVarName the new variable name * */ void setVarName(const std::string &newVarName);
/** * This functions returns the current variable name. * By default it is "e"; * * @return the current variable name * */ const std::string & getVarName() const;
/** * Clears all internal variables. This is a reset to default function. * */ void clear();
I have attached the modified version.
Best regards from Germany
Martin
-------- Original-Nachricht --------
Datum: Wed, 26 May 2010 17:55:19 -0700 (PDT) Von: Doug <cape1232@yahoo.com> An: GiNaC discussion list <ginac-list@ginac.de> Betreff: Re: [GiNaC-list] Term ordering and compiling C++ code
Beautiful. Thanks!
--- On Wed, 5/26/10, Martin Ettl <ettl.martin@gmx.de> wrote:
From: Martin Ettl <ettl.martin@gmx.de>
... What do you think about my modifications (see attachment)?
_______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de https://www.cebix.net/mailman/listinfo/ginac-list
This doesn't work. I may be wrong on the explanation, so someone with more experience please correct me. 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. If they are the same, which is the case that matters, then b) you test pointer values. But each expression in the expression tree will have its own pointer, or at least it appears to in practice.
Actually, the simplest explanation is: since hashes aren't unique, ex_is_less doesn't work for GinacPrint. Forgive the verbosity below! ;) Support NPR 20 seconds at a time. www.twentysecondsatatime.org --- On Fri, 5/28/10, Doug <cape1232@yahoo.com> wrote: From: Doug <cape1232@yahoo.com> Subject: Re: [GiNaC-list] Term ordering and compiling C++ code To: jros@unavarra.es, "GiNaC discussion list" <ginac-list@ginac.de> Date: Friday, May 28, 2010, 1:15 PM This doesn't work. I may be wrong on the explanation, so someone with more experience please correct me. 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. If they are the same, which is the case that matters, then b) you test pointer values. But each expression in the expression tree will have its own pointer, or at least it appears to in practice.
participants (3)
-
Doug
-
jros
-
Martin Ettl