Help / Release / J 6.02 / u&.(a.&i.) Improved

From J Wiki
Jump to navigation Jump to search


>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release



u&.(a.&i.) Improved

initial writing: 2007-10-17
last updated: 2007-11-28


The phrase u&.(a.&i.) (also u&.(a.i.])) have been made more efficient in the following cases:

Case        Requirements
monad (u-:u"0) y
monad u is  m b./ where m e. 16+i.16
dyad  u is  m b.where m e. 16+i.16

The m b. cases provide bitwise functions on character arguments. Note that the requirement u-:u"0 does not imply that the rank of u must be 0.

The following benchmarks demonstrate the improvement.

x=: a. {~ 1e6 ?@$ 256
y=: a. {~ 1e6 ?@$ 256
c=: a. {~ ?256

ts=: 6!:2 , 7!:2@]  NB. time and space
ts 'Expression'
Expression       J 6.02    J 6.01    Ratio
(256|>:)&.(a.&i.) y  0.004724 1.06458e6 0.050507 1.25868e7 10.69  11.82
123&(22 b.)&.(a.&i.) y 0.001583 1.06470e6 0.030874 9.44115e6 19.51  8.87
x 22 b.&.(a.&i.) y  0.002221 1.05197e6 0.043039 1.25867e7 19.38  11.96
c 22 b.&.(a.&i.) y  0.001419 1.05216e6 0.030395 9.44102e6 21.43  8.97
25 b./&.(a.i.]) y  0.000529 1.66400e3 0.007741 4.20090e6 14.63 2524.58



>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release