I wrote binc as a monad,  just as a quick way of conjuring up
sets of binomial coefficients:

   binc 5
1 5 10 10 5 1

   3 binc 5 NB. does work, but not as intended!
1 3 3 1 0 0
NB. as does its commute:
   5 binc 3
1 5 10 10
... but again, not as I intended.

div is what does the division;  div&binc a,b just
does (binc a) div binc b


I wasn't particularly interested in the performance of binc,
as Raul was seeking a division algortithm,  and binc was
just easier than typing 1 5 10 10 5 1 or whatever.

I do agree that your definition improves on mine when it
matters,  eg
   ts'binc 500x'
0.0392271 460640
   ts'1, */\ 500x (- % >:@]) i.500x' NB. x=y for my examples
0.001463 504032

I suppose it's now worth investigating the performance of
div cf dbho and divlo cf dblo excluding the overhead of binc:

   'a b' =: binc 50 20
   a (dbho-:div) b
1
   ts'a div b'
1.21e_5 5952
   ts'a dbho b'
2.63e_5 6496
   a (dblo-:divlo) b
1
   ts'a divlo b'
1.06e_5 6976
   ts'a dblo b'
1.75e_5 6496

Thanks for pointing out the overheads imposed by binc,

Mike

On 20/02/2022 16:01, Hauke Rehr wrote:
On my machine, I get

   100 timespacex '1000x binc 500x'
0.101916 957376
   100 timespacex '1, */\ 1000x (- % >:@]) i.500x'
0.00247977 680320


Am 20.02.22 um 13:30 schrieb 'Michael Day' via Programming:
    ts'1000x div&binc 500x'
2.1598005 4815264



--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to