tv=. 123334 122344 121212 111222 112122 555432

     ,+./"2]1=($&~.)"1(0 1 2,1 2 3,2 3 4,:3 4 5){"2 1(6#10)#:tv


1 0 0 1 0 1





    Den søndag den 4. juli 2021 01.59.28 CEST skrev Julian Fondren 
<[email protected]>:  
 
 On Saturday, July 3rd, 2021 at 6:50 PM, Julian Fondren 
<[email protected]> wrote:
> That takes about 80x as long as the attached method
> using the FFI and a quick library in D.

That attachment got stripped? Well, it's nothing special.

extern(C) void triples(int* xs, int len) @nogc {
    foreach (i; 0 .. len)
        xs[i] = triple(xs[i]);
}

  triplesd =: './libtriple.so triples n *i i'&cd
  triples =: [: triplesd (; #)
  triples 123334 122344 121212 111222 112122 555432
+-+-----------+-+
|0|1 0 0 1 0 1|6|
+-+-----------+-+
  $(#~ triple"1) sn
33219 6
  $(#~ 1 {:: triples) n
33219
  30 timex '$(#~ triple"1) sn'
0.869076
  30 timex '$(#~ 1 {:: triples) n'
0.0100672

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
  
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to