I suggest trawling the Knuth
paper<http://arxiv.org/PS_cache/math/pdf/9205/9205211v1.pdf>for ideas.
 It's APL thinking if I ever saw it, but done by a mainstream
mathematician / computer scientist.

How about (x>0)-(x<0) for signum?  Or (a*0=p)+(b*1=p)?  These are blasé to
us, but could be mind-blowing if you've never seen them before.

There is a more complicated but topical (topical to us) one.  Inner
product<http://www.jsoftware.com/papers/innerproduct/ip.htm> (let's
say just on plus and times) in J can be computed as follows, and is in fact
defined as follows:

+/@(*"1 _)

If the traditional approach is characterized as row-by-column, then this
approach is "row-at-a-time".  The paper quoted some benchmarks, including
that on a 600-by-600 matrix, row-at-a-time is faster than row-by-column by
a factor of 10.  There are other benefits to row-at-a-time, described in
the paper and illustrated by the following story:
http://www.jsoftware.com/papers/APLQA.htm#IC2013

The interesting and topical thing is, I recently discovered that a C
implementation of row-at-a-time, when compiled on Visual Studio 2012, ran
2.5 times faster than when compiled on Visual Studio 2005 (or is it
VS2008?).  This is without any changes to the C source and (I believe)
without using multicore.

A final story.  I believe I told it here before, but I like telling it.
 The J implementation of inner product was sped-up using row-at-a-time in
2004 http://www.jsoftware.com/help/release/pdt504.htm .  Of all the
speed-ups this one is special to me, because it is the last significant one
that I was able to tell Ken Iverson about before his passing.  "Hey Ken, if
we implement inner product the way it's defined in the dictionary [years
ago], it's 10 times faster."





On Fri, Jan 17, 2014 at 7:41 AM, Devon McCormick <[email protected]> wrote:

> I'll be talking on J to a meetup here in New York this coming Tuesday -
> http://www.meetup.com/7-Languages-in-7-Months-NYC/ - so I've been watching
> the "fork examples" discussion w/some interest.
>
> I did a dry run of my talk at NYCJUG this past Tuesday and, at that time, I
> was looking to build up to a final, mind-blowing example like the
> Newton-Raphson iterator, but now am thinking that that's too "tricky" and
> what I'd really like to do is go into detail on some simpler examples.  Joe
> Bogner's interest in the parenthesis-nesting idiom reminded me of how
> innovative the array approach still is, so I'm definitely using that one.
>
> David Lambert, who was at the NYCJUG meeting has also given me a couple of
> good ideas since then but I'm interested in anyone else's favorite J idiom
> - "Jems" as Dan would have it - that illustrate the usefulness of array
> thinking.
>
> Thanks,
>
> Devon
> --
> Devon McCormick, CFA
> ----------------------------------------------------------------------
> 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