Is this what you want? a=:i.4 4 m=:1 1 0 0,:0 1 1 1 (8$m)*(2#a) 0 1 0 0 0 1 2 3 4 5 0 0 0 5 6 7 8 9 0 0 0 9 10 11 12 13 0 0 0 13 14 15
On Thu, Sep 6, 2012 at 8:28 AM, Devon McCormick <devon...@gmail.com> wrote: > I'm not as conversant with rank as you are. To my way of thinking, > you want to multiply each row of "a" by each row of the multiplier: > > a *"1/2 4$ 1 1 0 0 0 0 1 1 > 1 1 0 0 > 0 0 1 1 > > 1 1 0 0 > 0 0 2 2 > > 1 1 0 0 > 0 0 3 3 > > 1 1 0 0 > 0 0 4 4 > > This gives a 3-D result, which may be handy depending on what you next > plan to do with this. However, as David shows, you can also ravel the > first two dimensions into one: > > ,/a *"1/2 4$ 1 1 0 0 0 0 1 1 > 1 1 0 0 > 0 0 1 1 > 1 1 0 0 > 0 0 2 2 > 1 1 0 0 > 0 0 3 3 > 1 1 0 0 > 0 0 4 4 > > > On Wed, Sep 5, 2012 at 9:56 PM, David Ward Lambert > <b49p23t...@stny.rr.com> wrote: > > Right! "Matrix multiplication" usually means something else. > > You want a sort of element-by-corresponding-element multiplication. > > > > B ; A > > +-------+-------+ > > |1 1 0 0|1 1 1 1| > > |0 0 1 1|1 1 2 2| > > | |1 1 3 3| > > | |1 1 4 4| > > +-------+-------+ > > > > A solution uses rank conjunction twice. I couldn't begin to understand > > it the first time I saw this sort of construction. Then one day I wrote > > rank rank and retrospectively realized what I'd written and understood. > > I practiced rank with sentences like 'abc' "2 i. 2 3 4 > > > > My thoughts to construct this sentence: > > First I realized that you need to multiply row by row. > > The ("1) adverb ensures this. The frames of these two matrices disagree > > because there are 2 rows in B and 4 in A. The next adverb ("_ 1) means > > (because ultimately the final verb is dyadic) "use all of the left array > > with each row of the right hand array". > > > > B * ("1) ("_ 1) A > > 1 1 0 0 > > 0 0 1 1 > > > > 1 1 0 0 > > 0 0 2 2 > > > > 1 1 0 0 > > 0 0 3 3 > > > > 1 1 0 0 > > 0 0 4 4 > > > > Finally, inserting append between the pages gives > > > > ,/B*"1"_ 1 A > > 1 1 0 0 > > 0 0 1 1 > > 1 1 0 0 > > 0 0 2 2 > > 1 1 0 0 > > 0 0 3 3 > > 1 1 0 0 > > 0 0 4 4 > > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > -- > Devon McCormick, CFA > ^me^ at acm. > org is my > preferred e-mail > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm