[GiNaC-list] table and exhashmap

Jerome BENOIT jgmbenoit at mailsnare.net
Mon Feb 19 13:20:31 CET 2007


Hi,

Sheplyakov Alexei wrote:
> 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.

I am more than agree: hence my question.
I guess that I still too Maple oriented.

Thanks you very much,
Jerome



More information about the GiNaC-list mailing list