[GiNaC-list] table and exhashmap
Sheplyakov Alexei
varg at theor.jinr.ru
Mon Feb 19 11:28:23 CET 2007
On Mon, Feb 19, 2007 at 03:45:03PM +0800, Jerome BENOIT wrote:
> Let be more specific.
>
> During some kind of computation I have to compute (multi-indexed)
> coefficients:
> 1] these coefficients are long to compute;
> 2] they are computed by sub set through (consuming) recurrence formulae;
> 3] these coefficients are meant to be used randomly and very often.
> Clearly the remember machinery can be use to overcome point [1] and [3]:
> for GiNaC function this is transparent for the user.
>
> Point [2] causes me some difficulty:
> I want to compute each subset only once.
> Hence the idea to compute each subset through a GiNaC function
> (with the remember option) which return tables,
Why do you need _GiNaC_ function to compute coefficients? What's wrong
with C++ function, e.g.
ex compute(const ex& data)
{
static exmap remember;
exmap::iterator i = remember.find(data);
if (i != remember.end())
return i->second;
ex result;
// actually compute it, making use of compute() itself
remember.insert(exmap::value_type(data, result));
return result;
}
> Right now, my guess is that I have to introduce a super class
> with a exhashmap<SOMETHING> as (principal) member: I thought
> that there was a better GiNaC way to do so, but apparently not.
Unless I'm missing something fundamental, this approach seems to be
unnecessary complicated.
Best regards,
Alexei
--
All science is either physics or stamp collecting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20070219/b18ac4e4/attachment.pgp
More information about the GiNaC-list
mailing list