Charles Greathouse on Fri, 21 Jun 2013 15:05:30 +0200


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

Re: setsearch flags


vecsearch doesn't work at all here, since it returns 0 if the element is missing. I'm looking for something giving the position the element would occupy.

Charles Greathouse
Analyst/Programmer
Case Western Reserve University


On Fri, Jun 21, 2013 at 5:55 AM, Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr> wrote:
On Thu, Jun 20, 2013 at 01:28:29PM -0400, Charles Greathouse wrote:
> My immediate purpose was an implementation of Hooley's Δ function, which I
> tried to define as:
>
> Delta(n)=my(d=divisors(n),m=1);for(i=1,#d-1,m=max(setsearch(d,exp(1)*d[i],1)-i,m));m
>
> For each divisor d < n of n, this finds the number of divisors in the
> interval [d, de]. So my vector does consist only of integers. Unfortunately
> neither flag gives the desired behavior, since one or both of floor(de) and
> floor(de+1) may be in the set.
>
> Thus my feature request for another flag on setsearch.

Fundamentally you are using the wrong data structure.
As an abstract data structure, Set are not ordered.
You should use vecsort and vecsearch, which allow for arbitrary comparaison
function to be used.

Cheers,
Bill.