On Wed, Oct 28, 2009 at 6:42 PM, Bertfried Fauser wrote:
>
> Uff I am sorry I started this, I will store all these mails and look
> at them later, have to fokus on plethysms....

Don't worry. This is not typical. There will be long periods of
silence where you can get some real work done. It is just interesting
suddenly that someone new is asking interesting questions here. :-)

>
> Am I naive with the following (down to earth) approach:
>
> Given I have a function, say:
> MurNak(Partition,Partition) -> Integer
>
> May I not just implement inside the function a table with
>
> key= (part,part)   (possibly somehow turned into a hash value)
> value = result of Murnak(part,part) for that pair.
>
> If the function is called, it looks up if a value is in the
> cache/table, if so fine, else compute the value, store it
> and return it.
>
> The outside world never wold even see that some caching is
> going on. Anyhow, caching can cause side effects, and may
> need vast amount of memory, so it has to be used with care
> and hindsight anyhow.
>

Yes you can - well almost.  The slight complication is to decide where
you are going to store the table.  A possible answer is that it might
be part of the domain where the function is defined.  The domains that
Franz and Ralf have designed on the other hand are intended
essentially to act like such "containers" for the table. It is really
not much more complicated than that.

In the case of a two argument function you first need to define a
simple domain of SetCategory that combines two domains into one.
Examples of such domains are 'Product' and 'Record' (also 'List' and
'DirectProduct' are good if the same domain is used twice).

So given that you want a function with the signature

  MurNak: (Partition,Partition) -> Integer

what you do is first define a related function such as

  MurNak2: Record(x1:Partition,x2:Partition) -> Integer

And where you might have written the function like this:

  MurNak(x1:Partition,x2:Partition):Integer ==  ... x1 ... x2 ...

with 'x1' and 'x2' parameters of the function, you now write instead

  MurNak2(arg):Integer ==  ... arg.x1 ... arg.x2 ...

Here 'arg' is a single parameter that refers to the Record. 'arg.x1'
is it's first component and 'arg.x2' is it's second component.

One calls MurNak2 like this

  MurNak2 [a,b]

for some values a and b. The brackets [a,b] construct a value of type
Record(x1:Partition,x2:Partition) on which MurNak2 operates.

Now you can define a cached version of this using Ralf's new domain constructor:

  MurNakCached2:CachedFunction(Record(a1:Partition,a2:Partion),Integer) :=
    cachedFunction(MurNak2)

and you call it like this

  MurNakCached2 [a,b]

Or if you want you can wrap it up as the original two argument
function like this:

  MurNak(x,y) == MurNakCached2 [x,y]

It's easier than this sounds.

Regards,
Bill Page.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to fricas-devel@googlegroups.com
To unsubscribe from this group, send email to 
fricas-devel+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to