> From: Roger Hui
> Sent: Friday, 18 June 2010 04:23
> 
> I have not tried it but ,.&:>/ is probably quadratic.

I can confirm this.

I have gone with the following to give me the performance benefits along with 
error checking.

toMatrix=: 3 : 0
 'length error' assert (= {.)@:#&> t=. ".&.> ;: y
 |: > t
)

toMatrix1=: |:@:(".@>)@;:

toMatrix2=: ,.&:>/@:(".&.>)@;:

toMatrix3=: 3 : 0
 ". ,',.'&,&> ;: y
)

   'Var3 Var5 Var4 Var1 Var2' =: 5 7e5 ?...@$ 60
   
   ts=: 6!:2 , 7!:2...@]

     10 ts 'toMatrix ''Var3 Var5 Var4 Var1 Var2'' '
0.0507515 3.35573e7
     10 ts 'toMatrix1 ''Var3 Var5 Var4 Var1 Var2'' '
0.044986 3.35567e7
     10 ts 'toMatrix2 ''Var3 Var5 Var4 Var1 Var2'' '
0.106096 5.03364e7
     10 ts 'toMatrix3 ''Var3 Var5 Var4 Var1 Var2'' '
0.0945896 7.55026e7
 
> From: Henry Rich 
> Date: Thursday, June 17, 2010 8:56
> 
> > Oh, I didn't see the fine print under ,/ .
> >
> > Ric was planning to use ,.&:>/  which isn't listed as
> > improved, and seems to be quadratic.
> >
> > So I'll just say 'avoid quadratic performance for large operands'.
> >
> > Henry Rich
> >
> > Roger Hui wrote:
> > >> ,./ will work but it will have quadratic performance.
> > >> Avoid for large operands.
> > >
> > >    t0=: 3 : '6!:2 '',./t'' [ t=.
> > (y,43)$''abc'''"0
> > >    t1=: 3 : '6!:2 '',./t'' [ t=.
> > (43,y)$''abc'''"0
> > >    t0 1e5*2^i.4
> > > 0.0979133 0.10202 0.194575 0.391258
> > >    t1 1e5*2^i.4
> > > 0.0770126 0.0742525 0.118406 0.235672
> > >
> > > Looks linear to me.
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: Henry Rich <[email protected]>
> > > Date: Thursday, June 17, 2010 4:55
> > > Subject: Re: [Jprogramming] Combine named lists as matrix
> > > To: Programming forum <[email protected]>
> > >
> > >> I share your antipathy to ". but I think it is
> > unfounded.
> > >> Surely it's
> > >> no different from using 3 :   .
> > >>
> > >> ,./ will work but it will have quadratic performance.
> > >> Avoid for large
> > >> operands.
> > >>
> > >> Henry Rich
> > >>
> > >>
> > >>
> > >> Sherlock, Ric wrote:
> > >>> Thanks Henry
> > >>> This is much simpler but I have this (probably irrational)
> > >> negative feeling about using Do (".). I imagine that Evoke
> > (~)
> > >> is probably just Do (".) under the covers so perhaps I just
> > need
> > >> to get over it!! Reassurances welcome :-)
> > >>> The other thing I like about the other solution is that it
> > >> will give a length error if the columns are not equal length.
> > >> Whether that is desirable is obviously problem dependent, but
> > in
> > >> my case it is a plus. Combining bits I get:
> > >>> ,.&:>/@:(".&.>)@;: 'Var1 Var2 Var3 Var4 Var5'
> > >>>
> > >>>> From: Henry Rich
> > >>>> Sent: Thursday, 17 June 2010 12:23
> > >>>>
> > >>>> |:@:(".@>)      ;: 'Var3 Var5 Var4
> > >> Var1 Var2'
> > >>>> Sherlock, Ric wrote:
> > >>>>> How best to form a matrix from a list of noun names where
> > >> each noun
> > >>>> is a list of values that will form a column in the matrix?
> > >>>>> Below is one solution, are there better ones?
> > >>>>>
> > >>>>> Named nouns:
> > >>>>> 'Var3 Var5 Var4 Var1 Var2' =: 5 7 ?...@$ 60
> > >>>>>
> > >>>>> evoke=: 3 : 'y~'
> > >>>>> toMatrix =: [: ,.&:>/ [: evoke&.> ;:
> > >>>>>
> > >>>>>     toMatrix 'Var1 Var2 Var3 Var4 Var5'
> > >>>>> 16 36  6 31 37
> > >>>>>   0 46 35 32 40
> > >>>>> 24  5 59 58 14
> > >>>>> 24 17 52  0  6
> > >>>>> 11  8 14 10 38
> > >>>>> 13 48 39 42 13
> > >>>>> 23 42 20 11 58
> ----------------------------------------------------------------------
> 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