Just a few quick note : Sometimes avoiding loops is more trouble than it's worth.
I used a loop and I expect that the exec. time penalty will in the end not be too great. In this case, - I added a feature to the simulation. As a result an extra step was added and the following was looped through. a=:*/\(0,.2#"1 ,.i.5)}."1 3 (i.2 5 5) - the needed shift was actually by 1 line and column on the first 2 5 5 array, 2 lines and columns on the second etc. Avoiding the loop seemed to make the resulting code a bit too intricate. b=: (-i.5)|."0 1"2 (-i.5)|."0 1&. |:"2 a Cheers On Mon, Mar 2, 2009 at 8:43 PM, Robert Cyr <[email protected]> wrote: > > Thank you. > > This is part of a attempt to do a cumulative product on the diagonals of > the first 2 dimensions and store the result as a higher rank matrix. > > Start with a 2 5 5 matrix end up with a 5 2 5 5 matrix > > a=:*/\(0,.2#"1 ,.i.5)}."1 3 (i.2 5 5) NB. The result must be shifted back > to the lower left corner of each 5 5 matrix. > b=: (-i.5)|."0 1"2 (-i.5)|."0 1&. |:"2 a > > > But the thing looks a bit heavy-handed. There must be an easier way. Any > suggestion? > > The first 2 dimensions are actually lower left triangular, and as in fact > my array gets a bit large I was thinking of using a partitioned array until > I gave up. It would probably save space and time but I am trying to keep > things simple. > > > On Mon, Mar 2, 2009 at 5:47 PM, Brian Schott <[email protected]>wrote: > >> Try this. >> >> 0 2 1 2|."0 1&. |:"2(i.2 3 4) >> >> >> >> >> -- >> (B=) >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
