At the same time it was puzzling how the most
straightforward method--passing concrete indices
and lengths--did not produce a good speed.

    f3=: (,:"0~ 0,+/[EMAIL PROTECTED]:)@[ <;.0 ]
    f3a=: <;.0

    z=. (,:"0~ 0,+/[EMAIL PROTECTED]:) x


    x (f0 -: f3) y
1
    z ((x f0 ]) -: f3a) y
1

   3 ts 'x f0 y'
0.0341443 1.09757e7
   3 ts 'x f1 y'
0.00830281 4.22656e6
   3 ts 'x f3 y'
0.0155314 5.07117e6
   3 ts 'z f3a y'
0.0116746 4.94016e6



> From: Roger Hui <[EMAIL PROTECTED]>
> 
> It has been a long quest in APL/J to make
> x e. y  as fast as  1 x1}y1 .  The quest continues.
> 
> I must say that I like Brian Schott's solution (I.x)> the best.  The 
> implementation should reward concise
> solutions and I'll see if I can make that solution faster.
> 
> 
> ----- Original Message -----
> From: "Sherlock, Ric" 
> Date: Tuesday, November 4, 2008 22:57
> Subject: RE: [Jprogramming] cut on length
> To: Programming forum 
> 
> > ---Roger Hui wrote:
> > >    f0=: 4 : '(I.x)> > >    f1=: 4 : '((i.#y) e. +/\0,x) <;.1 y'
> > >
> > >    x=: 1+1e4 [EMAIL PROTECTED] 100
> > >    y=: t {~ (+/x) [EMAIL PROTECTED] #t=. 'barack obama'
> > >
> > >    x (f0 -: f1) y
> > > 1
> > >    ts=: 6!:2 , 7!:[EMAIL PROTECTED]
> > >
> > >    ts 'x f0 y'
> > > 0.0700156 1.09591e7
> > >    ts 'x f1 y'
> > > 0.00778395 4.20992e6
> > 
> > When I saw Brian's solution I wasn't going to post mine - his 
> > was so much simpler (BTW I have only used monadic I. to turn a 
> > boolean into an index of 1s and hadn't realised what it did with 
> > integers). Roger's post prompted me to time mine and the result 
> > surprised me.
> > 
> >    f2=: 4 : '(1 (<:+/\x)} (#y)$0) <;.2 y'
> >    x (f1 -: f2) y
> > 1
> >   50 ts 'x f0 y'
> > 0.030942459167 10976256
> >   50 ts 'x f1 y'
> > 0.0077791269561 4227072
> >   50 ts 'x f2 y'
> > 0.0060425808308 2654272
> ----------------------------------------------------------------------
> 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