> I have noticed inefficiency, multiplying constant function by > itself needs 4.11 sec to compute term number 5000. I think > we can get much better efficiency using a version of Stream > which is buffering values using array (and growing the array > as needed). Then we can compute only needed values (we > still need to allocate space for all).
http://www.risc.jku.at/people/hemmecke/AldorCombinat/combinatse12.html Computing only the needed values would mean that the array entries are something like Union(Coef, "not-yet-computed") I'm not sure that this an efficient way to go. Of course that needs tests. I somehow think that hash tables is the more appropriate data structure for this business. But there should be an intelligent way of not throwing away already cached data... Oh... actually, the suggestion in my previous mail works, i.e. Rep == Record(fun: PI -> Coef, cache: Table(PI, Coef)) We would have for f: % (I here identify Rep and %): elt(f: %, n: PI): Coeff == if key?(n, f.cache) then qelt(f.cache, n) else (f.fun)(n) And -(f: %): % == g(n: PI): Coef == - elt(f, n) per [g, table()] This has a initially empty cache for -f, but the full cache remains in f, so if a value for (-f)(n) is needed where f(n) is in the cache, that should be only a short delay. Ralf -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
