Bill Allombert on Tue, 06 Sep 2016 23:03:50 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: No more vector gcd and lcm? |
On Tue, Sep 06, 2016 at 04:31:46PM -0400, Charles Greathouse wrote: > Recently changes were committed to the git version to drop support for gcd > and lcm on vectors (and columns and matrices). This has been a useful > feature, is there a reason for dropping it? > > There are a thousand sequences in the OEIS which use lcm or gcd and it's > not entirely clear which use the version that was removed. (Probably not > that many, but still, breaking changes are bad.) Could you give an example ? > Of course fold can be used to replace these constructs, but this can be > very much slower in the case of lcm. vector(10^6,i,random(10^6)+1) is 300x > slower with fold than with the original version. (In fairness, I don't know > of any applications of huge LCMs of big numbers.) The one which has been removed is not the one that can be done using fold(). Instead it is the one that can be done using apply + a function that compute the external Cartesian product of two vectors. ? gcd([1,2],[3,4,5]) %2 = [[1,1],[1,2],[1,1]] Cheers, Bill.