Leigh - For matrix multiply, as for any other inner-product, the arguments have to be conformable, i.e. the last dimension of the first array should equal the first dimension of the second array, as you can see from Raul's example.
As you can see below, this conformable dimension is the one that gets "swallowed up", leaving the result shaped by the dimensions that were not combined. Regards, Devon $(i.2 3 4) +/ .* i.4 5 6 2 3 5 6 On Mon, Feb 22, 2010 at 10:13 AM, Raul Miller <[email protected]> wrote: > On Mon, Feb 22, 2010 at 10:03 AM, Leigh J. Halliwell > <[email protected]> wrote: > > Dear J Forum: > > > > Wishing to generalize matrix multiplication to arrays of higher rank than > 2, > > I tried the following: > > > > mmult =. +/ . * > > A =. i. 2 3 4 > > B =. i. 3 4 5 > > > > A mmult B NB. Hopefully a 2-by-5 array > > |length error: mmult > > Try (i.2 3 4) +/ .* i.4 5 6 > > Why would you expect a rank 2 array when multiplying > arrays of higher rank? > > -- > Raul > ---------------------------------------------------------------------- > 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
