[GiNaC-list] table and exhashmap

Jerome BENOIT jgmbenoit at mailsnare.net
Mon Feb 19 08:45:03 CET 2007


Hello,

thank you for the reply.

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,
a second function (without the remember option) can then
call this function and pick up the desired coefficient
--- a kind of wrapper function.
Another possibility is to write down only one GiNaC function
(with remember option) which record not only the desired value
(as it is done by the remember machinery) but also the all
coefficients of the computed subset. The latter alternative
may be good, but unfortunately (unless I missed something in
GiNaC code) we can do such a thing. Anyhow, the former approach
is better in the current case because some computation may need
to deal directly with the subsets. The use of a lst is also a
possibility (currently my function returns lst),
but I want to pick up rapidly each coefficient.

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.

Otherwise, I thing that using table of expressions
makes as sense as using lst of expressions.
 
Best regards,
Jerome

Sheplyakov Alexei wrote:
> Hi,
> 
> On Mon, Feb 19, 2007 at 01:58:10AM +0800, Jerome BENOIT wrote:
> 
>> I am afraid I have to specify my request:
>> by function I meant GiNaC function
>> (the one declared with DECLARE_FUNCTION_<N>P).
> 
> What about a list (GiNaC::lst) of relational objects, e.g.
> 
> DECLARE_FUNCTION_2P(foo)
> static ex eval_foo(const ex& x, const ex& y)
> {
> 	lst l;
> 	l = x == x + y/2, y == cos(x);
> 	return l;
> }
> REGISTER_FUNCTION(foo, eval_func(eval_foo))
> 
> 
>> As the object exmap (or exhashmap<T>) is no an ex object,
>> it cannot be returned by such a function.
> 
> Exactly, since most operations with expressions do not make any sense
> for associative arrays. So I wonder why you want to treat associative
> arrays as expressions.
> 
> 
> Best regards,
>  Alexei
> 

-- 
Jerome BENOIT
jgmbenoit_at_mailsnare_dot_net


More information about the GiNaC-list mailing list