Ariel Pacetti on Fri, 06 Feb 2015 00:47:00 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: fordiv question |
I placed the 1 argument by mistake (which made the computation much faster).
Better (and faster): ? P = [2,3,5,7]; ? forvec(X=[[0,240],[0,50],[0,20],[0,15]], x=factorback(P,X)) time = 1,821 ms. Of course, the divisors() implementation is much faster since it doesn't start from scratch multiplying all primes together? fordiv(2^240*3^50*5^20,x,1) ? ## *** last result computed in 90 ms.Indeed: the time necessary to sort the divisors. For integer arguments, fordiv is specified to output divisors by increasing size. If we remove that condition, then indeed an iterator is going to be (much) faster. OTOH for other types of inputs, divisors are output in (seemingly) random order, so we might as well always use an iterator in this case. All trivial to implement but I'm not sure how useful this would be...
I think it is as useful as running over the elements of divisors(N). I thought that the point of using fordiv was to avoid storing the whole data (like in forqfvec). As you mentioned Karim, it is quite easy to implement, but looks what one would want fordiv to do.
Thanks for your answer and Bill's one. Ariel