Why do you want the shape to be M,N,M?  A*"1/B has shape M,M,N, the "wrong"
shape for you, but feels like a nice computation.



On Sun, Dec 8, 2013 at 7:06 AM, Nollaig MacKenzie <[email protected]
> wrote:

> Recently I was playing with something where I had two M by N
> arrays, and I wanted a sort of product with shape M by N by M.
> What I wanted was tantamount to
>
>         (1 3;2) |: A */ B
>
> or, nicer,
>
>         1|: A *"1/ B
>
> But it occurred to me that the problem had the look of an
> inner product that didn't go all the way:
>
>         A f/ . * |: B
>
> would give a result with shape M by M (the N-length axes
> would first merge, then disappear with the reduction).
> But the left function of a J inner product doesn't have
> to be a reduction. So if I had a left function that did
> nothing.... The hook
>
>         ] . * |:
>
> perverse though it looked, gave the correct result.
>
> It was also a trifle faster for the smallish arrays I
> tried, and since I could as well have made one of the
> arrays N by M anyway, I could drop the transpose and
> just have
>
>         A ] . * B
>
> which is nicer than
>
>         1|: A *"1/ B
>
> I suppose I had never really internalized the point about
> the difference between APL and J inner products.
>
> NM
> --
> Nollaig MacKenzie
> http://www.yorku.ca/nollaig
> ----------------------------------------------------------------------
> 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