Essays/Boolean Array Size
Certain operations on boolean arrays are faster if the product of key axis lengths is a multiple of the number of boolean atoms (bytes) in a machine word. It is simplest to ensure this by making the trailing axis length be a multiple. For example:
b=: 10000 3 32 ?@$ 2 c=: 10000 3 31 ?@$ 2 ts=: 6!:2 , 7!:2@] ts '+/b' 0.00534817 1792 ts '+/c' 0.00654999 1792 ts '+./b' 0.00549204 1280 ts '+./c' 0.00769232 1280
In this case */}.$b is 96 and */}.$c is 93; the former is a multiple of 4 (4 bytes in a machine word on 32-bit systems) but the latter is not. Therefore, f/b is faster than f/c even though b has more elements than c .
So if you are doing data design, and it does not matter if the boolean arrays have a few extra columns, then pad them appropriately. At least, do this until the J interpreter is smart enough to do it on its own, in some future release.
Contributed by Roger Hui.