Charles Greathouse on Tue, 25 Nov 2014 23:08:57 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: New gp function fold()


Yes, that's precisely what I mean, Loïc.

> This is mostly useful for multiplication, and factorback() and lcm() already
> handles this case. Do you have other examples ?

An obvious example would be chinese(). But anywhere partial results are large this function could be useful. One eventual application would be parallelization -- if you've already told gp that the operation is associative, and nbthreads > 1, it could split the calculation onto two or more cores. (I'm not suggesting that we implement this now -- but having it in the language would make it easier to do this in the future, which may be useful as the number of cores rise.)

Charles Greathouse
Analyst/Programmer
Case Western Reserve University

On Tue, Nov 25, 2014 at 4:28 PM, Loïc Grenié <loic.grenie@gmail.com> wrote:
2014-11-25 22:05 GMT+01:00 Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>:
> On Tue, Nov 25, 2014 at 03:08:26PM -0500, Charles Greathouse wrote:
>> We might consider a function (or flag) that folds by binary splitting. For
>> example, this could be used to keep subproducts small:
>
> Binary splitting is not necessarily useful for all associative operations.

  Thus it sounds like a flag is useful !

> This is mostly useful for multiplication, and factorback() and lcm() already
> handles this case. Do you have other examples ?
>
> But as you say, the issue is that it would be awkward to document for
> non-associative operations.

Doc: if the operation is not associative, the result is random.

     Loïc