Help / Release / J 4.06 / f;.n Sparse Arguments

From J Wiki
Jump to navigation Jump to search


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



f;.n Sparse Arguments

initial writing: 2000-12-08
last updated: 2004-10-21


The dyad x f;.n y now has special code for sparse boolean vector x . For example:


   ts=: 6!:2 , 7!:2@]

   f0=: {. ; }.                                2-cut case
   f1=: 4 : '(1 (0,x.)}1$.(#y.);0;0) <;.1 y.'  sparse left argument to cut
   f2=: 4 : '(1 (0,x.)}(#y.)$0) <;.1 y.'       dense  left argument to cut

   x=: 1e5
   y=: i.1e6
   x (f0 -: f1) y
1
   x (f1 -: f2) y
1
   ts 'x f0 y'
0.028419 4.72e6
   ts 'x f1 y'
0.0288414 4.72653e6
   ts 'x f2 y'
0.0480949 6.82246e6

   p=: ?.20$#y
   p (f1 -: f2) y
1
   ts 'p f1 y'
0.0385063 5.95846e6
   ts 'p f2 y'
0.0635578 8.05395e6



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