0. For a floating point vector, ~.!.0 is faster than ~., but not to the
extent that Bill Lam implied.
timer=: 6!:2
x=: 1e6 ?@$ 0
10 timer '~.x'
0.136236
10 timer '~.!.0 x'
0.0814054
Same comments apply to other functions in the index-of family.
1. For non-numeric arguments (and boxed arrays not involving numbers),
~.!.0 should run at the same speed as ~.
x=: a.{~ 1e6 12 ?@$ 256
10 timer '~.x'
0.13204
10 timer '~.!.0 x'
0.130772
2. Floating point matrices can have O(n^2) performance. It's best to use
~.!.0 if you can get away with it.
3 : '10 timer ''~.t'' [ t=. 1.5,.y ?@$ 0'"0 ]10^0 1 2 3 4
3.03225e_6 5.45805e_6 0.000412806 0.012665 1.01016
3 : '10 timer ''~.!.0 t'' [ t=. 1.5,.y ?@$ 0'"0 ]10^0 1 2 3 4
4.05855e_6 4.3851e_6 3.11155e_5 0.000177643 0.0015026
3. Boxed arrays involving numerics (even all integers) can have O(n^2)
performance. It's best to use ~.!.0 if you can get away with it.
I don't remember the exact details of how this comes about. Best to check
the source, or at least run a few (small) benchmarks.
3. The interpreter checks for interrupts predominantly during memory
allocation. If there is a computation that runs for a long time and
appears to be uninteruptible, this is the most likely culprit. Note: most
anything in J can not proceed without allocating memory.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm