It is difficult to come to any sensible conclusion when
more than one thing is varied. Anyway:
- It is known that applying functions to larger chunks
is faster than applying to smaller chunks, because
any overhead is amortized over a greater number
of elements.
- It is known that boxed arrays take longer because
something has to be done on small chunks.
- It is known that comparing expressions that
are not equivalent is usually futile.
> Somebody resolve this quick--I accidentally typed ".
> instead of {. while looking at this!
I don't know what this means, so can not solve it.
----- Original Message -----
From: Marshall Lochbaum <[email protected]>
Date: Wednesday, September 1, 2010 18:10
Subject: Re: [Jprogramming] Splitting an integer into its digits
To: 'Programming forum' <[email protected]>
> Wait just a second...
>
> dd=.1e5?2e9
> 6!:2 '(10&#.^:_1 )&.>dd'
> 3.31308
> 6!:2 '(''0123456789'' i. ":)&.>dd'
> 0.119448
> 6!:2 ' "."0@":&.>dd'
> 0.0710835
> 6!:2 '(10&#.^:_1) dd'
> 0.0532393
> 6!:2 ' "."0@":"0 dd'
> 0.0829183
>
> The fastest non-padded execution is actually ("."0@":), just as
> promised.(10&#.^:_1) is only faster for arrays because it
> doesn't have to be run with
> rank 0.
> Somebody resolve this quick--I accidentally typed ". instead of
> {. while
> looking at this!
>
> Marshall
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Roger Hui
> Sent: Wednesday, September 01, 2010 8:28 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Splitting an integer into its digits
>
> The second expression can be simplified to
> ('0123456789' i. ":)&.>dd
> which would make much it easier to understand and 50% faster.
>
> 10&#. b. _1
> ($&10@>:@(10&(<....@^.))@(1&>.)@(>./)@:|@, #: ]) :.(10&#.)
>
> reveals why 10&#.^:_1 is so much slower and points to
> substantial room for
> improvement if we decide to do something about it.
>
>
>
> ----- Original Message -----
> From: Devon McCormick <[email protected]>
> Date: Wednesday, September 1, 2010 17:03
> Subject: Re: [Jprogramming] Splitting an integer into its digits
> To: Programming forum <[email protected]>
>
> > dd=. 1e5?2e9
> > 6!:2 '(10&#.^:_1 )&.>dd'
> > 3.7797712
> > 6!:2 '((<''0123456789'')i.&>":&.>)&.>dd'
> > 0.15169945
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm