Dear Marshall and Henry,

Marshall Lochbaum <[email protected]> writes:
> Although a matrix product will execute faster, if I want to write tensor
> code that is straightforward, and extends to multiple contracted axes, I
> would transpose the contracted axes to the end and combine them with
> (+/@:*"1).

This is exactly how I was thinking yesterday. But I could not make the
shapes and ranks fit, and I gave up, and asked the question here,
thinking that I must have been doing something really wrong... (That the
problem at hand should be 'easy', especially in J.)


> The idea with (|:~ 1 -.~ i.@(#@$)) is to get the list of indices for
> ...

Thanks for the explanation. When I saw Henry's answer I was taken aback,
but after some thought I now understand what is going on.


> I think this is a weak point for J's array programming style. Just like
> tacit code works well for small manipulations but gets confusing and
> difficult as the number of arguments increases, J primitives like rank,
> transpose, and inner product are excellent for a few axes, but don't
> work so well when the number of axes increases and the ways they are
> manipulated become more complicated. In J's defense, most programming
> languages are pretty awful at this (how many times are you going to
> write .map before you just give up?). But it's something that bothers
> me. Sure, I can write a bunch of nested rank operators to do what I
> want, but why is it so hard to just say which axes correspond to which?

Generally, I wonder whether trying J is worth it. It happened again that
something one could write explicitly with ease in, say, fortran (the
code would be more verbose, but straightforward), took me many hours to
get working in J. I guess, pragmatically, it does not pay off, but, for
the fun of it, it is interesting to see how far one can get. I love
those little sniplets that can solve quite complex problems really
succinctly.


Thanks to both of you again,
Ruda
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to