| LoÃc Grenià on Sun, 14 Oct 2012 23:07:52 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: iterators, sums and products |
2012/10/14 Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>:
> On Thu, Oct 11, 2012 at 10:14:17PM +0200, LoÃc Grenià wrote:
>> Hi pari developers,
>>
>> what do you think of the following idea ? Does it look interesting
>> and feasible ?
>>
>> We have a forprime iterator. I've always wished I could sum over
>> primes.
>>
>> My idea is to introduce a new pari type t_ITERATOR which
>> could wrap some iterators (forprime, forsubgroup, forell, etc). For each
>> iterator there would be an initializer. There would also be some
>> users of those iterators: foriter, sumiter, proditer and (why not)
>> vectoriter. Usage:
>
> I miss two things:
> sumprime()
> and a function that return the sum of the element of a vector.
For the last one, I've the attached patch (vecsum and vecprod).
For moderately long vectors, sum(i=1,#v,v[i]) is not so bad...
LoÃc
Attachment:
vecsum.diff
Description: Binary data